what it does is that to exit the position if the price did not reach my profit target(6%) after 10 bars(bus days).
The problem is that once this profit target get triggered, my 10 bar stop code would not know that I am no longer in a long position. so I want to know how can I get SetProfitTarget() to update variable hasPosition, or how to find out i am no longer in the postion...I tied iPosition and IOrder but i couldnt get them work...
or if there are smarter way to do this. thank you.
Code example:
=======================================
protected override void Initialize()
{
SetProfitTarget(CalculationMethod.Percent, 0.06);
}
protected override void OnBarUpdate()
{ private bool hasPosition=0;
if(MyIndicator==true)
{ EnterLong(0, "myIndicatorLong", 1);
hasPosition=1;
}
If(BarssinceEntry()>10&&hasPosition!=0)
{
ExitLong("myIndicatorLong", 1);
hasPosition=0;
}
}
========================================

Comment