Beginner needs some help with EMA cross strategy

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25348 quote
    NDT
    Participant
    Junior

    Hi all,

    I’ve been trading a system manually for the two years and I’m delighted to say it’s made a profit. What I’ve been trying to do since discovering PRT is to code my manual system, but everything I’m trying isn’t replicating the manual process.

    I’ve attached an image in the hope it’ll make my system a bit clearer, but I’ll explain below.

    The manual system uses three EMA’s – 8, 200, 400 EMA.

    • When the 8ema crosses over the 400ema we go long and when the 8 ema crosses back over the 200ema the long is exited.
    • Once the 8 ema and price enters a “channel” between the 200-400ema no trade is taken – treat it like a no mans land.
    • If price then pops back across the 200ema we go long again, hoping the trend will continue.

    The opposite happens for a short position.

    • If the 8ema moves out of the no trade zone and cross over the 400ema I go short
    • If the 8ema then re enters the no trade zone and crosses back over either the 400ema or the 200ema the trade is exited.

    Obviously the 200 and 400 switch around as the trend develops with the 200 eventually being the second closest ema as the trend in either direction establishes itself.

    You can probably see why I’m struggling to code this now….

    Any help coding this would be awesome as I’m pulling my hair out here 🙁

    Screen-Shot-2017-02-16-at-20.55.55.jpg Screen-Shot-2017-02-16-at-20.55.55.jpg
    #25353 quote
    Raul Vg
    Participant
    Senior

    I suppose you were looking for something like this:

     

    // Definición de los parámetros del código
    DEFPARAM CumulateOrders = False // Acumulación de posiciones desactivada
    
    // Condiciones para entrada de posiciones largas
    indicator1 = ExponentialAverage[8](close)
    indicator2 = ExponentialAverage[400](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Condiciones de salida de posiciones largas
    indicator3 = ExponentialAverage[8](close)
    indicator4 = ExponentialAverage[200](close)
    c2 = (indicator3 CROSSES UNDER indicator4)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Condiciones de entrada de posiciones cortas
    indicator5 = ExponentialAverage[8](close)
    indicator6 = ExponentialAverage[400](close)
    c3 = (indicator5 CROSSES UNDER indicator6)
    
    IF c3 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Condiciones de salida de posiciones cortas
    indicator7 = ExponentialAverage[8](close)
    indicator8 = ExponentialAverage[200](close)
    c4 = (indicator7 CROSSES OVER indicator8)
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    Nicolas and NDT thanked this post
    #26346 quote
    NDT
    Participant
    Junior

    Hi all,

    Thank you so much for you help! I really appreciate it. 🙂

    Unfortunately I’m still struggling with this code :(. The code very kindly created above isn’t quiet right.

    The system needs to re-enter a long or short position, if the 8ema moves back over the 200ema for a long or under again for a short. I’ve attached some examples to this thread which I hope may help me explain it a bit better.

    Is it at possible to use pro real time to create an area between two moving average or a channel and create a  “no trade area”?

    Screen-Shot-2017-02-25-at-14.03.41.png Screen-Shot-2017-02-25-at-14.03.41.png Screen-Shot-2017-02-25-at-14.10.52-copy.png Screen-Shot-2017-02-25-at-14.10.52-copy.png
    #26375 quote
    Raul Vg
    Participant
    Senior
    // Definición de los parámetros del código
    DEFPARAM CumulateOrders = False // Acumulación de posiciones desactivada
    
    // Condiciones para entrada de posiciones
    indicator1 = ExponentialAverage[8](close)
    indicator2 = ExponentialAverage[200](close)
    indicator3 = ExponentialAverage[400](close)
    
    // buy conditions
    
    // buy
    
    c1 = (indicator1 CROSSES OVER indicator3)
    c2 = (indicator1 CROSSES OVER indicator2)
    
    //sell
    
    c3 = (indicator1 CROSSES UNDER indicator2)
    
    // sellshort conditions
    
    //sell
    
    c4 = (indicator1 CROSSES UNDER indicator3)
    c5 = (indicator1 CROSSES UNDER indicator2)
    
    //buy
    
    c6 = (indicator1 CROSSES OVER indicator2)
    
    
    // LARGE
    
    IF c1 or c2 and not onmarket THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    
    IF c3 THEN
    SELL AT MARKET
    ENDIF
    
    
    // SHORT
    
    IF c4 or c5 and not onmarket  THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    
    IF c6 THEN
    EXITSHORT AT MARKET
    ENDIF
    Nicolas thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Beginner needs some help with EMA cross strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
NDT @ndt Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Raul Vg
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/16/2017
Status: Active
Attachments: No files
Logo Logo
Loading...