auto close
auto close
22 May 2024, 19:58
Hi I have built an code that says if open trade at 21.30 then close positions.
It works in backtesting but not live at my demo account, what is wrong?
if (utcTime.Hour == 19 && utcTime.Minute >= 30) // 19:30 UTC corresponds to 21:30 UTC+2
{
if (isTradeInitiated)
{
CloseOpenTrades();
}
Stop();
}
}
private void CloseOpenTrades()
{
foreach (var position in Positions)
{
if (position.Label == Label)
{
ClosePosition(position);
}
}
}
PanagiotisCharalampous
23 May 2024, 05:34
Hi there,
Please share with us the following
Best regards,
Panagiotis
@PanagiotisCharalampous