This is the code I have so far. It enters OnBarClose, but I cannot figure out how to update my position OnTickUpdate. I was thinking of calculating the indicators OnBarClose, while keeping the strategy OnTickUpdate. However, I don't know what is the best way to do this. Please help
/ Check if Flat
if (Position.MarketPosition == MarketPosition.Flat)
{
CurrentStopPrice = 0;
}
if (CurrentBars[0] < 1)
return;
// Long Entry
if ((RSI1.Avg[0] >= 50)
&& (WaveTrendV21[1] < 53)
&& (SMA1[0] <= Close[0])
&& (CrossAbove(WaveTrendV21.Values[0], WaveTrendV21.Values[1], 1))
&& (Position.MarketPosition == MarketPosition.Flat)
&& (State == State.Realtime))
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"longEntry");
CurrentTriggerPrice = (Close[0] + (TrailFrequency * TickSize)) ;
CurrentStopPrice = (Close[0] + (TrailStopDistance * TickSize)) ;
}
// Stop Update
if ((Position.MarketPosition == MarketPosition.Long)
&& (Close[0] > CurrentTriggerPrice))
{
CurrentTriggerPrice = (Close[0] + (TrailFrequency * TickSize)) ;
CurrentStopPrice = (Close[0] + (TrailStopDistance * TickSize)) ;
}
// Position Close
if (CurrentStopPrice != 0)
{
ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), CurrentStopPrice, @"", "");
}

Comment