Prevent netting of positions

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #141554 quote
    AugustusKing
    Participant
    Junior

    Hello all, hope that you’re well.

    I use the simplified creation ProOrder builder on PRT that I get with my IG Index account. I have a coded strategy that I’m happy with, BUT, only when the system doesn’t close your positions early if there’s a signal to take a position in the opposite direction.

    I’ve deactivated position netting on IG, but all this does is force open of multiple positions, which I have combated using:

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    My question to the forum is simply, how do I prevent the strategy from closing my trade and taking the opposite direction if/when a new signal comes along? This strategy needs to give positions time to play out.

    Here’s the code as it stands:

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 100000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 200000
    timeEnterAfter = time < noEntryAfterTime
    
    // Conditions to enter long positions
    indicator1 = ExponentialAverage[200](close)
    c1 = (close > indicator1)
    indicator2 = MACDline[12,26,9](close)
    indicator3 = ExponentialAverage[9](MACDline[12,26,9](close))
    c2 = (indicator2 CROSSES OVER indicator3)
    indicator4 = MACDline[12,26,9](close)
    indicator5 = MACD[12,26,9](close)
    c3 = (indicator4 < indicator5)
    
    IF (c1 AND c2 AND c3) AND timeEnterBefore AND timeEnterAfter THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator6 = ExponentialAverage[200](close)
    c4 = (close < indicator6)
    indicator7 = MACDline[12,26,9](close)
    indicator8 = ExponentialAverage[9](MACDline[12,26,9](close))
    c5 = (indicator7 CROSSES UNDER indicator8)
    indicator9 = MACDline[12,26,9](close)
    indicator10 = MACD[12,26,9](close)
    c6 = (indicator9 > indicator10)
    
    IF (c4 AND c5 AND c6) AND timeEnterBefore AND timeEnterAfter THEN
    SELLSHORT 1 PERPOINT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 30
    SET TARGET pPROFIT 45
    

    (I use it on GBP/USD on the 5 min time frame)

    I appreciate any help, thanks guys.

    Matt

    #141555 quote
    robertogozzi
    Moderator
    Master

    At line 22 and line 36 add this before the final THEN:

    And Not OnMarket
    AugustusKing thanked this post
    #141556 quote
    AugustusKing
    Participant
    Junior

    Roberto, as always, thank you for the rapid reply. That has worked!

    I love this community, I think it’s the best forum I’ve ever been a part of. I just wish that I were able to also be helpful to users haha. I need to go through doing all the courses properly.

    Thanks again!!

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

Prevent netting of positions


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/14/2020
Status: Active
Attachments: No files
Logo Logo
Loading...