Code from signal indicator
input int STSssp =9; //SSP input int STSrisk =3; //Risk input E_BAR STSbar =BAR_CLOSED; //Signal Bar sinput color STScolorB =clrLimeGreen; //Color Buy sinput color STScolorS =clrOrangeRed; //Color Sell sinput uint STSwidth =2; //Width //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double Buy[],Sell[]; double Trend[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { Comment(""); if(!LicenseValidation()) return(INIT_FAILED); int cnt=0; SetIndexBuffer(cnt,Buy,INDICATOR_DATA); ArraySetAsSeries(Buy,true); cnt++; SetIndexBuffer(cnt,Sell,INDICATOR_DATA); ArraySetAsSeries(Sell,true); cnt++; SetIndexBuffer(cnt,Trend,INDICATOR_DATA); ArraySetAsSeries(Trend,true); cnt=0; PlotIndexSetString(cnt,PLOT_LABEL,"Buy"); PlotIndexSetDouble(cnt,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetInteger(cnt,PLOT_DRAW_TYPE,(STScolorB==clrNONE) ?DRAW_NONE :DRAW_ARROW); PlotIndexSetInteger(cnt,PLOT_LINE_COLOR,STScolorB); PlotIndexSetInteger(cnt,PLOT_LINE_WIDTH,STSwidth); PlotIndexSetInteger(cnt,PLOT_ARROW,108); cnt++; PlotIndexSetString(cnt,PLOT_LABEL,"Sell"); PlotIndexSetDouble(cnt,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetInteger(cnt,PLOT_DRAW_TYPE,(STScolorS==clrNONE) ?DRAW_NONE :DRAW_ARROW); PlotIndexSetInteger(cnt,PLOT_LINE_COLOR,STScolorS); PlotIndexSetInteger(cnt,PLOT_LINE_WIDTH,STSwidth); PlotIndexSetInteger(cnt,PLOT_ARROW,108); IndicatorSetInteger(INDICATOR_DIGITS,Digits()); IndicatorSetString(INDICATOR_SHORTNAME,MQLInfoString(MQL_PROGRAM_NAME)+" ("+IntegerToString(STSssp)+"; "+IntegerToString(STSrisk)+")"); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); ArraySetAsSeries(close,true); static int k; int limit=rates_total-prev_calculated; if(prev_calculated==0) { for(int i=0; i<rates_total; i++) { Buy[i]=EMPTY_VALUE; Sell[i]=EMPTY_VALUE; Trend[i]=WRONG_VALUE; } k=33-STSrisk; limit=(rates_total-1)-k; } for(int i=limit; i>=STSbar; i--) { double rang=AvgRange(i,STSssp,high,low); double max=low[i]; double min=close[i]; GetMaxMin(i,STSssp,max,min,high,low); double smin=min+(max-min)*k/100; double smax=max-(max-min)*k/100; Trend[i]=(close[i]>smax) ?0.0 :((close[i]<smin) ?1.0 :Trend[i+1]); Buy[i]=(Trend[i]==0.0 && Trend[i+1]!=0.0) ?(low[i]-rang*0.5) :EMPTY_VALUE; Sell[i]=(Trend[i]==1.0 && Trend[i+1]!=1.0) ?(high[i]+rang*0.5) :EMPTY_VALUE; } return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void GetMaxMin(const int vStart,const int vCnt,double &vMax,double &vMin,const double &vHi[],const double &vLo[]) { double res=NULL; for(int i=0; i<vCnt; i++) { res=vHi[vStart+i]; if(vMax<res) vMax=res; res=vLo[vStart+i]; if(vMin>=res) vMin=res; } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double AvgRange(const int vStart,const int vCnt,const double &vHi[],const double &vLo[]) { double avg=NULL; for(int i=0; i<=vCnt; i++) avg+=(vHi[vStart+i]-vLo[vStart+i]); return(avg/(vCnt+1)); }
I discovered it is the SSP and RISK parameter of the SilverTrend flag. If I optimize with values above 15 it locks up, it uses a lot of memory. I know it uses to calculate and should store in an array. Does anyone know how to fix it?
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