Negative GrossProfit stop robot with closeposition
Created at 30 Jun 2021, 18:39
Negative GrossProfit stop robot with closeposition
30 Jun 2021, 18:39
Hi,
how can I closeposition and stop robot when GrossProfit is $-10 ?
This code not works on OnTick ?
foreach (var position in Positions)
{
if (position.GrossProfit < -10)
{
ClosePosition(position);
Stop();
}
}
amusleh
01 Jul 2021, 11:37
Hi,
I don't see any issue on your code, it should work fine if there is any position that has less than 10 gross profit, it might not working because the OnTick method is called only for chart symbol ticks, not all position ticks, if you want to manage multiple symbols positions then try this:
@amusleh