the code quality of indicators posted by people who think they must write indicators although they [know that they] have *absolutely* no clue about what they are doing is exactly as it can be expected under such circumstances.
Here is an example:
Why don't people at least try to test their code (for functionality, not profitability) before releasing it?
</rant>
Here is an example:
Inserted Code
int limit, i, counter; double MA1now, MA2now, MA1previous, MA2previous, MA1after, MA2after; double Range, AvgRange; [b][color=Red] // this following whole pattern is just copy&pasted from some [/color][/b][b][color=Red] // extremely bad written example indicator written somewhere // in cold siberia after the consumption of too much vodka that just // happens to be cited over and over despite (or because?) // of its extreme ugliness and without ever being fully understood. [/color][/b] int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) [color=Blue][color=Black]counted_bars[/color][b][color=Red]--[/color][/b][/color]; limit=Bars-counted_bars; for(i = 0; i [color=Red][color=Black]<[/color][b]=[/b][/color] limit; i++) { [b][color=Red] [/color][/b][b][color=Red] // now this will count from 0 to 2 on each new bar[/color][/b] [b][color=Red] // so the condition will be checked 3 times[/color][/b] counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; MA1now = iMA(NULL, 0, MA1, 0, MA1Mode, PRICE_CLOSE, i); MA1previous = iMA(NULL, 0, MA1, 0, MA1Mode, PRICE_CLOSE, i+1); MA1after = iMA(NULL, 0, MA1, 0, MA1Mode, PRICE_CLOSE, i-1); MA2now = iMA(NULL, 0, MA2, 0, MA2Mode, PRICE_CLOSE, i); MA2previous = iMA(NULL, 0, MA2, 0, MA2Mode, PRICE_CLOSE, i+1); MA2after = iMA(NULL, 0, MA2, 0, MA2Mode, PRICE_CLOSE, i-1); if ((MA1now > MA2now) && (MA1previous < MA2previous) && (MA1after > MA2after)) { CrossUp[i] = Low[i] - Range*1.5; [color=Red] [b]// natuarally this will now alert 3 times for the same signal[/b] [/color] if (AlertOn && NewBar()) { Alert(AlertPrefix+MA1short_name+" ("+MA1+") "+"crosses UP " + MA2short_name+" ("+MA2+")"); } [b][color=Red]// and this will send 3 emails![/color][/b] if (SendAnEmail && NewBar()) { SendMail(AlertPrefix,MA1short_name+" ("+MA1+") "+"crosses UP " + MA2short_name+" ("+MA2+")"); } } [...]
</rant>