Indicators: Didi Index - page 3

 
collisr350 #:
this indicator is great, EXCPEPT  it does not function correctly in real time. It doesnt react right for giving real time signal.
It is working fine in real time with me. What problem are you facing?
 

Some things are Bad.

If I use original SMA03 + SMA20 the crossess are diferent from this indicator.
Are there some secret algo???
There are not used the calculation buffers. I do not know ..

 
Petr Michalica #:

Some things are Bad.

If I use original SMA03 + SMA20 the crossess are diferent from this indicator.
Are there some secret algo???
There are not used the calculation buffers. I do not know ..

It is published source code--not a secret.

Here's the calculation:

   short_handle   = iMA(Symbol(), Timeframe, FastPeriod, Shift, Method, AppliedPrice);
   average_handle = iMA(Symbol(), Timeframe, MeanPeriod, Shift, Method, AppliedPrice);
   long_handle    = iMA(Symbol(), Timeframe, SlowPeriod, Shift, Method, AppliedPrice);

// and then...

   void CalculateDidiIndex(const int shift=0)
  {
//---
   double fast[1],mean[1],slow[1];

   if(CopyBuffer(short_handle, 0, shift, 1, fast)<=0) return;
   if(CopyBuffer(average_handle, 0, shift, 1, mean)<=0) return;
   if(CopyBuffer(long_handle, 0, shift, 1, slow)<=0) return;

   FastBuffer[shift] = fast[0]/mean[0];
   MeanBuffer[shift] = 1;
   SlowBuffer[shift] = slow[0]/mean[0];
//---
  }
 

Yes I read the source,

But the problem is the diferncy.
The croses of original sma03+sma20 are not on the same place.

 
Petr Michalica #:
sma03+sma20

You're omitting the average_handle which is controlled by the input:

input int                MeanPeriod   =8;               // Mean MA Period
 

AHA.
OK. Yes, all is right.
I am sorry for this. 
Measure quality is  easier. Nice.
I thinkd the mean is 20. I know, thera are 3smas.

 
Matheus de Oliveira #:
Do you think there would be a problem to remove the lines and do the fix?

There should be no problem. Occasionally people write code for their specific symbol/instrument is all.

This digits code is pretty standard in indicators with nothing more:

IndicatorSetInteger(INDICATOR_DIGITS, _Digits);

You could delete the function altogether and the indicator would still work, but it would always default to displaying 6 digits.

 
trade_addicted #:
[W]here can I read the SlowBuffer values

See the buffer declarations:

   SetIndexBuffer(0,FastBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,MeanBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,SlowBuffer,INDICATOR_DATA);

You've already found the fast buffer #0. Similarly, the slow buffer is buffer #2.

Personally, the mean buffer #1 which is assigned a static value of 1 leaves me scratching my head. It would be easier and cleaner to just use the integer... 1.🤔
 
Ryan L Johnson #Personally, the mean buffer #1 which is assigned a static value of 1 leaves me scratching my head. It would be easier and cleaner to just use the integer... 1.🤔

You're right to be puzzled by the mean buffer. In this implementation it's always assigned a static value of 1 (MeanBuffer[shift] = 1), so it never changes across bars.

That means the buffer itself is redundant: you don't actually need to store or expose it through SetIndexBuffer.

The indicator could simply use the literal constant 1 directly in the calculation of the other two series, and that would make the code shorter, clearer, and use less memory. The Fast and Slow buffers are the only ones that carry real data.

 
Yes. It is good  to have  high precision.