Limit On Open Orders (LOO)

Modified on 2018/02/28 07:29 by Eugene — Categorized as: Community Components

Syntax

public static Position EnterLOO(this WealthScript ws, int tradeBar, PositionType pt, double limitPrice, string signalName = "") public static bool ExitLOO(this WealthScript ws, int tradeBar, Position p, double limitPrice, string signalName = "")

Parameter Description

tradeBarPass bar + 1 to this method
ptPositionType.Long or PositionType.Short
limitPriceLimit price
signalName(optional) Entry/exit signal name

Description

Created by Robert Sucher, these methods emulate Limit On Open (LOO) orders.

Example

Example using C# extension methods:

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { for(int bar = GetTradingLoopStartBar(20); bar < Bars.Count; bar++) { if( bar < Bars.Count-1 ) // for backtesting only { if (IsLastPositionActive) { this.ExitLOO(bar+1, LastPosition, Highbar); } else { this.EnterLOO(bar+1, PositionType.Long, SMA.Value(bar, Close, 20) * 0.98); } } } } } }