Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi guys I need some help please I am having a hard time getting the grid to replace pending orders if they are turned into market orders...
have a look :
1: This is how I get it to place 6 pending buys and 6 pending sells above and below a set range size that is able to be changed externally :
extern int Interval = 8;
extern int Range = 12;
total=OrdersTotal();
if(total<1)
{
Temp=MarketInfo(Pair, MODE_BID);
for (int Cnt=1;Cnt<=NormalizeDouble((Range/2),0);Cnt++)
{
OrdSend(Pair, OP_BUYSTOP, Lot, Temp+(Cnt*Interval*point()), 0, Temp+(Cnt*Interval*point())-SL*point(),0, CommOrder, Cnt*Magic, 0, Blue);
OrdSend(Pair, OP_SELLSTOP, Lot, Temp-(Cnt*Interval*point()), 0, Temp-(Cnt*Interval*point())+SL*point(),0, CommOrder, (Cnt*Magic)+1, 0, Red);
Comment(Temp+"Cnt : "+Cnt+" interval: "+Interval);
}
}
//--------Keep the Grid by replacing orders if pending orders drop below 6 --------//
//Replace Pending buy orders and add a sell order if pending buy orders drop below 6
if(countbuystop()<6&&countsellstop()>0)
{
Temp=MarketInfo(Pair, MODE_BID);
for (Cnt=1;Cnt<=NormalizeDouble((Range/2),0);Cnt++)
{
OrdSend(Pair, OP_BUYSTOP, Lot, Temp+(6*Interval*point()), 0, Temp+(6*Interval*point())-SL*point(),0, CommOrder, Cnt*Magic, 0, Blue);
OrdSend(Pair, OP_SELLSTOP, Lot, Temp-(1*Interval*point()), 0, Temp-(1*Interval*point())+SL*point(),0, CommOrder, (Cnt*Magic)+1, 0, Red);
Comment(Temp+"Cnt : "+Cnt+" interval: "+Interval);
}
}
//Replace Pending sell orders and add a buy order if pending sell orders drop below 6
if(countsellstop()<6&&countbuystop()>0)
{
Temp=MarketInfo(Pair, MODE_BID);
for (Cnt=1;Cnt<=NormalizeDouble((Range/2),0);Cnt++)
{
OrdSend(Pair, OP_BUYSTOP, Lot, Temp+(1*Interval*point()), 0, Temp+(1*Interval*point())-SL*point(),0, CommOrder, Cnt*Magic, 0, Blue);
OrdSend(Pair, OP_SELLSTOP, Lot, Temp-(6*Interval*point()), 0, Temp-(6*Interval*point())+SL*point(),0, CommOrder, (Cnt*Magic)+1, 0, Red);
Comment(Temp+"Cnt : "+Cnt+" interval: "+Interval);
}
}
This works the first 2 times and replaces the pending orders as they are triggered but after the 2nd time it works...then it stops working.
any 1 know how to fix this??
Thanx in advance guys for any help