Coding Criteria using multiple conditions

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #145782 quote
    Courtney Smith
    Participant
    Junior

    Pro Screener Questions

    System Name Conqueror

    So I currently have this system that has 3 conditions. If all three conditions are met we have the count =+3 (we go long) and if all three conditions are not me we have the count=-3(we got short).

    I am trying to develop a screener where it will search for when we have the first initial count of +3 or -3 condition.

    I am not sure how to code it where the screener looks back to the previous day (maybe use barindex??)  to see if we have the count of +1, +2 or -1, -2 then sees that today… we now have the count of +3 or -3. In such that I want to go long or go short on the very first signal not during the middle of the move.

     

    In addition to searching for the first initial criteria of +3  or -3. I want and additional criteria where we use the ADX14 where the slope must be positive to take the trade ie show up in the screener.

    I have attached some screen shots of what a good signal and bad signal would be, the PRT indicator and the PRT screener code that I have developed so far.

    Any help would be greatly appreciated.

    Conqueror-Code.docx Conqueror-Screener-Help-Screenshots.docx Conqueror-Screener-3-3-adx.itf Conqueror-CS-version-Indicator.itf
    #145790 quote
    robertogozzi
    Moderator
    Master

    Here is the modified screener, so that it returns only the first signal, with the addition of ADX as a filter:

    // this is an attempt at finding new +3 and -3 conqueror postions
    count=0
    countb=0
    MA = Average[10](Dclose(10))
    cond1= dclose(0)-average[10](close)
    cond2= average[10](close)-MA
    cond3= dclose(0)-dclose(40)
    MyAdx= Adx[14]
    cond4= MyAdx > MyAdx[1]
    cond5= MyAdx < MyAdx[1]
    if cond1>0 then
       count=count+1
    endif
    if cond2>0 then
       count=count+1
    endif
    if cond3>0 then
       count=count+1
    endif
    if cond1<0 then
       countb=countb-1
    endif
    if cond2<0 then
       countb=countb-1
    endif
    if cond3<0 then
       countb=countb-1
    endif
    if ((count=3 AND cond4) or (countb=-3 AND cond5)) then
       c1=1
    else
       c1=0
    endif
    x = c1
    IF c1 = c1[1] THEN     //make sure not to issue a signal equal to the previous one
       x = 0
    ENDIF
    Screener[x]

    When attaching files, please attach only:

    • ITF files for the ProRealTime platform
    • TXT or PDF files for unformatted text
    • PDF files for formatted text and documents
    • JPG or PNG files for images.

    Moreover, when posting ITF (code) files, please post also the source code (using the “Insert PRT code” button to make it easier to read).

    Thank you 🙂

    Practice-Conqueror-Search-2.itf
    #146129 quote
    Courtney Smith
    Participant
    Junior

    Hi Roberto,

    Thank you so much for the support. I do have a few more questions. I did make a few modifications to your code that you provided. You can see my comments in the code. But for some reason this isnt working 100% correct all the time. Also I am the person that reached out on August 13 for one on one tutoring. I am almost ready to set up an appointment with you.

    The +3 trades seem to work most of the time (see attached screen shots)

    The -3 trades dont seem to work as well.   (see attached screen shots)

     

     

    // this is an attempt at finding new +3 and -3 conqueror postions
    count=0
    countb=0
    MA = Average[10](Dclose(10))
    cond1= dclose(0)-average[10](close)
    cond2= average[10](close)-MA
    cond3= dclose(0)-dclose(40)
    MyAdx= Adx[14]
    cond4= MyAdx > MyAdx[1]
    //cond5= MyAdx < MyAdx[1]      We only want to take trading signals if ADX has postive slope bull or bear trades. ADX is confirming that the trend is "trending". We dont need this part of the code.
    if cond1>0 then
    count=count+1
    endif
    if cond2>0 then
    count=count+1
    endif
    if cond3>0 then
    count=count+1
    endif
    if cond1<0 then
    countb=countb-1
    endif
    if cond2<0 then
    countb=countb-1
    endif
    if cond3<0 then
    countb=countb-1
    endif
    if ((count=3 AND cond4) or (countb=-3 AND cond4)) then    // Cond5 in the second part i changed to cond4
    c1=1
    else
    c1=0
    endif
    x = c1
    IF c1 = c1[1] THEN     //make sure not to issue a signal equal to the previous one
    x = 0
    ENDIF
    Screener[x]
    Practice-Conqueror-Search-3.itf Conqueror-3-Signal-when-it-should-not-have-showed-up-on-screener.jpg Conqueror-3-Signal-when-it-should-not-have-showed-up-on-screener.jpg Conqueror-3-Signal-when-it-should-not-have-showed-up-on-screener-1.jpg Conqueror-3-Signal-when-it-should-not-have-showed-up-on-screener-1.jpg
    #146236 quote
    robertogozzi
    Moderator
    Master

    I replaced the last line of the screener with:

    Screener[x](Count + Countb AS "Criteria")

    then I converted it into this indicator:

    MA    = Average[10](Dclose(10))
    cond1 = dclose(0)-average[10](close)
    cond2 = average[10](close)-MA
    cond3 = dclose(0)-dclose(40)
    RETURN cond1 AS "cond1",cond2 AS "cond2",cond3 AS "Cond3"

    and it seems to be working fine.

    Xscreener.jpg Xscreener.jpg MyIndicator.itf
    #146299 quote
    Courtney Smith
    Participant
    Junior

    Hi Roberto,

    Thank you once again. I added your adjustments to my code. I think I was a little bit vague in my last post.

    I am fairly confident in my indicator working correctly, but I am having trouble in the screener itself.

    I think we are very close to having it work 100%. I just ran the screener on the predefined list “US NASDAQ Stocks”.

    The Screener does produce initial +3 signals correctly most of the time… But for example this stock “FLDM” was listed as a fresh +3 signal, but it is actually the second +3 signal in the string and shouldnt have shown up at all. Thursday Oct 1st was the first +3 day, but the adx was negative so it technically shouldn’t show up in the screener for Oct 1.  On Oct 2nd we got another +3 signal and the first day we got a positive ADX.  So maybe the order of the code needs to be switched around so the adx is read first?

    Also

    Conqueror-3-Signal.jpg Conqueror-3-Signal.jpg
    #146423 quote
    Courtney Smith
    Participant
    Junior

    I was able to figure it out on my own.

    Thank you once again. !

    Now time to try to get a backtest worked out for this.

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

Coding Criteria using multiple conditions


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Courtney Smith
5 years, 5 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 09/28/2020
Status: Active
Attachments: 11 files
Logo Logo
Loading...