Ihigh & ilow isn't work

 

I added this part of code, but does not work, all the others if it works, OK.

int iHigh20H1 = iHighest(NULL,PERIOD_M15,MODE_HIGH,20,1);

double highestPrice = iHigh(NULL,PERIOD_M15, iHigh20H1);

if (highestPrice < Bid)

int iLow20H1 = iLowest(NULL,PERIOD_M15,MODE_LOW,20,1);

double lowestPrice = iLow(NULL,PERIOD_M15, iLow20H1);

if (lowestPrice > Ask)

Anyone can help me? tkn

         int iHigh20H1 = iHighest(NULL,PERIOD_M15,MODE_HIGH,20,1); 
         double highestPrice = iHigh(NULL,PERIOD_M15, iHigh20H1);
    
         int iLow20H1 = iLowest(NULL,PERIOD_M15,MODE_LOW,20,1);
         double lowestPrice = iLow(NULL,PERIOD_M15, iLow20H1);
         

   if ((((Buy4_1 + Buy7_1 + Buy10_1) + (Sell3_1 + Sell6_1 + Sell9_1))/3  > Sell3_2) && ((Sell2_1 + Sell5_1 + Sell8_1)/3 > Sell2_2 && ((Buy4_1 + Buy7_1 + Buy10_1) + (Sell3_1 + Sell6_1 + Sell9_1))/3 > Sell2_2)) Order = SIGNAL_BUY;

   if ((((Buy4_1 + Buy7_1 + Buy10_1) + (Sell3_1 + Sell6_1 + Sell9_1))/3 < Buy4_2) && ((Buy2_1 + Buy5_1 + Buy8_1)/3 < Buy2_2 && ((Buy4_1 + Buy7_1 + Buy10_1) + (Sell3_1 + Sell6_1 + Sell9_1))/3 < Buy4_2)) Order = SIGNAL_SELL;
   
   if (DayOfWeek()==5)Friday=TRUE;


if (openbuy == 0) // Op Buy
{
   if (lowestPrice > Ask) 
    {
      if (Order == SIGNAL_BUY && (DayOfWeek()!=5) && IsTradedOnThisBar!=Bars)) 
       {        
             if(!IsTradeAllowed())
             {
              Print("Trade context is busy! The expert cannot open position!");
              return(-1);
             }
             else
             Print("Trade context is free! Trying to open position...");
         
             if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
             if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

             {Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
             IsTradedOnThisBar = Bars;}
             if(Ticket > 0) 
             {
                if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) 
                {
                                    Print("BUY order opened : ", OrderOpenPrice());
                    if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
                               } 
                               else 
                               {
                                    Print("Error opening BUY order : ", GetLastError());
                               }
             }
             return(0);     
       } 
    }   
}
if (openbuy != 0)
 { 
   if (lowestPrice > Ask)
    {  
      if ((PriceBuy()/OpenedBuy()) > Ask) // this is the price gain equal to 0
      {
       if (Order == SIGNAL_BUY && IsTradedOnThisBar!=Bars) 
       {       
             if(!IsTradeAllowed())
             {
              Print("Trade context is busy! The expert cannot open position!");
              return(-1);
             }
             else
             Print("Trade context is free! Trying to open position...");
         
             if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
             if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

             {Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
             IsTradedOnThisBar = Bars;}
             if(Ticket > 0) 
             {
                if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) 
                {
                                    Print("BUY order opened : ", OrderOpenPrice());
                    if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
                               } 
                               else 
                               {
                                    Print("Error opening BUY order : ", GetLastError());
                               }
             }
             return(0);
       } 
    }     
  }
 }

 
         int iHigh20H1 = iHighest(NULL,PERIOD_M15,MODE_HIGH,20,1); 
         double highestPrice = iHigh(NULL,PERIOD_M15, iHigh20H1);
Print("iHigh20H1 =   ",iHigh20H1,"  highestPrice =   ",highestPrice);  
 
Right, this is fine, but only see it with 4 digits, you should get with 5 digits.
 
Bellagio:
Right, this is fine, but only see it with 4 digits, you should get with 5 digits.
Read the documentation about Print()
 
deVries and RaptorUK, it already works, thanks all
 
  1. Bellagio:
    Right, this is fine, but only see it with 4 digits, you should get with 5 digits.
    Print("iHigh20H1 =   ",PriceToStr(),"  highestPrice =   ",PriceToStr(highestPrice));  
    //////////////////////////////////////////////////////////
    string  PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }
    string  DeltaToPips(double d){
        if (d > 0)  string sign = "+";  else    sign = "";
        double pips = d / pips2dbl;
        return (sign + DoubleToStr(pips, Digits.pips)); }
    
  2. int iHigh20H1 = iHighest(NULL,PERIOD_M15,MODE_HIGH,20,1); 
    Why is your variable name 20H1 when it runs on the M15
  3. if (DayOfWeek()==5)Friday=TRUE;
    is Friday ever set to false? Simplify
    bool Friday DayOfWeek()==5;

  4. datetime now = TimeCurrent(); // Or Time[0]
    int      DOW = TimeDayOfWeek(now); // https://www.mql5.com/en/forum/127483 reports
                                       // DayOfWeek() always returns 5 (tester)
    
Reason: