iHighest() and iLowest()

Back to topics list To post a new topic, please log in or register
avatar
120
DeanDeV 2015.06.01 17: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()); 

 

avatar
12988
WHRoeder 2015.06.01 19: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
avatar
120
DeanDeV 2015.06.01 20: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? 
avatar
250
ffoorr 2015.06.02 11:27 #
 
double BuyPendingPrice=High[iHighest(NULL,0,MODE_HIGH,90,1)] + some_point*Point;
avatar
120
DeanDeV 2015.06.02 15:10 #
 
ffoorr:
Thank you kindly. Pretty obvious indeed. 
avatar
12988
WHRoeder 2015.06.02 20:14 #
 
Especially since val=High[val_index]; was in the iHighest - MQL4 Documentation



Back to topics list  

To add comments, please log in or register