Download MetaTrader 5

Envelope indicator upper/lower values are the same

To add comments, please log in or register
Ryan Leland
22
Ryan Leland  

Hey all, I'm a total noob and just experimenting for now. Been playing with, and learning strategies, but I am having issues with using the envelopes indicator.

Given the following code, my upper and lower values are getting output as exactly the same. Any help would be really appreciated.

envelope_handle = iEnvelopes(_Symbol, PERIOD_M1, envelope_period, 0, MODE_LWMA, PRICE_MEDIAN, envelope_deviation);

double env_lower[3], env_upper[3];
   
if (CopyBuffer(envelope_handle, 0, 0, 2, env_lower) < 2 
    || CopyBuffer(envelope_handle, 1, 0, 2, env_upper) < 2) {
      
   Print("No data from CopyBuffer");
   return;
}
   
Comment("upper: ", env_upper[1], " lower: ", env_lower[1]);
Ryan Leland
22
Ryan Leland  

Trying to call ArraySetAsSeries is also failing on both env_lower and env_upper.

ArraySetAsSeries(env_lower, true);
Documentation on MQL5: Array Functions / ArraySetAsSeries
Documentation on MQL5: Array Functions / ArraySetAsSeries
  • www.mql5.com
Array Functions / ArraySetAsSeries - Documentation on MQL5
Shaharudin Ahmad
921
Shaharudin Ahmad  

hi ryanleland

try this

 

double      env_lower[];                     int  envelope_handle;
double      env_upper[];

 envelope_handle = iEnvelopes(_Symbol, PERIOD_M1, envelope_period, 0, MODE_LWMA, PRICE_MEDIAN, envelope_deviation);


      CopyBuffer(envelope_handle,1,0,2,env_upper);
      CopyBuffer(envelope_handle,0,0,2,env_lower);

      ArraySetAsSeries(env_upper,true);
      ArraySetAsSeries(env_lower,true);

 Comment("upper: ", env_upper[1], " lower: ", env_lower[1]);

 

 

Ryan Leland
22
Ryan Leland  
Thanks jelam! That helps.
To add comments, please log in or register