I am working on a Ninja Script strategy using support / help Guides / nt7 as a guideline but I can't find a way to make a partial exit.
I enter the market buying 3 contracts and when it reaches Profit >= 6 and hma (10) < hma (50) it sells 2 contracts.
My first problem is that I cannot find the right code to make the remaining contract to pass to BreakEven.
The second problem is that when it reaches Profit >= 6 but hma (10) IS NOT < hma (50). I want the code to "forget" that condition, meaning that it only checks that condition once.
Can anybody help me with this?
Thanks in advance.
protected override void OnBarUpdate()
{
if (HMA(10)[0] > HMA(20)[0])
{EnterLong(3);}
if (Position.MarketPosition == MarketPosition.Long)
{
if (Close[0] >= Position.AvgPrice + 8*TickSize
&& HMA(10)[0] < HMA(50)[0])
{
ExitLong(2);
SetStopLoss("",CalculationMode.Price,thestop-(1*TickSize), false); // ?.
}
}
}
Comment