Hello everyone,
I am very new to coding, so I’m just trying to learn and make myself a somewhat useful screener. As I don’t understand why the results I get don’t meet all my conditions, I would very much appreciate if someone could point out what I’m doing wrong.
The idea was to have 2 conditions for each timeframe, and the results need to meet all 4 conditions.
Condition 1 (weekly): The fast EMA needs to have crossed over the slow EMA (ideally it would have occured recently but I haven’t figured out how to do that)
Condition 2 (weekly): Bars must have been tracing higher lows for the past X weeks
Condition 3 (daily): The close is currently below a X day EMA
Condition 4 (daily): Volume has been rising for the past X days
EMA13 = ExponentialAverage[13](Close)
EMA26 = ExponentialAverage[26](Close)
WeeklyLookback = 4
DailyLookback = 5
EMA22 = ExponentialAverage[22](Close)
TIMEFRAME (Weekly)
C1 = EMA13 > EMA26
C2 = summation[WeeklyLookback](Low > Low[1])
TIMEFRAME (Daily)
C3 = Close < EMA22
C4 = Summation[DailyLookback](Volume > Volume [1])
SCREENER[C1 And C2 And C3 And C4]
Any advice would be greatly appreciated, thanks a lot!
First thing I notice is that your SUMMATIONs need to be compared to something.
C2 = summation[WeeklyLookback](Low > Low[1]) = WeeklyLookback
C4 = Summation[DailyLookback](Volume > Volume[1]) = DailyLookback
You can also use SUMMATION to check if a cross has occurred recently.
c1 = (summation[WeeklyLookback](EMA13 crosses over EMA26) > 0) and (EMA13 > EMA26)
Lines 1-5 are evaluated according to your default TF, so lines 9 and 14 will be set weekly and daily but are not evaluating a daily nor weekly EMA.
Lines 1-5 are evaluated according to your default TF, so lines 9 and 14 will be set weekly and daily but are not evaluating a daily nor weekly EMA.
I did spot that one but I was waiting for CluelessNobel to reply that it still didn’t work before passing on the final clue! Saturday is a slow day on the forums and I was trying to get as many posts as possible! I didn’t want to hand the fish straight over before the OP had done a little fishing!
Thank you so much for taking the time to reply. I wish I could have gotten back to this sooner but internet is currently down at my place, which means I’m operating on lousy 3G…
After reading that my summation condition isn’t compared to anything, I think I don’t fully understand how it’s meant to be used. When writing:
C2 = summation[WeeklyLookback](Low > Low[1])
I thought I was already saying: the current low needs to have been above the previous one for the past X number of weeks. Obviously that’s wrong, but when I look at your correction, I don’t understand why I must use my “WeeklyLookback” variable twice. Could you “translate” it for me?
c1 = (summation[WeeklyLookback](EMA13 crosses over EMA26) > 0) and (EMA13 > EMA26)
Do I understand this correctly? => Over the past X number of weeks, the fast EMA has crossed the slow EMA more than 0 times, AND the fast EMA is above the slow EMA?
Sorry, I posted something wrong.
Hi Roberto, thank you very much for replying,
I think I see what you’re trying to tell me but I need to ask you follow up questions.
Do you mean that when I’m setting variables, I must set them according to a specific timeframe? If that’s the case it’s confusing to me because I thought I was already giving the appropriate instructions by just specifying the timeframe, and then writing the conditions. Ie: in this timeframe, look for these conditions.
TIMEFRAME (Weekly)
EMA13 = ExponentialAverage[13](Close)
EMA26 = ExponentialAverage[26](Close)
C1 = EMA13 > EMA26
TIMEFRAME (Daily)
EMA22 = ExponentialAverage[22](Close)
C3 = Close < EMA22
That is your correct use of your conditions.
If you define an MA in a TF you can access it wherever you want to, but it will refer to the TF where the MA has been defined.
If you need to check the same MA in different TF’s, then you have to define the MA in each TF using different variable names.
SUMMATION will count how many times a condition is met in x candles. So if you check four candles and condition EMA1 < EMA2 = 4 then it is true that EMA1 has been less than EMA2 for at least four candles. If the SUMMATION result is less than the total look back period of x then the condition is false and EMA1 has not been less than EMA2 for the last x candles.
|
|
c1 = (summation[WeeklyLookback](EMA13 crosses over EMA26) > 0) and (EMA13 > EMA26)
|
Do I understand this correctly? => Over the past X number of weeks, the fast EMA has crossed the slow EMA more than 0 times, AND the fast EMA is above the slow EMA?
Yes that is exactly correct. There has been at least one cross over in the last x weeks and the fast EMA is currently still above the slow EMA so it cannot have crossed back under.
With the SUMMATION instruction, you simply make a sum of all boolean conditions that were true (so equal to 1) in the last X periods. So if the summation is superior to 0, one of the X previous condition was true.
OK got it this time.
Thank you all very much, that was really helpful.