- cashmaker:
Here is my cycle to check the last closed order, to decide how many lots the next order will open.
It works fine, but I would like to introduce some break time, e.g. 12h or 24h, if the last order were a loser one.You must find the last closed order. Wither it was a loser, set the delay, and don't trade. Your code finds the last in the list which may not be the last closed, thus you could have dropped the for loop and just orderselect ordersHistoryTotal()-1
- Counting down is more efficient here. (Required for closing/deleting orders)
static datetime tradingAllowed; datetime lastOrderDT; for(int j=OrdersHistoryTotal()-1; j>=0; j--) if ( OrderSelect(j,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol() == Symbol() && OrderMagicNumber()== magico && OrderCloseTime() > lastOrderDT) { lastOrderDT = OrderCloseTime(); if (OrderProfit() > 0 ) { comenta=comentario1; lote=lotes1; } else { tradingAllowed = lastOrderDT + 12 * 3600; // Skip 12 hours /**/ if (OrderLots()==lotes1){ lote=lotes2; comenta=comentario2; } else if (OrderLots()==lotes2){ lote=lotes3; comenta=comentario3; } else if (OrderLots()==lotes3){ lote=lotes4; comenta=comentario4; } else if (OrderLots()==lotes4){ lote=lotes5; comenta=comentario5; } else if (OrderLots()==lotes5){ lote=lotes6; comenta=comentario6; } else if (OrderLots()==lotes6){ lote=lotes1; comenta=comentario1; } } } // end of ORDERSELECT if (TimeCurrent() < TradingAllowed) return(0); ...
WHRoeder:
- cashmaker:
Here is my cycle to check the last closed order, to decide how many lots the next order will open.
It works fine, but I would like to introduce some break time, e.g. 12h or 24h, if the last order were a loser one.You must find the last closed order. Wither it was a loser, set the delay, and don't trade. Your code finds the last in the list which may not be the last closed, thus you could have dropped the for loop and just orderselect ordersHistoryTotal()-1
- Counting down is more efficient here. (Required for closing/deleting orders)
Thank you.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
Here is my cycle to check the last closed order, to decide how many lots the next order will open.
It works fine, but I would like to introduce some break time, e.g. 12h or 24h, if the last order were a loser one.
I just can´t figure out how can I do that.
I already tryed in so many ways, but being a novice means this. :)
Any suggestions? Thanks.
Regards
double j; // Total of closed orders
for(j=0; j<OrdersHistoryTotal(); j++)
{
OrderSelect(j,SELECT_BY_POS,MODE_HISTORY);
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magico && OrderProfit() > 0 )
{
comenta=comentario1;
lote=lotes1;
}
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magico && OrderProfit() < 0 )
{
if (OrderLots()==lotes1)
{
lote=lotes2;
comenta=comentario2;
}
if (OrderLots()==lotes2)
{
lote=lotes3;
comenta=comentario3;
}
if (OrderLots()==lotes3)
{
lote=lotes4;
comenta=comentario4;
}
if (OrderLots()==lotes4)
{
lote=lotes5;
comenta=comentario5;
}
if (OrderLots()==lotes5)
{
lote=lotes6;
comenta=comentario6;
}
if (OrderLots()==lotes6)
{
lote=lotes1;
comenta=comentario1;
}
} // end of losts IF
} // end of ORDERSELECT
} // end of FOR