MA Cross Over

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13927 quote
    traderollie
    Participant
    New

    Would someone mind having a look at my code and seeing if it could be tweaked a little?

    I don’t have much experience and any help would be appreciated.

     

    Thank you

    #13942 quote
    Nicolas
    Keymaster
    Master

    Ok, but where is your code?😉

    #13944 quote
    traderollie
    Participant
    New

    Thank you very much.

    Is it also possible to time limit it?

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[5](close)
    indicator2 = Average[21](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 THEN
    BUY 2 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator3 = Average[5](close)
    indicator4 = Average[21](close)
    c2 = (indicator3 CROSSES UNDER indicator4)
    
    IF c2 THEN
    SELL  AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator5 = Average[5](close)
    indicator6 = Average[21](close)
    c3 = (indicator5 CROSSES UNDER indicator6)
    
    IF c3 THEN
    SELLSHORT 2 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator7 = Average[5](close)
    indicator8 = Average[21](close)
    c4 = (indicator7 CROSSES OVER indicator8)
    
    IF c4 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 15
    #13959 quote
    Nicolas
    Keymaster
    Master

    Ok, so that’s a simple moving average cross strategy. Seems that you have “coded” it with the simple creation module because the moving average variables are declared many times (for everyone’s information, this is not the case in the upgraded version of this programming module in v10.3).

    If you want to restrain trading time, you can add the flatbefore and flatafter instructions at the beginning of the code.

    #13962 quote
    traderollie
    Participant
    New

    Thank you, Can this be made “better” in any way?

     

    Ollie

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

MA Cross Over


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by traderollie
9 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/29/2016
Status: Active
Attachments: No files
Logo Logo
Loading...