Hi
I’m tackling my first attempt at a multi timeframe screener but I’m trying to get my head around the logic.
If I want to test a condition on an hour chart and also on a 30 min chart as an example. Then I presumably I write the code for each timeframe but it’s where I test the conditions on that I’m not sure about?
Using the example below, let’s say I only want to know if it’s happened on both timeframes but appreciate it might happen a few candles earlier or later on one timeframe than the other. Where do I test this condition and on what screener period?
Thanks, as always, Rob
//ONEHOURCROSS = 0
Signal = 0
EMA21 = ExponentialAverage[21](close)
EMA34 = ExponentialAverage[34](close)
IF EMA21 CROSSES OVER EMA34 THEN
Signal = 60
ENDIF
TIMEFRAME(30 minutes)
Signal = 0
//THIRTYMINCROSS = 0
EMA13 = ExponentialAverage[13](close)
EMA21 = ExponentialAverage[21](close)
IF EMA13 CROSSES OVER EMA21 THEN
Signal = 30
ENDIF
TIMEFRAME(Default)
SCREENER [(Signal)] (signal)
The TIMEFRAME(1 hour) keyword is missing.
I think it should be placed at line 2.
You should then move line 3, lines 8-10 and lines 21-23 to line 26.
Remove line 14.
The TIMEFRAME(1 hour) keyword is missing.
I think it should be placed at line 2.
You should then move line 3, lines 8-10 and lines 21-23 to line 26.
Remove line 14.
TIMEFRAME(1 hour)
EMA211hour = ExponentialAverage[21](close)
EMA3411hour = ExponentialAverage[34](close)
TIMEFRAME(30 minutes)
EMA1330mins = ExponentialAverage[13](close)
EMA2130mins = ExponentialAverage[21](close)
TIMEFRAME(Default)
Signal = 0
IF EMA211hour CROSSES OVER EMA3411hour THEN
Signal = 60
ENDIF
IF EMA1330mins CROSSES OVER EMA2130mins THEN
Signal = 30
ENDIF
SCREENER [(Signal)] (signal)
Thanks Roberto, so more like this?
But how would I catch the condition happening on one timeframe AND the other but perhaps within five bars of each other?
Try this:
TIMEFRAME(1 hour)
EMA211hour = ExponentialAverage[21](close)
EMA3411hour = ExponentialAverage[34](close)
TIMEFRAME(30 minutes)
EMA1330mins = ExponentialAverage[13](close)
EMA2130mins = ExponentialAverage[21](close)
TIMEFRAME(Default)
Signal = 0
IF EMA211hour CROSSES OVER EMA3411hour THEN
Signal = 60
ENDIF
IF EMA1330mins CROSSES OVER EMA2130mins THEN
Signal = Signal + 30
ENDIF
SCREENER [Signal] (signal)
this will return 30, 60 or 90 when both signals are returned.
What do you mean by 5 bars apart from each other? Which one should occur first?
Thanks again Roberto
As it stands at the moment, to get 90 i.e. when both signals are returned, does this mean they have to cross on the same candle? So, if the 30 min and 60 min candles both close at 3pm and the EMAs happened to cross in both the 30 min and 60 min candle then both signals would be returned?
If not, and say the EMAs crossed on the 30 min candle at 1.30pm then this would be outside of the 2pm-3pm 60 min candle. Very hypothetical example, I’m just trying to get my head round it.
Thanks.
Screeners work LIVE, they don’t care much when a candle closes.
So to return 90 both TF’s must have a crossover at the same time. To make sure the same signal is returned at closing time, then you should at[1] at line 15:
IF EMA211hour[1] CROSSES OVER EMA3411hour[1] THEN
the same for line 19.
With this change you will only consider the last candle closed, prior to the current one.
It’s slightly different than ProOrder, where strategies are always run at closing time, so the current candle is the last one closed. ProScreener scans markets LIVE, so the current candle is the one being formed [0] and the last one closed is [1].
Great, thanks, that clarifies it for me.