This is my Spread indicator. Can someone tell me why time[3000] is out of range when #property strict is used and how to fix it without removing #property strict
I think the Bars in your chart is less than 3000, you must use this :
//+------------------------------------------------------------------+ //| Show Spread | //+-----------------------------------------------------------Ndumiso+ void spreadraw() { if ( Bars < 3000 ) return; Comment("");ObjectDelete("Set1");ObjectDelete("Set2");ObjectDelete("Set3"); double time=0; double colour; double Bidd=MarketInfo(Symbol(),MODE_BID ); double Askk=MarketInfo(Symbol(),MODE_ASK ); double Sprea=MarketInfo(Symbol(),MODE_SPREAD); if(Spread<=MaxSpread)colour=clrLimeGreen; else colour=clrRed; if(Period()==1)time=60; if(Period()==5)time=300; if(Period()==15)time=900; if(Period()==30)time=1800; if(Period()==60)time=3600; if(Period()==240)time=14400; if(Period()==1440)time=86400; if(Period()==10080)time=604800; if(Period()==43200)time=2592000; ObjectCreate("Set1",OBJ_RECTANGLE,0,Time[3000]+(int)time/2,Bidd,TimeCurrent()+(int)time*5,Askk); //Error is here? ObjectSet("Set1",OBJPROP_COLOR,colour); ObjectCreate("Set2",OBJ_RECTANGLE,0,TimeCurrent()+(int)time*5,Bidd,TimeCurrent()+(int)time*1000,Askk); ObjectSet("Set2",OBJPROP_COLOR,colour); ObjectCreate("Set3",OBJ_TEXT,0,TimeCurrent()+(int)time*10,(4*Ask+Bidd)/5); ObjectSetText("Set3",DoubleToStr(Sprea/10,1),8,"Lucida console",White); }
Because in your code, time is not an array, but you are trying to access it as an array.
I think the Bars in your chart is less than 3000, you must use this :
You must check your history data, I have no problem using this script because my Bars = 7600, you can try this script and see what's the result:
Print( "Bar = ",Bars);
Ok I got it thank you for your opinions.
Seems like Time can not or not allowed to access 3000 bars, I do not need it to anyway so I reduce it to Time[300].
You must check your history data, I have no problem using this script because my Bars = 7600, you can try this script and see what's the result:
He isn't use time as an array, he use Time as an array.
Yes, good point! I guess I needed to have my coffee first ;-)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is my Spread indicator. Can someone tell me why time[3000] is out of range when #property strict is used and how to fix it without removing #property strict