Hi,
I'm very very new to mql coding, and I'm asking you help with some basic concept.
I'm starting from a very simple attempt: I check if thare aren't orders opened or pending, and I open some orders, market and stop.
When all orders are triggered and closed, in loss or profit, and there are no order pending or opened again, it will place the same orders:
The problem is I'm not able to put it into a cycle; in strategy tester it puts first 10 orders correctly, and when thery are closed, of course, nothing happens.
I've tried with for or while, but I'm very confused with them:
int start()
{
if (OrdersTotal()==0)
{
OrderSend(Symbol(), OP_BUY, 0.01, NormalizeDouble(Ask,Digits), 0, NormalizeDouble(Ask-sl,Digits),NormalizeDouble(Ask+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELL, 0.01, NormalizeDouble(Bid,Digits), 0, NormalizeDouble(Bid+sl,Digits),NormalizeDouble(Bid-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+d,Digits), 0, NormalizeDouble(Ask+d-sl,Digits),NormalizeDouble(Ask+d+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+dueD,Digits), 0, NormalizeDouble(Ask+dueD-sl,Digits),NormalizeDouble(Ask+dueD+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+treD,Digits), 0, NormalizeDouble(Ask+treD-sl,Digits),NormalizeDouble(Ask+treD+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+quattroD,Digits), 0, NormalizeDouble(Ask+quattroD-sl,Digits),NormalizeDouble(Ask+quattroD+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-d,Digits), 0, NormalizeDouble(Bid-d+sl,Digits),NormalizeDouble(Bid-d-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-dueD,Digits), 0, NormalizeDouble(Bid-dueD+sl,Digits),NormalizeDouble(Bid-dueD-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-treD,Digits), 0, NormalizeDouble(Bid-treD+sl,Digits),NormalizeDouble(Bid-treD-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-quattroD,Digits), 0, NormalizeDouble(Bid-quattroD+sl,Digits),NormalizeDouble(Bid-quattroD-tp,Digits), "10-20-corretto", 0, 0, Green);
}
}
I'm very very new to mql coding, and I'm asking you help with some basic concept.
I'm starting from a very simple attempt: I check if thare aren't orders opened or pending, and I open some orders, market and stop.
When all orders are triggered and closed, in loss or profit, and there are no order pending or opened again, it will place the same orders:
The problem is I'm not able to put it into a cycle; in strategy tester it puts first 10 orders correctly, and when thery are closed, of course, nothing happens.
I've tried with for or while, but I'm very confused with them:
int start()
{
if (OrdersTotal()==0)
{
OrderSend(Symbol(), OP_BUY, 0.01, NormalizeDouble(Ask,Digits), 0, NormalizeDouble(Ask-sl,Digits),NormalizeDouble(Ask+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELL, 0.01, NormalizeDouble(Bid,Digits), 0, NormalizeDouble(Bid+sl,Digits),NormalizeDouble(Bid-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+d,Digits), 0, NormalizeDouble(Ask+d-sl,Digits),NormalizeDouble(Ask+d+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+dueD,Digits), 0, NormalizeDouble(Ask+dueD-sl,Digits),NormalizeDouble(Ask+dueD+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+treD,Digits), 0, NormalizeDouble(Ask+treD-sl,Digits),NormalizeDouble(Ask+treD+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_BUYSTOP, 0.01, NormalizeDouble(Ask+quattroD,Digits), 0, NormalizeDouble(Ask+quattroD-sl,Digits),NormalizeDouble(Ask+quattroD+tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-d,Digits), 0, NormalizeDouble(Bid-d+sl,Digits),NormalizeDouble(Bid-d-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-dueD,Digits), 0, NormalizeDouble(Bid-dueD+sl,Digits),NormalizeDouble(Bid-dueD-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-treD,Digits), 0, NormalizeDouble(Bid-treD+sl,Digits),NormalizeDouble(Bid-treD-tp,Digits), "10-20-corretto", 0, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, 0.01, NormalizeDouble(Bid-quattroD,Digits), 0, NormalizeDouble(Bid-quattroD+sl,Digits),NormalizeDouble(Bid-quattroD-tp,Digits), "10-20-corretto", 0, 0, Green);
}
}