[Help] My force index formula didn't match MQL Force Index Indicator line

 

[Help] My force index formula didn't match MQL Force Index Indicator line

I tried to experimented many indicators formula but when I created force index without using iForce function the indicator line is not same as the original MQL Force Index indicator.

   int limit;
   int counted_bars=IndicatorCounted();
  //---- check for possible errors
   if(counted_bars<0) return(-1);
  //---- the last counted bar will be recounted
      
   if(counted_bars>0) counted_bars--;
     
   limit=Bars-counted_bars;
     
  //---- main loop
   for(int i=0; i<limit; i++)
   {
      
      double now_close = iMA(Symbol(), Period(), 9, 0, MODE_SMA, PRICE_CLOSE, i);
      double prev_close = iMA(Symbol(), Period(), 9, 0, MODE_SMA, PRICE_CLOSE, i-1);
      
      double now_vol = iVolume(Symbol(), Period(), i);
      //double now_vol = Volume[i];
      
      double res = (now_close - prev_close) * now_vol;
      USD_Buffer[i] = res;

FI

You see in above screenshot that my force index line is reverse.

 
Musngi:

[Help] My force index formula didn't match MQL Force Index Indicator line

I tried to experimented many indicators formula but when I created force index without using iForce function the indicator line is not same as the original MQL Force Index indicator.

You see in above screenshot that my force index line is reverse.

From the documentation:

Timeseries are arrays with reverse indexing, i.e. the first element of a timeseries is in the extreme right position, and the last element is in the extreme left position. Timeseries being used for storing history price data and contain the time information, we can say that the newest data are placed in the extreme right position of the timeseries, while the oldest data are in the extreme left position.

Thus, your prev_close should be calculated on i+1.

 
Anthony Garot:

From the documentation:

Timeseries are arrays with reverse indexing, i.e. the first element of a timeseries is in the extreme right position, and the last element is in the extreme left position. Timeseries being used for storing history price data and contain the time information, we can say that the newest data are placed in the extreme right position of the timeseries, while the oldest data are in the extreme left position.

Thus, your prev_close should be calculated on i+1.


Thanks.. its work now.

Reason: