EXITSHORT not working?

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

    Hi, I have a trading system which appears not to want to EXITSHORT. Which is clearly very strange. what am i missing here?

    Am certain the exitdn condition is triggered as other variables in the if statement are being correctly affected (position is reset to its initial value) and the exitdn boolean is true at the expected time. however the EXITSHORT is not executing: the position size is unaffected and so the position’s losses are unusually large.

    I may have read the outcome incorrectly and it is in actual fact executing, but then why is the positionsize not zero?

    For BUY, SELL and SELL SHORT the system behaves as expected: overall position size adjusted, new position entry size decreased (the system takes a large initial stake and then decreases new stake position size each time until 1 or the exit is tirggered and so a reset to initial)

    On the screenshot we see EURCAD 5min on Friday 22nd Jan at 16:15. At 16:10 the CCI crossed over the 100 line which is an exit short condition in this system. At 16:20 the Positions should have gone down to zero. on the user variables chart the blue variable Position (new entry size) is reset to initial value 5. The variable Xdn is set to 1 indicating an exit down criteria has been met, so the contents of the if condition should all be executed.

    I tried with EXITSHORT and with BUY, same inaction both times.

    Will keep looking and any suggestions questions welcome 🙂

     

    Thank you.

    myCCI=CCI[20]
    CCIMA=Average[20](myCCI)
    
    initialposition = 5
    
    if onmarket then
    ccimaup = ccima > 70
    ccimadn = ccima < -70
    else
    ccimaup = ccima > 10
    ccimadn = ccima < -10
    position = initialposition
    endif
    
    Vup = mycci>mycci[1] and mycci[1] < mycci[2] and mycci>0//  \/
    Vdn= mycci<mycci[1] and mycci[1] > mycci[2]and mycci<0//    /\
    
    entryup= ccimaup and Vup
    entrydn= ccimadn and Vdn
    
    
    exitup = myCCI crosses under -100 and longonmarket
    exitdn = myCCI crosses over 100 and shortonmarket
    
    
    
    if entryup then
    buy position contract at market
    SET STOP TRAILING SAR[0.02,0.02,0.09]
    if position >1 then
    position = position -1
    endif
    endif
    
    if entrydn then
    SELLSHORT position contract at market
    SET STOP TRAILING SAR[0.02,0.02,0.09]
    if position >1 then
    position = position -1
    endif
    endif
    
    GRAPH exitup*-1 coloured (255,0,0) as "Xup"
    GRAPH exitdn coloured (155,0,0) as "Xdn"
    GRAPH entryup coloured (0,255,0) as "UP"
    GRAPH entrydn*-1 coloured (0,200,0)as "DN"
    GRAPH position coloured (0,0,200) as "Position"
    
    
    if exitup then
    SELL COUNTOFPOSITION contract at market
    position = initialposition
    endif
    
    if exitdn then
    EXITSHORT COUNTOFPOSITION contract at market
    //BUY COUNTOFPOSITION contract at market
    position = initialposition
    endif
    
    #158977 quote
    fifi743
    Participant
    Master

    Hello,
    Graph COUNTOFPOSITION .
    It is negative -16 on the graph whereas you have 5 trades.

    Capture-decran-1253.png Capture-decran-1253.png
    #159082 quote
    Philippo
    Participant
    Average

    this is expected, the position builds with decreasing stakes, so 16=5+4+3+2+1+1 for a total of six entries as the favourable wind continues…

    if the wind changes and the stoploss is triggered, everything appears ok. Well at least it triggers.

    The problem I have is that this position of 16, when the exit criteria are met, does not execute the EXITSHORT.

    at 2030 on your attachment I see an exit long signal on the variables, so SELL happens and the position is reset. But looking earlier you will see two exit short (red /\ on the variables graph) but the position size keeps growing. It should be same as exit long: BUY and position is reset. why no buy?

    Thanks

    #159095 quote
    robertogozzi
    Moderator
    Master

    Instead of using COUNTOFPOSITION, which can be negative, use:

    abs(COUNTOFPOSITION)

    to make it positive.

    Philippo thanked this post
    #159178 quote
    Philippo
    Participant
    Average

    awesome! thanks

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

EXITSHORT not working?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Philippo @philipd Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Philippo
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/23/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...