How to have EA look at past 10 bars for signal?

Post Reply
jayjonbeach
Posts: 3
Joined: Sun Feb 26, 2012 11:30 pm

How to have EA look at past 10 bars for signal?

Post by jayjonbeach »

Hi all. Looking for quick help to write a line of code for a signal.

I am using Step_Indy and an EMA cross for a combined signal. What I want to do is have the EA enter a trade only when both give a signal within 10 bars of each other.

So say that the Step gives a signal, I want the EA to look back 10 bars to see if there was a MA cross, if yes enter, if not ignore signal. (Note I don't want it to just check and see if the MA cross current signal is long, I want it to have been a recent NEW signal like within 10 bars, this is critical to the strat)

I know I need to likely use the 'for' function, but an unsure of how exactly I should structure it.

TIA for any help, I don't think I have seen this done in the past in any EA's I've looked at.
Solarwind
Posts: 9
Joined: Tue Nov 22, 2011 11:52 pm

Re: How to have EA look at past 10 bars for signal?

Post by Solarwind »

I've used this..
for (int ct=SignalCandle;ct<=SignalCandle+LookBack;ct++) {

Hope it helps
Post Reply

Return to “Coders Hangout”