Inverse Fisher transform codings HELP!!

 

Hi, I have been coding Inverse Fisher transform but it is still lacking some professional touch.

It works if it is compiled "after" attaching to a chart. Re-opening the chart will not work either. I'd appreciate any help.

thanks

Leo

#property copyright "Copyright Š 2010, MP"
#property link "https://www.metaquotes.net//"

//----
#property indicator_separate_window
#property indicator_buffers 1 // number of indicators to plot
#property indicator_color1 DarkGreen

//---- input parameters
extern int IFFPeriod = 5;
extern int smooth = 9;

//---- buffers

double Value1,Value2,Value3[],Value4,Value5; //Value3 is just needed for calculation

double IFS[]; // to plot


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2); // Total buffers needed to calculate

IndicatorDigits(2); // number of decimals to show
IndicatorShortName("IFCycle"); // for window display name

SetLevelStyle(STYLE_DOT,1,DeepSkyBlue);
SetLevelValue(0,0.50);
SetLevelValue(1,-0.50);


SetIndexBuffer(0,IFS);
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,2);
SetIndexDrawBegin(0,IFS);
SetIndexLabel (0,"IFS");

// additional buffers required for computation

SetIndexBuffer (1, Value3);



return(0);
}
//-------------END OF init()-----------

int deinit()
{
return(0);
}


int start()
{

int i, 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-IndicatorCounted();
//---- main loop

for(i=0; i<limit; i++)
{
Value1= iRSI(NULL,0,IFFPeriod,PRICE_CLOSE, i);
Value2 = 0.1* (Value1-50);
Value3[i] = Value2 ;



Value4 = iMAOnArray(Value3,Bars,smooth,0,MODE_LWMA,i);

Value5=(MathExp(2*Value4)-1)/(MathExp(2*Value4)+1);


IFS[i] = Value5;
}





return(0);

}

Files:
 

you have a problem with the imaOnArray.. i had the same problem when using this or similar onArray functions. never solved it. since them i use the onArray functions only in EA's

some workaround would be:

change :

 iMAOnArray(Value3,Bars,smooth,0,MODE_LWMA,i);

to

 iMAOnArray(Value3,Bars,smooth,i,MODE_LWMA,0);

but then the processing time increases a lot.

//z

 

thanks, but it still doesn't solve the problem. Indicator's still not calculating unless it is compiled again after attaching to the chart.

 

There are others much more qualified than I am to answer this question, so I offer only a few observations, no solution...

init()

//   SetIndexDrawBegin(0,IFS);  //I think this line should be replaced with the next...
   SetIndexDrawBegin(0,smooth);  



start()

    int i, 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-IndicatorCounted();// I think this line should be replaced with the next...
     limit=Bars-counted_bars;
  //---- main loop

//   for(i=0; i<limit; i++)                   
//   {

// I think the above should be replaced with the following...
   i = Bars - counted_bars - 1;
   while(i>=0)
      {
 

After I had a closer look at the Inverse Fisher Transform I wonder what its value is?

All it does is exaggerate the RSI or Cycles as in the paper, or any other oscillator you wish to exaggerate.

But why should you want to? I prefer to see whether RSI is 79 or 81, rather than have those values equalized to 1.

Maybe I am not seeing what you see. What am I missing?

 

thank you guys. I've sorted it out. Below is what I have replaced and it works.

int start()
{
int counted_bars=IndicatorCounted();
//----

int limit,i;

limit = Bars - counted_bars + 1;

for (i = limit; i>=0; i--)

 

Hi

engcomp:

After I had a closer look at the Inverse Fisher Transform I wonder what its value is?

All it does is exaggerate the RSI or Cycles as in the paper, or any other oscillator you wish to exaggerate.

But why should you want to? I prefer to see whether RSI is 79 or 81, rather than have those values equalized to 1.

Maybe I am not seeing what you see. What am I missing?


Hi engcomp

I find it much simpler to use. RSI works fine, too. It's just a variation.

 
#property indicator_separate_window
#property indicator_buffers 1 // number of indicators to plot
#property indicator_color1 DarkGreen 

extern int IFFPeriod = 5;
extern int smooth = 9;

double IFS[],MaRSIf[], RSIf[]; 

int init()
{
 IndicatorBuffers(3); 
 IndicatorDigits(2); 
 IndicatorShortName("IFCycle"); 

 SetLevelStyle(STYLE_DOT,1,DeepSkyBlue);
 SetLevelValue(0,0.50);
 SetLevelValue(1,-0.50);

 SetIndexBuffer(0,IFS);
 SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,2);
 SetIndexDrawBegin(0,IFS); 
 SetIndexLabel (0,"IFS");

 SetIndexBuffer(1, MaRSIf);
 SetIndexBuffer(2, RSIf); ArraySetAsSeries(RSIf, true);
 return(0);
}

int start()
{
 int i, limit ;
 int counted_bars=IndicatorCounted();
 if(counted_bars<0) return(-1);
 if(counted_bars>0) counted_bars--;
 limit=Bars-1-counted_bars;

 for(i=limit; i>=0; i--) 
 {
   RSIf[i]   = 0.1*(iRSI(NULL,0,IFFPeriod,PRICE_CLOSE, i)-50);
   MaRSIf[i] = iMAOnArray(RSIf,0,smooth,0,MODE_LWMA,i);
   IFS[i]    = (MathExp(2*MaRSIf[i])-1)/(MathExp(2*MaRSIf[i])+1);
 }
 return(0);
}
Leo, Your code needs some efficiency. I think this one will work fine (not tested). Good luck.
 
cameofx:
Leo, Your code needs some efficiency. I think this one will work fine (not tested). Good luck.


It doesn't work. The bug lies with bar counting technique. It works with the following technique.

What is the difference? Many thanks.. it works now.

//-------------------------------

int start()
{

int counted_bars=IndicatorCounted();
//----

int limit,i;

limit = Bars - counted_bars + 1;

for (i = limit; i>=0; i--)

 
for(i=0; i<limit; i++) {
Value1= iRSI(NULL,0,IFFPeriod,PRICE_CLOSE, i);
...
Value4 = iMAOnArray(Value3,Bars,smooth,0,MODE_LWMA,i);

Can't do a iMAOnArray(Value3, ..., i) until Value3[i+1]... have been set.

Count DOWN

 
Leo33:


It doesn't work. The bug lies with bar counting technique. It works with the following technique.

What is the difference? Many thanks.. it works now.

//-------------------------------

int start()
{

int counted_bars=IndicatorCounted();
//----

int limit,i;

limit = Bars - counted_bars + 1;

for (i = limit; i>=0; i--)

I think the reason for counting down instead of up is that indicator buffers are filled from left to right and index values increment from right to left.
Reason: