Something interesting, old thread - page 52

 

Good morning Mladen,

I did try to add a BB with CCI price, but I have problem with the standard deviation.

//SMA

SimpleMAOnBuffer(rates_total, prev_calculated, period2+period3, period3, cciValue2, maValue2);

//BB

//--- variables

int pos;

//--- starting calculation

if(prev_calculated>1) pos=prev_calculated-1;

else pos=0;

//--- main cycle

for(int i=pos;i<rates_total && !IsStopped();i++)

{

//--- middle line

ExtMLBuffer=SimpleMAOnBuffer(rates_total, prev_calculated, period1+period2, period2, cciValue1, maValue1);

//--- calculate and write down StdDev

ExtStdDevBuffer=StdDev_Func(i,cciValue1,ExtMLBuffer,ExtBandsPeriod);

//--- upper line

ExtTLBuffer=ExtMLBuffer+ExtBandsDeviations*ExtStdDevBuffer;

//--- lower line

ExtBLBuffer=ExtMLBuffer-ExtBandsDeviations*ExtStdDevBuffer;

//---

}[/CODE]

what I like to have is the CCI line that cross the Bands (in this ex. the bottom line)

[CODE] if (cciValue1[0] < ExtBLBuffer[0]) {cci1 = " 0 "; cocci1 = Blue; ucci1 = 1; dcci1 = 0;}

else if (cciValue1[0] > ExtBLBuffer[0]) {cci1 = " 0 "; cocci1 = Red; ucci1 = 0; dcci1 = 1;}

It doesn't work, could you please take a look?

If I want add a second period for the BB I need to re-write all the cycle? Could you please let me show how simplify this?

Thank you

doc

Files:
mah_mod.mq5  11 kb
 
dr.house7:
Good morning Mladen,

I did try to add a BB with CCI price, but I have problem with the standard deviation.

//SMA

SimpleMAOnBuffer(rates_total, prev_calculated, period2+period3, period3, cciValue2, maValue2);

//BB

//--- variables

int pos;

//--- starting calculation

if(prev_calculated>1) pos=prev_calculated-1;

else pos=0;

//--- main cycle

for(int i=pos;i<rates_total && !IsStopped();i++)

{

//--- middle line

ExtMLBuffer=SimpleMAOnBuffer(rates_total, prev_calculated, period1+period2, period2, cciValue1, maValue1);

//--- calculate and write down StdDev

ExtStdDevBuffer=StdDev_Func(i,cciValue1,ExtMLBuffer,ExtBandsPeriod);

//--- upper line

ExtTLBuffer=ExtMLBuffer+ExtBandsDeviations*ExtStdDevBuffer;

//--- lower line

ExtBLBuffer=ExtMLBuffer-ExtBandsDeviations*ExtStdDevBuffer;

//---

}[/CODE]

what I like to have is the CCI line that cross the Bands (in this ex. the bottom line)

[CODE] if (cciValue1[0] < ExtBLBuffer[0]) {cci1 = " 0 "; cocci1 = Blue; ucci1 = 1; dcci1 = 0;}

else if (cciValue1[0] > ExtBLBuffer[0]) {cci1 = " 0 "; cocci1 = Red; ucci1 = 0; dcci1 = 1;}

It doesn't work, could you please take a look?

If I want add a second period for the BB I need to re-write all the cycle? Could you please let me show how simplify this? Thank you

doc

doc

Return from SimpleMAOnBuffer() function is not the ma value of the desired buffer, but the number of elements processed (in the case of that call, it is the rates_total). If you wish to calculate the ma value of a certain element "on-the-fly", you must do it with a function that does that differently (we already did that in a couple of occasions at this thread). That function is made to process the entire buffer at once

 

doc

Try out this version

Files:
mah_mod-1.mq5  11 kb
 
mladen:
you must do it with a function that does that differently (we already did that in a couple of occasions at this thread). That function is made to process the entire buffer at once

I was worried that you would tell me this There's no other way?

I need only a BB that works with CCI price

 
mladen:
doc Try out this version

Thanks Mladen,

I tried but seems there is a problem...if you insert 900 for period the signal is wrong, cause the color is blue but the cci is above the BLbuffer

 
dr.house7:
Thanks Mladen, I tried but seems there is a problem...if you insert 900 for period the signal is wrong, cause the color is blue but the cci is above the BLbuffer

doc

When in doubt always best to make all visible

Here is this version. Try it out and check the conditions

PS: you can not set those buffers as serries since the StdDev_Func does not work that way - it would work in a wrong dirrection then

Files:
mah_mod-2.mq5  11 kb
 
mladen:
doc

When in doubt always best to make all visible

Here is this version. Try it out and check the conditions

PS: you can not set those buffers as serries since the StdDev_Func does not work that way - it would work in a wrong dirrection then

Thank you!

I have a very complicated relationship with arrays

 
dr.house7:
Thank you! I have a very complicated relationship with arrays

That is probably the main problem of metatrader 5 : everything is much more complicated than in metatrader 4. So, instead of evolution (that the most efficient ways survive) we have some kind of inverted evolution : "the more complicated the better" logic. Probably it is why they are not able to get serious support (it is almost 5 years that metatrader 5 started and how many of us are using it in live trading?)

 
mladen:
That is probably the main problem of metatrader 5 : everything is much more complicated than in metatrader 4. So, instead of evolution (that the most efficient ways survive) we have some kind of inverted evolution : "the more complicated the better" logic. Probably it is why they are not able to get serious support (it is almost 5 years that metatrader 5 started and how many of us are using it in live trading?)

They started "developing" it more than 6 years ago (according to metatrader). Here is a post they posted here on TSD where it is obvious when did they start the whole thing : https://www.mql5.com/en/forum/general

 
mladen:
That is probably the main problem of metatrader 5 : everything is much more complicated than in metatrader 4. So, instead of evolution (that the most efficient ways survive) we have some kind of inverted evolution : "the more complicated the better" logic. Probably it is why they are not able to get serious support (it is almost 5 years that metatrader 5 started and how many of us are using it in live trading?)

:):)

I like to study this language because I approached a little to c++, in a way that I can understand immediately.

For me mt5 is a very nice tool to use it, I like the way I can manually trade and change everything directly on the chart...but the BIGGEST problem (the reason why mt5 is a big failure) is the no hedge possibility

Reason: