Dear MrPip,
I would like to ask your help in preventing the situations when DIN_KusKus_EA_v2.4 just closing a trade in profit and places another order at once because the second order frequently closes in loss - please see such situations on the images attached.
I am not a programmer but despite of this tried to set out a snippet of code that is aiming at the prevention the instant placement of a new order on closing the earlier. Would you please check it up and I would like to have your advice on this:
HTML Code:
// Do not open position right on close of the earlier
int i,HsTTotal=OrdersHistoryTotal();
datetime CloseTimeLast = 0;
for(i=0;i<HsTTotal;i++)//---- check order history
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if ((OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber))
{
datetime CloseTime=OrderCloseTime();
if (CloseTimeLast<=CloseTime)
{
CloseTimeLast=CloseTime;
}
RefreshRates();
if (TimeCurrent() - CloseTimeLast < 3600)
{
Sleep(60000);
}
}
return(0);
}