Download MetaTrader 5
To add comments, please log in or register
MQL5.community allows users to store their source codes in MQL5 Storage. Try it!
DeanDeV
330
DeanDeV 2015.06.01 15:10 

Hi guys,

I have the below code for pending orders. I want it to place a buy stop X points above the highest point in the last few candles, and X amount below the lowest point in the last few candles. The orders aren't being sent at all, and I get OrderSend() 130; not sure why..? Please help.

 

double BuyPendingPrice=iHighest(NULL,0,MODE_HIGH,90,1);
double SellPendingPrice=iLowest(NULL,0,MODE_LOW,90,1);

         int buyticket=OrderSend(Symbol(),OP_BUYSTOP,Lotsize,BuyPendingPrice+(PendingPoints*Point),3,BuyPendingPrice-(Stoploss*Point),BuyPendingPrice+(Takeprofit*Point),"Buy stop pending order",MagicNumber,TimeCurrent()+((ExpirationTimeHours*60*60)+(ExpirationTimeMinutes*60)),clrBlue);
            if(buyticket>0) Print("Buy stop OrderSend() SUCCESS.");
            if(buyticket<0) Print("Buy stop OrderSend() FAILED." , GetLastError());
         
         int sellticket=OrderSend(Symbol(),OP_SELLSTOP,Lotsize,SellPendingPrice-(PendingPoints*Point),3,SellPendingPrice+(Stoploss*Point),SellPendingPrice-(Takeprofit*Point),"Sell stop pending order",MagicNumber,TimeCurrent()+((ExpirationTimeHours*60*60)+(ExpirationTimeMinutes*60)),clrRed);
            if(sellticket>0) Print("Sell stop OrderSend() SUCCESS.");
            if(sellticket<0) Print("Sell stop OrderSend() FAILED." , GetLastError()); 
whroeder1
13641
whroeder1 2015.06.01 17:17  
double BuyPendingPrice=iHighest(NULL,0,MODE_HIGH,90,1);
double SellPendingPrice=iLowest(NULL,0,MODE_LOW,90,1);
Read the documentation. iHighest returns an int iHighest - MQL4 Documentation
DeanDeV
330
DeanDeV 2015.06.01 18:27  
WHRoeder:
Read the documentation. iHighest returns an int iHighest - MQL4 Documentation
Okay thank you. Would you know how to get the highest price and lowest price a certain amount of candles back respectively? 
ffoorr
985
ffoorr 2015.06.02 09:27  
double BuyPendingPrice=High[iHighest(NULL,0,MODE_HIGH,90,1)] + some_point*Point;
DeanDeV
330
DeanDeV 2015.06.02 13:10  
ffoorr:
Thank you kindly. Pretty obvious indeed. 
whroeder1
13641
whroeder1 2015.06.02 18:14  
Especially since val=High[val_index]; was in the iHighest - MQL4 Documentation



/
To add comments, please log in or register