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
tradeBar | Pass bar + 1 to this method |
pt | PositionType.Long or PositionType.Short |
limitPrice | Limit 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, High[bar]);
}
else
{
this.EnterLOO(bar+1, PositionType.Long, SMA.Value(bar, Close, 20) * 0.98);
}
}
}
}
}
}