- 0796214726: Please how can I fix the following errors in the below code?
Learn to code.
-
first=begin+MAPeriod-1; } } if else {
What does that bracket close? - Does an “if else” exist? Do you mean else?
1//+------------------------------------------------------------------+ 2//| First Indicator.mq5 | 3//| Kamau Muchiri | 4//| https://www.mql5.com | 5//+------------------------------------------------------------------+ 6#property copyright "Kamau Muchiri" 7#property link "https://www.mql5.com" 8#property version "1.00" 9#property indicator_chart_window 10#property indicator_buffers 1 11#property indicator_plots 1 12//--- plot Ind_value 13#property indicator_label1 "Ind_value" 14#property indicator_type1 DRAW_LINE 15#property indicator_color1 clrRed 16#property indicator_style1 STYLE_SOLID 17#property indicator_width1 1 18//--- input parameters 19input int MAPeriod=15;//Average Period 20input int MAShift=0;//Horizontal shift in bars 21//--- indicator buffers 22double Ind_valuesBuffer[]; 23//+------------------------------------------------------------------+ 24//| Custom indicator initialization function | 25//+------------------------------------------------------------------+ 26int OnInit() 27 { 28//--- indicator buffers mapping 29 SetIndexBuffer(0,Ind_valuesBuffer,INDICATOR_DATA); 30 PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,MAPeriod); 31 32//--- 33 return(INIT_SUCCEEDED); 34 } 35//+------------------------------------------------------------------+ 36//| Custom indicator iteration function | 37//+------------------------------------------------------------------+ 38 39/+------------------------------------------------------------------+ 40//| | 41/+------------------------------------------------------------------+ 42int OnCalculate(const int rates_total, 43 const int prev_calculated, 44 const int begin, 45 const double &price[]) 46 { 47//--- 48 49//--- return value of prev_calculated for next call 50 if(rates_total<begin+MAPeriod-1) 51 return (0); 52 } 53 54 55 if previous_calculated=0; 56 { 57 first=begin+MAPeriod-1; 58 } 59 } 60if else 61 { 62 { 63 first=prev_calculated-1; 64 } 65 for(bar=first; bar<rates_total; bar++) 66 { 67 Sum=0.0; 68 for(iii=0; iii<MAPeriod; iii++) 69 { 70 Sum=Sum+price[bar-iii]; 71 } 72 SMA=Sum/MAPeriod; 73 ind_valuesBuffer[bar]=SMA; 74 } 75 Alert(...) 76 } 78//+------------------------------------------------------------------+
Hi there ?I am thankful! Only 2 errors remaining. Please how should I fix them?
Line Error
Line 52: '}'- not all control paths return a value
Line 55: 'if' -expressions are not allowed on a global scope

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
Please how can I fix the following errors in the below code?
1.'if' expressions are not allowed on a global scope.
2.'}'expressions are not allowed on a global scope.
3.'if'open parentheses expected.
4.'first'-undeclared identifier
5.'}'-not all control paths return a value.