A non-typical iCustom problem - page 2

 
MrH wrote >>

I understand, you only use the indicator, no EA. You talked about the iCustom function that's why I thought you were using an EA.

Just check if your indicator works with the data form the last closed H4 bar ONLY and not the current data it may explain why you do not have the stairs design.

In your indicator you may be using, for every data you use from the market, marketInfo() from the closing time of the last H4 bar, is it the case? if not, that may lead to your current result.

 

here is what you have to do: replace i with iBarShift

ExtMapBuffer1[i]=iCustom(NULL,PERIOD_M15,"reference",0, iBarShift(NULL,PERIOD_M15,Time[i]);

and the same for all other timefrmaes. That will set shift to correct value for that timeframe

 
irusoh1:

here is what you have to do: replace i with iBarShift

ExtMapBuffer1[i]=iCustom(NULL,PERIOD_M15,"reference",0, iBarShift(NULL,PERIOD_M15,Time[i]);

and the same for all other timefrmaes. That will set shift to correct value for that timeframe

If you add another ) before the ; you don't get errors: ExtMapBuffer1[i]=iCustom(NULL,PERIOD_M15,"reference",0, iBarShift(NULL,PERIOD_M15,Time[i]));

Thank you both for taking the time to answer me, great work!

 

Ok now there is a problem with live charting:

the buffers don't update: I get a kind of dotted line

Any last help would be much appreciated:



 

I don't understand?

If you want to plot an average you only need one buffer for that average.

There is mo need for 5 buffers. iCustom calcualations can go into ordinary double and average shoud go into a buffer that will be plotted.

 
irusoh1:

I don't understand?

If you want to plot an average you only need one buffer for that average.

There is mo need for 5 buffers. iCustom calcualations can go into ordinary double and average shoud go into a buffer that will be plotted.

Apparently my code does not update correctly (only when I change timeframes on the chart with the same indicator attached): after a while it give me the dotted line...

Could it be something to do with the iBarShift?


#property indicator_level1 0.9

#property indicator_level2 -0.9

#property indicator_levelcolor Black

#property indicator_levelwidth 2

#property indicator_levelstyle STYLE_SOLID


#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 DarkBlue

//---- input parameters

int barsToProcess=10000;

//---- buffers

double ExtMapBuffer1[];


//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

//---- indicators

   SetIndexStyle(0,DRAW_LINE,0,1);

   SetIndexBuffer(0,ExtMapBuffer1);

//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

int deinit()

  {

//----

//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int start()

{

   int counted_bars=IndicatorCounted(),

       limit;

   if(counted_bars>0)

      counted_bars--;

   limit=Bars-counted_bars;

   if(limit>barsToProcess)

      limit=barsToProcess;

   for(int i=0;i<limit;i++)

   {

      ExtMapBuffer1[i]=iCustom(NULL,PERIOD_M1,"reference",0,iBarShift(NULL,PERIOD_M1,Time[i]));

   }

   return(0);

}

 

if you are using preiod_m1 you can't use line plot. You need to use histogram. His

togram will show you spread of M1 points over the same bar in a vertical manner.

Look at my ftf ma indicator where timeframe is small.

//--- init function 
case TF_SMALL:
{
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
break;
}



void SetSmallTF(int shift)
{
int smallshift=iBarShift(NULL,tf,Time[shift]);
datetime cuttime=Time[shift]+Period()*60-1;
double highma=0;
double lowma=9999999;
int check=0;
while(iTime(NULL,tf,smallshift)<cuttime&&smallshift>=0)
{
double ma=iMA(NULL,tf,maperiod,mashift,mamethod,maprice,smallshift);
if(ma>highma)
highma=ma;
if(ma<lowma)
lowma=ma;
smallshift--;
check++;
if(check>1000)
{
Print("infinite loop in SetSmallTF");
break;
}
}
mainbuf[shift]=highma;
extrabuf[shift]=lowma;
}
Reason: