Indicator bug

 

Hi everyone,

I have an indicator that does not create new signals after it has been put on a chart. In other words, the indicator shows signals that occured in the past, but it does not generate new signals once it's on the chart. When I place the indicator on the chart again after letting some time pass, it will generate and show signals in that same period where it didn't generate any signals initially.

It also seems like the indicator is repainting old signals when I put it back on the chart. Not sure what the issue is, but it might be an easy and quick fix for a more experienced coder.


Source code is attached, would be great if you could help me out.

Files:
 

Insert the following on line 110.

if (counted_bars == 0)
   limit -= atrPeriod;
 
Naguisa Unada:

Insert the following on line 110.

I did, new signals are now generated, but this happens on almost every bar. The signals are not generated with the logic of the indicator anymore.

 
Michael Breu:

I did, new signals are now generated, but this happens on almost every bar. The signals are not generated with the logic of the indicator anymore.

The first problem is an "Array out of range" error, which has been resolved. It has nothing to do with new trouble.

It takes a lot of time to analyze and modify the way signals are generated. I don't know whether I can help you.

 
Michael Breu:

I did, new signals are now generated, but this happens on almost every bar. The signals are not generated with the logic of the indicator anymore.

It's a badly designed indicator.

You can try replacing

string signalSentAlready = "NONE";
if (symbol == "0" || symbol == "") symbol = Symbol();
    for(int i = 0; i < limit; i++)

with

static string signalSentAlready = "NONE";
if (symbol == "0" || symbol == "") symbol = Symbol();
    for(int i = limit-1; i >= 0; i--)

That should stop you getting the repeat signals.

Not compiled, not tested.

 
Naguisa Unada: Insert the following on line 110.

See also How to do your lookbacks correctly.

Reason: