Set TF in indicator and look at open/close of specific candles.

To add comments, please log in or register
pipoholic1
12
pipoholic1  

Hi,

So I am a newbie and just learning MQL4 and I am hoping someone might be able to help me out.  I am trying to set a function to look at the last 2 candles of the 5min TF inside my indicator.  Basically I am looking for a couple of conditions to be met on the 15m chart and then on the 5m chart.  And once those conditions are met I want to populate a value for a parameter so that I can use it for my EA to tell me when to buy/sell.  In this case I want to populate either a 1 or a -1 for the BS_Signal parameter whenever I get an engulfing bar on the 5min TF.  So I have created a function that looks for the engulfing bar on the 5 min chart.  But I cannot get it to work properly. 


I have tried to use iOpen[1] or iClose[2] but this will give me whatever open/close to the TF the indicator is running in if I don't specify a period.  So if I am on the 1h chart it will be wrong. So if you look at the code below I tried to set the period but I get the errors below each iteration I tried.  What am I doing wrong?  How can I set the function to tell me the candles 1 and 2 of the 5min TF (regardless of the TF of the indicator) so that I can calculate if it is an engulfing bar or not?  Any help would be greatly appreciated.


void CheckForEntry() 

{

   iHigh(NULL, PERIOD_M5, 1);

   iLow(NULL, PERIOD_M5, 1);

   iOpen(NULL, PERIOD_M5, 1);

   iClose(NULL, PERIOD_M5, 1);



      if(iOpen[1] >= iClose[2] && iClose[1] <= iOpen[2]) 

      {

         BS_Signal = 1; //Buy signal

}

      if(iOpen[1] <= iClose[2] && iClose[1] >= iOpen[2])

      {

                BS_Signal = -1; //Sell signal

}

}



I Get Error- 'iClose' - undeclared identifier







void CheckForEntry() //This value goes above to figure out when we have an OB/OS condition on the 5m chart

{

      

      high_  = iHigh(NULL, PERIOD_M5, 1);

      low_   = iLow(NULL, PERIOD_M5, 1);

      open_  = iOpen(NULL, PERIOD_M5, 1);

      close_ = iClose(NULL, PERIOD_M5, 1);



      if(open_[1] >= close_[2] && close_[1] <= open_[2]) 

{

                BS_Signal = 1; //Buy signal

      }

      

      if(open_[1] <= close_[2] && close_[1] >= open_[2])

      {

                BS_Signal = -1; //Sell signal 

      }

}


Then I get Error- '[' - array required

Sergey Golubev
Moderator
106642
Sergey Golubev  

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

Thank you.

pipoholic1
12
pipoholic1  
Sergey Golubev:
will do sorry
pipoholic1
12
pipoholic1  
Ok looks like I got it figured out.  Just had to declare the values with different shifts.  currenthigh, previoushigh.
To add comments, please log in or register