How can I iterate an indicator from past to present?

 

Hello :-)

This is a really silly question but I would like to "look into the inmediate past" of my indicator to see if a signal has been triggered. It seems easy but indicator iteration is backwards!

Is there a way to do it without falling into an infinite loop with iCustom calling myself over and over again?

Is to avoid repetitive signals -which have been thrown in the inmediate past-

Thank you!

 
flaab:


This is a really silly question but I would like to "look into the inmediate past" of my indicator to see if a signal has been triggered. It seems easy but indicator iteration is backwards!

Is there a way to do it without falling into an infinite loop with iCustom calling myself over and over again?

  1. What do you mean backwards? The indicator calculates values for all bars it does not call iCustom on itself. (Only MTF indicators do that)
  2. Your EA calls iCustom with whatever shift value you want.
  3. You are very confused, by your question. Explain yourself better and we might be able to see where.
 
flaab:

This is a really silly question but I would like to "look into the immediate past" of my indicator to see if a signal has been triggered. It seems easy but indicator iteration is backwards!

Indicator iteration typically starts from long ago, say bar[3000], and comes forward to present time bar[0]. If you want to see if a trigger signal has occurred then look at bar[1]. There is no need to look back further than bar[1] because bar[5] would have been bar[1] 4 bars ago, so you would already have seen it and acted on it.
 
dabbler:
Indicator iteration typically starts from long ago, say bar[3000], and comes forward to present time bar[0].
It does in my Indicators, many examples I have seen work backwards . . . recent to long ago . . . so typically I would say they run from now to long ago.
 
dabbler:

That's bizarre. Any moving average filter has to work from past to present.

I (had) never seen one working that way so I just looked and found a Keltner Channel indicator that is indeed written from present to past for no good reason.


You know of course that you are going to unleash the wrath of the WHR for your insubordinate use of wrong way round for loops :-)

I don't think so . . . I coded my Indicators correctly . . . going from the past to the present . . . just like real time moves. I think WHR will agree with that . . . ;-)

If you look at the Custom Indicators supplied with MT4 I think you will see that they go backwards too . . . I'm sure I read a lengthy thread about it . . . can't remember. For my purposes it made sense to process the historic bars in the same way as current bars . . .

 

you both disagree what backwards is.

for dabbler backwards: for(int i=0;i<Bars;i++) //Going backwards in time

for raptor backwards: for(int i=Bars;i>=0;i--) //Looping backwards


at the end you are currently talking about the same ;)

 
zzuegg:

you both disagree what backwards is.

for dabbler backwards: for(int i=0;i<Bars;i++) //Going backwards in time

for raptor backwards: for(int i=Bars;i>=0;i--) //Looping backwards

Nope, for me backwards is i++ . . . I coded my indicators to go from the past to the present, so the bar index decrements when processing the historical bars.

 
arr, i have read it agian, my fault. apologize
 
zzuegg:
arr, i have read it agian, my fault. apologize
No worries :-)
 
RaptorUK:

Nope, for me backwards is i++ . . . I coded my indicators to go from the past to the present, so the bar index decrements when processing the historical bars.

Yes, I misread your post as well :-(
 

It is not the order of the loop that is the problem. It is wither the indicator repaints.

If the loop counts down and you don't see any iPos-n then most likely you're fine.

If the loop counts up, then it could be (intentionally or not) and must be looked at closely.

Count down is the way to go.

Reason: