Screener unknown error

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15237 quote
    jbyrne
    Participant
    Average

    Hi guys,

    Ive written this code and I can’t see anything wrong with it but the screener output doesn’t like it since it just returns my whole list.

    Can anyone see what is the problem with my code? also if I remove the first timeframe it works, but i’ve used code with dual timeframes before and it worked fine.

    thanks

     

    TIMEFRAME(1 minutes)
    ma20 = ExponentialAverage[20](close)
    ma50 = exponentialaverage[50](close)
    ma100 = ExponentialAverage[100](close)
    ma200 = exponentialaverage[200](close)
    
    ma10 = (ma20 crosses over ma50)
    ma20 = (ma20 crosses over ma100)
    ma30 = (ma50 crosses over ma100)
    ma40 = (ma50 crosses over ma200)
    
    ma50 = (ma20 crosses under ma50)
    ma60 = (ma20 crosses under ma100)
    ma70 = (ma50 crosses under ma100)
    ma80 = (ma50 crosses under ma200)
    
    Bull0 = ma10 or ma20 or ma30 or ma40
    Bear0 = ma50 or ma60 or ma70 or ma80
    
    TIMEFRAME(5 Minutes)
    
    ma20 = ExponentialAverage[20](close)
    ma50 = exponentialaverage[50](close)
    ma100 = ExponentialAverage[100](close)
    ma200 = exponentialaverage[200](close)
    
    ma1 = (ma20 crosses over ma50)
    ma2 = (ma20 crosses over ma100)
    ma3 = (ma50 crosses over ma100)
    ma4 = (ma50 crosses over ma200)
    
    ma5 = (ma20 crosses under ma50)
    ma6 = (ma20 crosses under ma100)
    ma7 = (ma50 crosses under ma100)
    ma8 = (ma50 crosses under ma200)
    
    Bull = ma1 or ma2 or ma3 or ma4
    Bear = ma5 or ma6 or ma7 or ma8
    
    rise2 = summation[1](Variation(close))>=0.5
    fall2 = summation[1](Variation(close))<=-0.5
    
    rise3 = summation[2](Variation(close))>=0.5
    fall3 = summation[2](Variation(close))<=-0.5
    
    //1%
    
    rise11 = summation[5](Variation(close))>=1
    fall11 = summation[5](Variation(close))<=-1
    
    rise22 = summation[1](Variation(close))>=1
    fall22 = summation[1](Variation(close))<=-1
    
    rise33 = summation[2](Variation(close))>=1
    fall33 = summation[2](Variation(close))<=-1
    
    rise44 = summation[3](Variation(close))>=1
    fall44 = summation[3](Variation(close))<=-1
    
    rise55 = summation[4](Variation(close))>=1
    fall55 = summation[4](Variation(close))<=-1
    
    Rises5 = rise2 or rise3
    Rises1 = rise11 or rise22 or rise33 or rise44 or rise55
    Falls5 = fall2 or fall3
    Falls1 = fall11 or fall22 or fall33 or fall44 or fall55
    
    screener [Rises5 or rises1 or falls1 or falls5 or bull or bear or bull0 or bear0] (rises1 or falls1 as "1% = 1")
    #15258 quote
    Nicolas
    Keymaster
    Master

    Well, there are a lot of “or” statements conditions, it is difficult to know why you have this problem. Obviously, because of the OR conditions, seems normal to me that you get a lot of results here. It is also difficult to know what condition has fired the screener result to debug it 🙂

    jbyrne thanked this post
    #15260 quote
    jbyrne
    Participant
    Average

    Ive just found the problem; the first timeframe was using the same ‘ma20’ ‘ma50′ ma100′ ma200’ as the second timeframe. Thanks for replying

    #15264 quote
    JC_Bywan
    Moderator
    Master

    Hi, don’t know about same moving averages used in both timeframes if you wanted different ones, this depends on your choices, but from a coding point of view, if we take a look just at first timeframe only, we can see you first define ma20 in line 2:

    ma20 = ExponentialAverage[20](close)

    and then you use this same ma20 name for storing a condition (0 or 1) value in line 8

    ma20 = (ma20 crosses over ma100)

    so later when you reach your lines 12 and 13, the ma20 used in (ma20 crosses under…) is no more the exponential moving average, but just the 0 or 1 value stored in line 8

    same thing with ma50 defined twice in line 3 and line 12, then becoming just 0 or 1 instead of an exp moving average in lines 14-15

    You probably want to rename your conditions ma10 to ma80 in lines 7 to 18 with something different from “ma…” to avoid any confusion between a condition and a moving average

    Problem doesn’t seem to repeat itself in second timeframe because there you used ma1 to ma8, so no double roles with 2 different definitions for ma20 and ma50 there. However, might be worth renaming ma1 to ma8 in lines 27 to 38 with same type of name you choose to rewrite ma10 to ma80 in lines 7 to 18 not to mix up conditions and moving averages

    #15276 quote
    Nicolas
    Keymaster
    Master

    @Noobywan

    I want you as a second brain 🙂

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Screener unknown error


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
jbyrne @jbyrne Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Nicolas
9 years, 4 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 10/20/2016
Status: Active
Attachments: No files
Logo Logo
Loading...