Code check please – keep me in the trade if a stoploss is hit?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #53850 quote
    MattyJMattyJ
    Participant
    Junior

    Hi guys,  Could I just ask for someone to cast an eye over this code to see if there are any issues with it. For example, will it keep me in the trade if a stoploss is hit? 

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[14](close)
    indicator2 = Average[30](close)
    c1 = (indicator1 > indicator2)
    indicator3 = Average[30](close)
    indicator4 = Average[50](close)
    c2 = (indicator3 > indicator4)
    indicator5 = Average[14](close)
    c3 = (close CROSSES UNDER indicator5)
    indicator6 = Average[30](close)
    c4 = (close > indicator6)
    
    IF c1 AND c2 AND c3 AND c4 THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF
    
    IF c1 THEN
    SELL AT MARKET
    ENDIF
    // Conditions to enter short positions
    indicator7 = Average[14](close)
    indicator8 = Average[30](close)
    c5 = (indicator7 < indicator8)
    indicator9 = Average[30](close)
    indicator10 = Average[50](close)
    c6 = (indicator9 < indicator10)
    indicator11 = Average[14](close)
    c7 = (close CROSSES OVER indicator11)
    indicator12 = Average[30](close)
    c8 = (close < indicator12)
    
    IF c5 AND c6 AND c7 AND c8 THEN
    SELLSHORT 1 PERPOINT AT MARKET
    ENDIF
    
    IF c2 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 25 ptrailing 25
    SET TARGET pPROFIT 150
    

      Thanks,  

    #53866 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    STOP LOSS is an order to close a trade, so when it’s entered your trade will end.

    Line 44 cannot be written that way (despite what PRT documentation says), you have to either write one of these (your choice):

    SET STOP pLOSS 25
    SET STOP ptrailing 25

    Roberto

    #53867 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There are some duplicates, lines 5-14 can be written:

    indicator1 = Average[14](close)
    indicator2 = Average[30](close)
    c1 = (indicator1 > indicator2)
    //indicator3 = Average[30](close)
    indicator4 = Average[50](close)
    c2 = (indicator2 > indicator4)
    indicator5 = Average[14](close)
    c3 = (close CROSSES UNDER indicator5)
    //indicator6 = Average[30](close)
    c4 = (close > indicator2)

    For the rest, it’s your strategy, try to test and optimize it, compare it to other strategiesyou may find here and over the web and… have fun autotrading!

    #53869 quote
    MattyJMattyJ
    Participant
    Junior

    Hi Roberto,

    Thanks very much for your help. The Simplified creator in PRT codes it as 

    // Stops and targets
    SET STOP pLOSS 25 pTRAILING 25

    Are you saying that’s incorrect and won’t work as a trailing stop 25 points behind profit? If so that is a pretty major flaw in their software right?

    #53873 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Yest, it is.

    #54159 quote
    NicolasNicolas
    Keymaster
    Legend
    @Mattyj To be perfectly clear, these 2 combined instructions are not possible with ProOrder through IG. But works ok in demo/paper trading.
Viewing 6 posts - 1 through 6 (of 6 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

Code check please – keep me in the trade if a stoploss is hit?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
MattyJ @mattyj Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by NicolasNicolas
8 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/24/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...