interesting...
tradelife:
interesting...
Can I consider you as a participant ?
interesting...
I participated in this contest
I'm in... if I have the time.
angevoyageur:
Can I consider you as a participant ?
Yes, of course.
Can I consider you as a participant ?
So we have 3 participants for now.
Soon the contest will begin, I hope participants are present.

So you can find the buggy code attached. This is an indicator where I introduced some bugs myself, below you can find the result you have to obtain when attached to a chart.
Please respect the rules and don't try to find the original code on Internet.
When you think you have the expected result, please post me the code by pm.
Files:
Contest1.mq5
6 kb
We get 1 winner, which is not even listed as participant.
The winner is Tjipke de Vries (deVries)
Congratulations !
He found the 3 bugs I introduced, and even a little more, good work !
Here his code, with the bugs and correction highlighted in yellow and the original code can be found here.
#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_type1 DRAW_ARROW #property indicator_color1 Red #property indicator_width1 4 #property indicator_label1 "Sell" #property indicator_type2 DRAW_ARROW #property indicator_color2 Lime #property indicator_width2 4 #property indicator_label2 "Buy" //+----------------------------------------------+ //| Indicator input parameters | //+----------------------------------------------+ input int RISK=3; input int NumberofAlerts=2; double SellBuffer[]; double BuyBuffer[]; int K,SSP=9; int counter=0; bool old,uptrend_; int StartBars; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- initialization of variables of the start of data calculation StartBars=SSP+1; //---- set dynamic array as an indicator buffer SetIndexBuffer(0,SellBuffer,INDICATOR_DATA); //---- shifting the start of drawing of the indicator 1 PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartBars); //---- create a label to display in DataWindow PlotIndexSetString(0,PLOT_LABEL,"Sell"); //---- indicator symbol PlotIndexSetInteger(0,PLOT_ARROW,108); //---- indexing elements in the buffer as time series ArraySetAsSeries(SellBuffer,true); //---- setting the indicator values that won't be visible on a chart PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); //---- set dynamic array as an indicator buffer SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA); //---- shifting the start of drawing of the indicator 2 PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,StartBars); //---- create a label to display in DataWindow PlotIndexSetString(1,PLOT_LABEL,"Buy"); //---- indicator symbol PlotIndexSetInteger(1,PLOT_ARROW,108); //---- indexing elements in the buffer as time series ArraySetAsSeries(BuyBuffer,true); //---- setting the indicator values that won't be visible on a chart PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0); //---- Setting the format of accuracy of displaying the indicator IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //---- name for the data window and for the label of sub-windows string short_name="Trend_Signal"; IndicatorSetString(INDICATOR_SHORTNAME,short_name); //---- } //+------------------------------------------------------------------+ //| 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[]) { //---- checking the number of bars to be enough for the calculation if(rates_total<StartBars) return(0); //---- declarations of local variables int limit; double Range,AvgRange,smin,smax,SsMax,SsMin,price; bool uptrend; //---- calculations of the necessary amount of data to be copied //---- and the 'limit' starting index for the bars recalculation loop if(prev_calculated>rates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { K=33-RISK; limit=rates_total-StartBars; // starting index for calculation of all bars } else { limit=rates_total-prev_calculated; // starting index for calculation of new bars } ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); ArraySetAsSeries(close,true); //---- restore values of the variables uptrend=uptrend_; //---- main indicator calculation loop for(int bar=limit; bar>=0; bar--) { //---- save values of the variables before running at the current bar if(rates_total!=prev_calculated && bar==0) { uptrend_=uptrend; } Range=0; AvgRange=0; for(int iii=bar; iii<=bar+SSP; iii++) AvgRange=AvgRange+MathAbs(high[iii]-low[iii]); //AvgRange+=AvgRange+MathAbs(high[iii]-low[iii]); Range=AvgRange/(SSP+1); //---- SsMax=low[bar]; SsMin=close[bar]; for(int kkk=bar; kkk<=bar+SSP-1; kkk++) { price=high[kkk]; if(SsMax<price) SsMax=price; price=low[kkk]; if(SsMin>=price) SsMin=price; } smin=SsMin+(SsMax-SsMin)*K/100; smax=SsMax-(SsMax-SsMin)*K/100; SellBuffer[bar]=0; BuyBuffer[bar]=0; if(close[bar]<smin) uptrend=false; if(close[bar]>smax) uptrend=true; if(uptrend!=old && uptrend==true) { BuyBuffer[bar]=low[bar]-Range*0.5; if(bar==0) //possible signals at bar 0 gonna be repainted or removed again { if(counter<NumberofAlerts)//if(counter<=NumberofAlerts) { //Alert("Trend ",EnumToString(Period())," ",Symbol()," BUY"); Alert("Trend ",EnumToString(Period())," ",Symbol()," BUY","\n","Current time is ",TimeToString(TimeCurrent(),TIME_SECONDS)); counter++; } } else counter=0; } if(uptrend!=old && uptrend==false) { SellBuffer[bar]=high[bar]+Range*0.5; if(bar==0) //possible signals at bar 0 gonna be repainted { if(counter<NumberofAlerts)//if(counter<=NumberofAlerts) { //Alert("Trend ",EnumToString(Period())," ",Symbol()," SELL"); Alert("Trend ",EnumToString(Period())," ",Symbol()," SELL","\n","Current time is ",TimeToString(TimeCurrent(),TIME_SECONDS)); counter++; } } else counter=0; } if(bar>0) old=uptrend; } //---- return(rates_total);//return(prev_calculated); } //+------------------------------------------------------------------+

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
This is the announcement for the 1er programming contest for mql5 community. This little contest consist to find some bugs in less time possible.
See also this topic Programmers Contest : Who can find more bugs in less time. Are you interested to participate ?
There is no price, the goal is to learn and entertain us a little. Monday at 15:00 GMT, I will post a mql5 code, with some bugs. Each participant can then begin his work to found the bug and then send me the results. When all results will be received, I will post them here, with a classification and of course some explanation. Of course some people who are interested to participate won't be free at this time, so don't worry, it's only the first contest, and the followers will be planned at different day/time, you can post your preference in this thread to help us organize the next contest.
The rules are the following :
We are also trying to organize such contest for mql4 and on other language sections. Feel free to ask any question.
P.S: If some is interested but want to be anonymous for whatever reason, there is no problem. Simply send me your code with correction, I won't publish your name publicly.