Why my codes only place Long order and ExitLong once? I want the strategy continue to place Long order/Exit Long when the condition is met.
My codes:
{
strDirection = string.Format("\tHiLoTrend UpTrend !!");
PrintLog(strDirection);
if (Position.MarketPosition == MarketPosition.Flat)
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"leTMA");
PrintLog("Enter Long-leTMA");
}
}
else if (hiLoTrend == -1)
{
strDirection = string.Format("\tHiLoTrend DownTrend !!");
PrintLog(strDirection);
if (Position.MarketPosition == MarketPosition.Long)
{
ExitLong(Convert.ToInt32(DefaultQuantity), @"LeExitTMA", @"leTMA");
PrintLog("Exit Long - LeExitTMA");
}
}
Logs:
10/11/2023 2:19:09 PM Strategy 'AlgoTechNQTrendMA/307965668': Entered internal SubmitOrderManaged() method at 10/11/2023 2:19:09 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='LeExitTMA' FromEntrySignal='leTMA'
10/11/2023 2:19:09 PM Strategy 'AlgoTechNQTrendMA/307965668': Ignored SubmitOrderManaged() method at 10/11/2023 2:19:09 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='LeExitTMA' FromEntrySignal='leTMA' Reason='There already is a matching order with same prices and quantity'
Time:2023-10-11 14:19:10.000 Exit Long - LeExitTMA
Time:2023-10-11 14:19:20.000 MarketPosition.Long Pos:1| Avg:15291.25
Time:2023-10-11 14:19:20.000 Entered OnBarUpdate()
Time:2023-10-11 14:19:20.000 HiLoTrend DownTrend !!
10/11/2023 2:19:19 PM Strategy 'AlgoTechNQTrendMA/307965668': Entered internal SubmitOrderManaged() method at 10/11/2023 2:19:19 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='LeExitTMA' FromEntrySignal='leTMA'
10/11/2023 2:19:19 PM Strategy 'AlgoTechNQTrendMA/307965668': Ignored SubmitOrderManaged() method at 10/11/2023 2:19:19 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='LeExitTMA' FromEntrySignal='leTMA' Reason='There already is a matching order with same prices and quantity'
Time:2023-10-11 14:19:20.000 Exit Long - LeExitTMA
Comment