Help on coding of ema strategy

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #83734 quote
    rae
    Participant
    New

    hi all,

    i have generate a code on ema crossing strategy. however, it seems like the gain is good but the exit point are not excellent. appreciate anyone could help me optimise this code for better exit prices. thanks in advance.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = ExponentialAverage[620](close)
    c1 = (close[1] CROSSES OVER indicator1)
    
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator2 = ExponentialAverage[34](close)
    c2 = (close CROSSES OVER indicator2)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator3 = ExponentialAverage[620](close)
    c3 = (close[1] CROSSES UNDER indicator3)
    
    IF c3  THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator4 = ExponentialAverage[89](close)
    c4 = (close CROSSES OVER indicator4)
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 30
    #83739 quote
    Vonasi
    Moderator
    Master

    Post moved to ProOrder forum as that is a more relevant place for strategy questions.

    It may help a lot if you tell everyone which instrument you are testing it on and what time frame you are testing it on.

    rae thanked this post
    #83743 quote
    GraHal
    Participant
    Master

    Do you know that you have … over (entry)  & over (exit) for Longs and under (entry) & over (exit) for Shorts?

    I know it can work good like that but just thought maybe your intention was … over (entry) & under (exit)  for Longs?

    rae thanked this post
    #83901 quote
    rae
    Participant
    New

    Thank you all for the reply.

    Here is my strategy:

    Long entry
    Condition 1 – Bar crosses over EMA 620
    Condition 2 – MACD crosses over zero
    Condition 3 – Stochastic < 45 Exit Long Condition - Stochastic > 55

    Short entry
    Condition 1 – Bar crosses under EMA 620
    Condition 2 – MACD crosses under zero
    Condition 3 – Stochastic > 55

    Exit Short
    Condition – Stochastic < 45 Time frame, I am looking at 30min Thanks all.

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

Help on coding of ema strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rae @rae Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by rae
7 years, 4 months ago.

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