PRT goes against rulesIF NOT LongOnMarket AND LongCondition AND belowred = 1 TH?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #4869 quote
    JerryJerry
    Participant
    New

    Hi guys,

    I’ve found a very interesting “bug”. For some reason it seems that PRT sometimes ignores a very important condition and goes for it anyway. In my code I have this:

    IF NOT LongOnMarket AND LongCondition AND belowred = 1 THEN

    Notice the “belowred = 1”. That’s my on/off trigger for buy, if it’s 0 then no go. Once i’m in the market it goes to zero and waits for a specific condition to switch back on. That works like a charm.

    However, PRT ignores it and takes a trade I don’t want! Look at the attached image. That IF statement is the only place in the code where a buy order is issued… Anyone else have this kind of hick-ups? Errors like this is very costly and if this is a true PRT error it is very serious.

    triggerPRT.png triggerPRT.png
    #4874 quote
    NicolasNicolas
    Keymaster
    Legend

    Hello, the other trades I see on your chart were also launched on a 0 condition. It’s difficult to help you more with no code at all 😀

    #4875 quote
    JerryJerry
    Participant
    New

    Arn’t those just a result of lag? Here is the full code (a bit messy though):

    //Conditions för long re-entry
    ONCE belowred = 1
    
    IF belowred = 0 AND low< MAH10 AND NOT LongOnMarket THEN
    belowred = 1
    ENDIF
    
    // Conditions to enter long positions
    MAL8 = Average[8](low)
    MAH10 = Average[10](high)
    
    William = WilliamsAccumDistr(close)
    WilliamMA = Average[57](William)
    
    LongCondition = low[1] > MAH10 AND open > MAH10 AND MAH10>MAL8 AND William>WilliamMA
    
    
    IF NOT LongOnMarket AND LongCondition AND belowred = 1 THEN
    BUY 100 CONTRACTS AT MARKET
    profittake = high+((high-low)*2)
    belowred = 0
    ENDIF
    
    graph belowred
    
    
    // Conditions to exit long positions
    If LongOnMarket AND open>profittake THEN
    SELL AT MARKET
    ENDIF
    
    //SL om hamnar under blå (MAL8)
    If LongOnMarket AND close<MAL8 THEN
    SELL AT MARKET
    
    ENDIF
    #4878 quote
    NicolasNicolas
    Keymaster
    Legend

    Can you tell me what instrument and timeframe please?

    Please test again with this instruction in the first line :

    defparam preloadbars = 0
    #4880 quote
    JerryJerry
    Participant
    New

    Im running daily on any stock. Preloadbars didn’t work, see attached result.

    PRTissue.png PRTissue.png
    #4883 quote
    NicolasNicolas
    Keymaster
    Legend

    For me everything is working well. Your GRAPH instruction draw your “belowred” variable that is reset to 0 each time you take a trade on line 21. That’s why you may think that PRT take the trade in “inverted” mode despite of this variable value.

    #4900 quote
    JerryJerry
    Participant
    New

     

    Hi Nicolas,

    Yeah I got it now, belowred goes on, trade is made and it goes off all in the same bar – thus it is “invisible” at that entry. Great, many thanks for your help!

    #4996 quote
    JerryJerry
    Participant
    New

    Hi,

    I’m still having a bit of trouble figuring this one out (this time it’s a reverse problem). Obvious entry is missed completely or severely delayed. Kindly look at the attached image, there should be an entry at X:

    LongCondition = low[1] > MAH10 AND open > MAH10 AND MAH10>MAL8 AND William>WilliamMA
    • Bar before above red line? Check.
    • Open above red line? Check.
    • Red line above blue line? Check.
    • William above Williams MA? Check.
    • belowred = 1? Check.

    Yet no entry at all…

     

    Now let’s have a look at Y:

    Same conditions as above, all check. Yet the entry is at 5th bar!

     

    Is it possible that “AT MARKET” sometimes fail or is greatly delayed? Or am I missing something here?

    PRTissue2.png PRTissue2.png
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

PRT goes against rulesIF NOT LongOnMarket AND LongCondition AND belowred = 1 TH?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Jerry @noren Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by JerryJerry
10 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/05/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...