iHighest() and iLowest()

 

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()); 
 
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
 
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? 
 
double BuyPendingPrice=High[iHighest(NULL,0,MODE_HIGH,90,1)] + some_point*Point;
 
ffoorr:
Thank you kindly. Pretty obvious indeed. 
 
Especially since val=High[val_index]; was in the iHighest - MQL4 Documentation



 
DeanDeV #:
Thank you kindly. Pretty obvious indeed. Hi Dean,So did the code solve your issue?

Hi Dean,

So did it solve your code?

 
@Stefano Diamante #:Hi Dean, So did it solve your code?

Yes, he did. Read the thread (and the documentation referenced).

Reason: