using iOpen in an indicator?
excuse me, I not say that I copy above code > add ";" > compile > run > it plot OK and NOT flat anywhere...
Counted_bars=IndicatorCounted(); // Number of counted bars
Comment("Bars to process = ", Bars-Counted_bars-1-LookBack); // add this line
if(Bars-Counted_bars-1-LookBack < 0) Alert("This isn't processing anything"); // add this line
for(i=Bars-Counted_bars-1-LookBack;i>=0;i--) // Index of the first uncounted
{
Counted_bars=IndicatorCounted(); // Number of counted bars
Comment("Bars to process = ", Bars-Counted_bars-1-LookBack); // add this line
if(Bars-Counted_bars-1-LookBack < 0) Alert("This isn't processing anything"); // add this line
for(i=Bars-Counted_bars-1-LookBack;i>=0;i--) // Index of the first uncounted
{
OK.
Changed it to the following:
CountedBars=IndicatorCounted(); // Number of counted bars Print("Bars to process = ",CountedBars-1); if(CountedBars-LookBack-1 < 0) Alert("This isn't processing anything"); for(i=CountedBars-LookBack-1;i>=0;i--) // Index of the first uncounted
The lines move up and down now. But they are still totally flat. The seem to move based on the most recent calculation of:
iClose("EURUSD",PERIOD_M1,i)-iOpen("EURUSD",PERIOD_M1,i+LookBack)
in other words:
iClose("EURUSD",PERIOD_M1,0)-iOpen("EURUSD",PERIOD_M1,59)
For example, right now the value=0.0073, and the line equals 0.0073 for the whole chart, no matter how far back I scroll.
Well...
#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Yellow extern int LookBack=60; double USD[]; int init() { SetIndexBuffer(0,USD); SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1); return(0); } int start() { for(int i = Bars-IndicatorCounted(); i >= 0; i--) { USD[i]=iClose(Symbol(),PERIOD_M1,i)-iOpen(Symbol(),PERIOD_M1,i+LookBack); } return(0); }
Well...
thanks, Phy
This indicator is supposed to show the open and close of the EURUSD in absolute value over the last hour. When it is run it just draws a flat line, which should never be the case. Anybody know where I went wrong?