Something interesting, old thread - page 53

 

Here is an indicator based on Bill Williams: Market facilitation index (MFI)...but this one is better, improved version.

This indicator is based on HLC and compare current bar's volume and spread to previous bar volume and spread. Many pro traders consider closing price more important to opening price. Description of symbols in price window is same as for MFI.

Files:
 
mladen:
Interesting idea from rone : a universal oscillator. Will nor describe what can it do since all is visible from parameters choices

Hi mladen, do you have the mq4 version of the Universal Oscillator?

Thanks!

 

Dear Mladen,

I'm coding and searching a solution for my problem...on the "mah-mod2" indicator we have this BB calculation:

//--- 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;

//---

}

the problem is that in this case the buffer's count is [ratestotal-1], instead of what I need is [0].

So what I suppose to do? Replace this cycle with a void object after rates_total?

Thanks

 
dr.house7:
Dear Mladen,

I'm coding and searching a solution for my problem...on the "mah-mod2" indicator we have this BB calculation:

//--- 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;

//---

}

the problem is that in this case the buffer's count is [ratestotal-1], instead of what I need is [0].

So what I suppose to do? Replace this cycle with a void object after rates_total?

Thanks

Doc

If the array (buffer) is set as series then the current element is 0. If it is not set as series the current element is rates_total-1. Just try thinking "inverted" compared to metatrader 4 way of using buffers and then you will think the "pure C/C++" way. Nothing else has to be changed - just the way how the array is looked at

 
mladen:
Doc If the array (buffer) is set as series then the current element is 0. If it is not set as series the current element is rates_total-1. Just try thinking "inverted" compared to metatrader 4 way of using buffers and then you will think the "pure C/C++" way. Nothing else has to be changed - just the way how the array is looked at

so I need to make something like this for my buffers?

ArrayInitialize(Ma1, 0);

ArraySetAsSeries(Ma1, true);

ArrayResize(Ma1, 2, 1);

if(CopyBuffer(handle_Ma1, 0, 0, 2, Ma1) < 0)

return(0);
 
dr.house7:
so I need to make something like this for my buffers?
ArrayInitialize(Ma1, 0);

ArraySetAsSeries(Ma1, true);

ArrayResize(Ma1, 2, 1);

if(CopyBuffer(handle_Ma1, 0, 0, 2, Ma1) < 0)

return(0);

Doc

Yes. If you set the buffer as series (the ArraySetAsSeries(Ma1,true); part) then 0th element is the current bar (as we are used to in metatrader 4)

 
mladen:
Doc Yes. If you set the buffer as series (the ArraySetAsSeries(Ma1,true); part) then 0th element is the current bar (as we are used to in metatrader 4)

ok

I hope not to mess things up, but otherwise I'll never learn something

Thanks

 
mladen:
Doc Yes. If you set the buffer as series (the ArraySetAsSeries(Ma1,true); part) then 0th element is the current bar (as we are used to in metatrader 4)

Mladen,

I have a doubt...I call the MA like this

maValue1 = SimpleMA(i,period1,cciValue1);

so it's not an handle, how could I use the "ArraySetAsSeries" function? I need to keep the price of CCI, that's my weak point

 
dr.house7:
Mladen,

I have a doubt...I call the MA like this

maValue1 = SimpleMA(i,period1,cciValue1);
so it's not an handle, how could I use the "ArraySetAsSeries" function? I need to keep the price of CCI, that's my weak point

Doc

For SimpleMA function it must not be set as series

This is how it looks like :

double SimpleMA(const int position,const int period,const double &price[])

{

//---

double result=0.0;

//--- check position

if(position>=period-1 && period>0)

{

//--- calculate value

for(int i=0;i<period;i++) result+=price[position-i]; // position-i means that the array is NOT set as series

result/=period;

}

//---

return(result);

}

See the marked part in that code.

It means that the "price" array must not be set as series or you will get false results. Because of things like these I told in more than one ocasion that it is best to write your own functions since the ones we are privided with do not honor any standard way of call and it is very easy to get lost in what and how something they threw together works

 
mladen:
Because of things like these I told in more than one ocasion that it is best to write your own functions since the ones we are privided with do not honor any standard way of call and it is very easy to get lost in what and how something they threw together works

if I were as good as you, I would love to do this

So this is a big problem for me, cause I need to use the MA array in the calculation

if (cciValue2[0] > maValue2[0]) {cci2 = " 0 "; cocci2 = Blue; ucci2 = 1; dcci2 = 0;}
Reason: