#property copyright "Mod" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 DeepSkyBlue #property indicator_level1 0 //---- input parameters extern int barsToCount = 2000; //---- buffers double zscore[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(1); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,zscore); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit = barsToCount; //---- for(int i = 0 ;i <= limit-20 ;i++) { zscore[i] = (iClose(NULL,0,i)-iMA(NULL,0,60,0,0,0,i))/iStdDev(NULL,0,60,0,0,0,i); } //---- return(0); } //+--------------------------------------------
extern int barsToCount = 2000; : int limit = barsToCount; for(int i = 0 ;i <= limit-20 ;i++) /iStdDev(NULL,0,60,0,0,0,i);What happens if there are not 2000-20 bars on the chart?
WHRoeder:
What happens if there are not 2000-20 bars on the chart?
What happens if there are not 2000-20 bars on the chart?
thank you whroeder i change the bars to 1500 and its ok
thanks
Don't change it to 1500, what if there are only 100 like in the tester? Do it right. | int limit = MathMin(Bars, barsToCount); |
One possible solution is an if/else test where you test the item that might possibly give you a divide by zero error before you get to that division. Test to see if it is a zero first, if not, then do the test, but if it is, skip the test part.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register