if ((Position.MarketPosition == MarketPosition.Long && myFreeTradeLong == true) )
{
double ask = GetCurrentAsk();
double bid = GetCurrentBid();
double tpByATRRecalculated = Instrument.MasterInstrument.RoundToTickSize(Positi on.AveragePrice + tpByATR * TickSize);
double slRecalculated = Instrument.MasterInstrument.RoundToTickSize(Positi on.AveragePrice - slLongMinMax[1] * TickSize);
//Buy Stop Order: Set price >= current Ask
if (FixedStopLoss)
{
if(slRecalculated.ApproxCompare(bid) >= ask)
{
ExitLongStopMarket(0, true, Position.Quantity, slLongMinMax[1], "SLL", "TLL");
}
}
if (UseTPByATR)
{
if(tpByATRRecalculated.ApproxCompare(ask) <= bid)
{
ExitLongLimit(0, true, Position.Quantity, Position.AveragePrice + (TickSize * tpByATR), "tpByATRRecalculated", "TLL");
}
}
}

Comment