The variables double myRangeLong and double my RangeShort, are used to determine the Exit. The Long part works fine, while the Short, opens and closes the position on the same bar. If, however, use only the code for the Short is okay.

Ciao
Roberto
Code:
# region OrderRouting
private void ManagerOrder ()
{
if (Position.MarketPosition == MarketPosition.Long && callOnce )
double myRangeLong = (MAX (HIGH, 3) [0]-MIN (Low, 10) [1]);
callOnce = false; // OK

}
{
if ( High [0]> (Position.AvgPrice +myRangeLong * 0.5)// myRangeLong OK
SetStopLoss (CalculationMode.Price, Position.AvgPrice);
}
if (Position.MarketPosition == MarketPosition.Short && callOnceB )
double myRangeShort = ((MIN (Low, 2) [0] - MAX (H, 10) [2]) *- 1);
callOnceB = false;//if the position is short the variable is true instead of false
Why?{
if ( Low [0]< (Position.AvgPrice - myRangeShort * 0.5)//myRangeShort not update. It remains default ( 1 ).

SetStopLoss (CalculationMode.Price, Position.AvgPrice);
}
protected override void OnBarUpdate ()
if (Position.MarketPosition == MarketPosition.Flat)
callOnce = true;
if (Position.MarketPosition == MarketPosition.Flat)
callOnceB = true;
ManagerOrder ();
if (Position.MarketPosition! = MarketPosition.Flat) return;
/ / Long
Etc. ....
/ / Short
Etc. ...


Why?
Comment