Getting indicator levels from EA?

 

Hi,

I have a indicator where I have spesified the indicator levels as input. So i can have N amount of levels each one a certain spacing apart. All nice and done but now my EA needs to read this Levels...i dont see how to do this?

 I feel lost here... 

 

I think some coders here can help you out. Give it to the as a job. they will certainly do it for you.

Thanks


 
ToolMaker:

Hi,

I have a indicator where I have spesified the indicator levels as input. So i can have N amount of levels each one a certain spacing apart. All nice and done but now my EA needs to read this Levels...i dont see how to do this?

 I feel lost here... 

Hi ToolMaker,

If you call this indicator in EA using iCustom() (click that), then there's should be no problem. Last parameters of iCustom is all the input parameters of your custom indicator - so all you have to do create those input in EA as well.

 

 
onewithzachy:

Hi ToolMaker,

If you call this indicator in EA using iCustom() (click that), then there's should be no problem. Last parameters of iCustom is all the input parameters of your custom indicator - so all you have to do create those input in EA as well.

 

thanks guys for taking time to answer,

Thanks zachy I know you can get the values inside the indicator but the thing is my EA needs the values :( so I can't call it inside the indicator...just thinking now for my scenario...you cant get the values even inside the indicator.... I'm kinda screwed. I use the bollingar, and seting levels on a bollingar draws yet another standard deviation ontop of your standard deviatED line (well atleast this is my conclusion not sure) so my level actually has diffrent values on each bar so I would need to get this values. Here is a pic to show the levels of my bol...

 Bands levels

I'm getting to the conclusion that what I'm trying to do will not work this way/route. I creating a diffrent post to address the actual issue and the reason why I can just have another bolingar on the chart...

Thanks for helping out! 

Files:
BolLevels.PNG  105 kb
 
ToolMaker:

thanks guys for taking time to answer,

Thanks zachy I know you can get the values inside the indicator but the thing is my EA needs the values :( so I can't call it inside the indicator...just thinking now for my scenario...you cant get the values even inside the indicator.... I'm kinda screwed. I use the bollingar, and seting levels on a bollingar draws yet another standard deviation ontop of your standard deviatED line (well atleast this is my conclusion not sure) so my level actually has diffrent values on each bar so I would need to get this values. Here is a pic to show the levels of my bol...

 

I'm getting to the conclusion that what I'm trying to do will not work this way/route. I creating a diffrent post to address the actual issue and the reason why I can just have another bolingar on the chart...

Thanks for helping out! 

added this post in the EA section:

https://www.mql5.com/en/forum/8341 

Stress testing need help on Indicator creation for bolingar PLZ
Stress testing need help on Indicator creation for bolingar PLZ
  • www.mql5.com
Stress testing need help on Indicator creation for bolingar PLZ.
 
ToolMaker:

thanks guys for taking time to answer,

Thanks zachy I know you can get the values inside the indicator but the thing is my EA needs the values :( so I can't call it inside the indicator...just thinking now for my scenario...you cant get the values even inside the indicator.... I'm kinda screwed. I use the bollingar, and seting levels on a bollingar draws yet another standard deviation ontop of your standard deviatED line (well atleast this is my conclusion not sure) so my level actually has diffrent values on each bar so I would need to get this values. Here is a pic to show the levels of my bol...

 

I'm getting to the conclusion that what I'm trying to do will not work this way/route. I creating a diffrent post to address the actual issue and the reason why I can just have another bolingar on the chart...

Thanks for helping out! 

Hi ToolMaker,

Oh the Band.

Very simple, get the distant between middle band to lower band (or the distant between upper band to middle band - its the same value), then multiply it with your level and add it to middle band.

You still have to write those inputs in the EA though, we can't do it programatically.  

input double Level_1 = 2.0;
input double Level_2 = -2.0;
input double Level_3 = 1.5;
input double Level_4 = -1.5;

double lev_1, lev_2, lev_3, lev_4;
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  double distant = middle_band - lower_band; // or upper_band - middle_band
  
  lev_1 = middle_band + Level_1 * distant;
  lev_2 = middle_band + Level_2 * distant;
  lev_3 = middle_band + Level_3 * distant;
  lev_4 = middle_band + Level_4 * distant;
  
  }
//+------------------------------------------------------------------+

 

 
onewithzachy:

Hi ToolMaker,

Oh the Band.

Very simple, get the distant between middle band to lower band (or the distant between upper band to middle band - its the same value), then multiply it with your level and add it to middle band.

You still have to write those inputs in the EA though, we can't do it programatically.  

 

onewithzachy:

Hi ToolMaker,

Oh the Band.

Very simple, get the distant between middle band to lower band (or the distant between upper band to middle band - its the same value), then multiply it with your level and add it to middle band.

You still have to write those inputs in the EA though, we can't do it programatically.  

 

Thanks zachy for you help will try this as this might be a more resource friendly way

 

 
onewithzachy:

Hi ToolMaker,

Oh the Band.

Very simple, get the distant between middle band to lower band (or the distant between upper band to middle band - its the same value), then multiply it with your level and add it to middle band.

You still have to write those inputs in the EA though, we can't do it programatically.  

 

Looking at your suggestion now I see that you getting the distance between middle and lower and use this value for leveling, right? if so this is not really the right way because of its static value increment, I tested this by adding 3 bolingars with each 1 deviation appart to see if their distances are the same....my hunch was it would not because we working with calculated deviations:

2012.10.18 05:53:46 AngleTest (EURUSD,H1) Window=0,  index=2,  Name=BB Period(20),Dev(3),Shft(0),  handle=12 - MA(1.311466) Lower(1.308570271076223), Dif between MA Val and lower : -0.002895728923777208 Per unit of dev 1 : -0.0009652429745924026
2012.10.18 05:53:46 AngleTest (EURUSD,H1) Window=0,  index=1,  Name=BB Period(20),Dev(1),Shft(0),  handle=11 - MA(1.311466) Lower(1.310500757025408), Dif between MA Val and lower : -0.0009652429745923286 Per unit of dev 1 : -0.0004826214872961643
2012.10.18 05:53:46 AngleTest (EURUSD,H1) Window=0,  index=0,  Name=BB Period(20),Dev(2),Shft(0),  handle=10 - MA(1.311466) Lower(1.309535514050815), Dif between MA Val and lower : -0.001930485949184879 Per unit of dev 1 : -0.001930485949184879

 

the last section "Per unit of dev 1" should be equal to each other for your suggestion hold merrid ... below is the script used to test..mind the slugish ness:

However, I have got the option to calculate the deviation with this levels suggestion of yours which I'm certainly thinking about doing rather than creating multpile boll bands... it would make the life much easier for the back tester...

Thanks Zachy!

void OnStart()
  {
   int windows=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);
   //--- Check all windows
   for(int w=0;w<windows;w++)
     {
      //--- the number of indicators in this window/subwindow
      int total=ChartIndicatorsTotal(0,w);
      //--- Go through all indicators in the window
      double prevVal = 0;
      for(int i=0;i<total;i++)
        {
         //--- get the short name of an indicator
         string name=ChartIndicatorName(0,w,i);
         //--- get the handle of an indicator
         int handle=ChartIndicatorGet(0,w,name);
         //--- Add to log
         double value[];
         CopyBuffer(handle,2,0,1,value);
         double MAvalue[];
         CopyBuffer(handle,0,0,1,MAvalue);
         double diff=(value[0] - MAvalue[0]);
         double diff2= diff/(i+1);      //  this is to get the diffrence per unit of 1 deviation, since bol 1 dev = 1,bol 2 dev =2 and bol 3 dev 3

         printf("Window="+w+",  index="+i+",  Name="+name+",  handle="+handle+" - MA("+MAvalue[0]+") Lower("+value[0]+"), 
                Dif between MA Val and lower : "+diff+" Per unit of dev 1 : "+(diff2));
         
        }
     }
  }

 

 

 
ToolMaker:

Looking at your suggestion now I see that you getting the distance between middle and lower and use this value for leveling, right? if so this is not really the right way because of its static value increment, I tested this by adding 3 bolingars with each 1 deviation appart to see if their distances are the same....my hunch was it would not because we working with calculated deviations:

2012.10.18 05:53:46 AngleTest (EURUSD,H1) Window=0,  index=2,  Name=BB Period(20),Dev(3),Shft(0),  handle=12 - MA(1.311466) Lower(1.308570271076223), Dif between MA Val and lower : -0.002895728923777208 Per unit of dev 1 : -0.0009652429745924026
2012.10.18 05:53:46 AngleTest (EURUSD,H1) Window=0,  index=1,  Name=BB Period(20),Dev(1),Shft(0),  handle=11 - MA(1.311466) Lower(1.310500757025408), Dif between MA Val and lower : -0.0009652429745923286 Per unit of dev 1 : -0.0004826214872961643
2012.10.18 05:53:46 AngleTest (EURUSD,H1) Window=0,  index=0,  Name=BB Period(20),Dev(2),Shft(0),  handle=10 - MA(1.311466) Lower(1.309535514050815), Dif between MA Val and lower : -0.001930485949184879 Per unit of dev 1 : -0.001930485949184879

the last section "Per unit of dev 1" should be equal to each other for your suggestion hold merrid ... below is the script used to test..mind the slugish ness:

However, I have got the option to calculate the deviation with this levels suggestion of yours which I'm certainly thinking about doing rather than creating multpile boll bands... it would make the life much easier for the back tester...

Thanks Zachy!

Hi ToolMaker, 

Of course 3 BB with different deviation will have different distant to its middle band, I was suggesting with one single BB and your post was asking about level and level is not deviation.

In a BB with any deviation the distant from upper band to middle band is equal with the distant from middle band to lower band.

Upper band, lower band and its levels are calculated from middle band.

Upper band and lower band are calculated by standard deviation, while levels is calculated with the distant from upper band (or lower band) to middle band.

If you have 3 band with different input data (period, deviation) then you will have to separate calculate 3 of them. 

Try this :

1. Attach BB deviation 1 and level 2/-2 or whatever and attach another BB again same period but with deviation 2 (different color please), You will see that BB deviation 1 level 2/-2, (or whatever) is not the same with BB deviation 2 - except of course its middle band.

2.

Looking at your suggestion now I see that you getting the distance between middle and lower and use this value for leveling, right? if so this is not really the right way because of its static value increment,

Press your mouse middle button to activate chart cross-hair, calculate the distant from middle band to upper band, then calculate the distant from upper band to level 2, then from level 2 to level 3, and so on. You will see that the value is the same.

Level is not deviation.

 

 

Ah, I see ...

I just check this :

Level 2/-2 of BB deviation 1 is equal with upper/lower band of BB deviation 2 

Level 3/-3 of BB deviation 1 is equal with upper/lower band of BB deviation 3  

and so on

Level 4/-4 of BB deviation 1 is equal with level 2 BB deviation 2  

Level 6/-6 of BB deviation 1 is equal with level 3 BB deviation 2   

Level 8/-8 of BB deviation 1 is equal with level 4 BB deviation 2   

and so on

Thanks ToolMaker,

 

Reason: