long-short when Moving average changed color

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #23141 quote
    enzo_52
    Participant
    Senior

    how can i tell t0 backtest that must BUY when Quadruple Exponential Moving Average is green and sell when Quadruple Exponential Moving Average is red?

    Thanks in advance

     

    //PRC_QEMA | indicator
    //23.01.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    //--- parameters
    // period = 14
    // method = MOVING AVERAGE TYPE
    // ---
    
    Price=customclose
    
    MA1=Average[period,method](Price)
    MA2=Average[period,method](MA1)
    MA3=Average[period,method](MA2)
    MA4=Average[period,method](MA3)
    MA5=Average[period,method](MA4)
    QEMA=5*MA1-10*MA2+10*MA3-5*MA4+MA5
    
    RETURN QEMA as "Quadruple Exponential Moving Average indicator"
    #23192 quote
    Dave
    Participant
    Senior

    Hi Enzo, Nicolas did this for me a couple of weeks ago, https://www.prorealcode.com/topic/place-orders-when-a-curve-change-colour/ it is for a single ma but i’m sure the condition could be added to incorperate all types of ma as per the indicator. hope it helps.

    dave

    Nicolas thanked this post
    #23221 quote
    enzo_52
    Participant
    Senior

    thanks so much DAVe!!!

    #23248 quote
    enzo_52
    Participant
    Senior

    HI, SOME TIME WORKS ..SOME TIMES NOT….WHY?   LOOK AT THE PIC

     

    THANKS

    THE CODE IS:

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate
    
    // Condizioni per entrare su posizioni long
    
    indicator3 = CALL "MM Quatruple EXP"[cinq, uno](close)
    indicator4 = CALL "MM Quatruple EXP"[cinq, uno](close)
    c2 = indicator3 > indicator4[1] and indicator4[1] < indicator3
    
    IF c2 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    
    indicator8 = CALL "MM Quatruple EXP"[cinq, uno](close)
    indicator9 = CALL "MM Quatruple EXP"[cinq, uno](close)
    c5 = indicator8 < indicator9[1] and indicator9[1]> indicator8
    
    IF c5 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    TSS.png TSS.png
    #23275 quote
    Dave
    Participant
    Senior

    Sorry Enzo, I’m out of my office until later but try this for a buy condition:-

    C2=indicator 3>indicator 3[1] and indicator 3[1]<indicator3[2]

    Dave

    #23284 quote
    Nicolas
    Keymaster
    Master

    >> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<

    #23286 quote
    enzo_52
    Participant
    Senior

    hi DAVE, i tried..but it is the same….very strange

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate
    
    // Condizioni per entrare su posizioni long
    
    indicator3 = CALL "MM Quatruple EXP"[150, 4](close)
    
    c2 = indicator3 > indicator3[1] and indicator3[1] < indicator3[2]
    
    IF c2 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    
    indicator8 = CALL "MM Quatruple EXP"[150, 4](close)
    
    c5 = indicator8 < indicator8[1] and indicator8[1]> indicator8[2]
    
    IF c5 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    #23288 quote
    enzo_52
    Participant
    Senior

    from 1984 to dicember 2006 ok…from dicember 2006 to now  it is crazy

    TSS-1.png TSS-1.png
    #23292 quote
    enzo_52
    Participant
    Senior

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate

    // Condizioni per entrare su posizioni long

    indicator3 = CALL “MM Quatruple EXP”[cinq, uno](close)

    c2 = indicator3 > indicator3[1] and indicator3[1] < indicator3[2]

    IF c2 THEN
    BUY 1 CONTRACT AT MARKet

    // Condizioni per entrare su posizioni short

    indicator8 = CALL “MM Quatruple EXP”[cinq, uno](close)

    c5 = indicator8 < indicator8[1] and indicator8[1]> indicator8[2]

    IF c5 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF

    #23352 quote
    Dave
    Participant
    Senior

    I’ve had a look and yes it does act strangely?, I think it is something mathematical with the indicator as the line of code I posted above works fine with regular ma’s, is a quatruple ma critical to what you are doing?.

    #23379 quote
    Nicolas
    Keymaster
    Master

    @Enzo
    I’d like people to use the button INSERT PRT CODE please! I already kindly ask it to you in my previous post. Thanks.

    #23391 quote
    enzo_52
    Participant
    Senior

    sorry Nicolas..you are right…now i understood how can i do it..

    #23393 quote
    enzo_52
    Participant
    Senior

    hi Dave, i wanted insert the Qema for to trade only short when the principal trend was down and only long when the principal trend was Up…

    principal trend  with EMA 75  and ema 195  on daily TF.

     

    anyway thanks a lot

    #23466 quote
    Dave
    Participant
    Senior

    did a quick test with just an exponential ma not qema, 10K acc £10/point from 01-01-2015 to 01-01-2017.   157% not bad!. optimised came back with ema25 & ema235 with 245%.

     

    Dave

    ema75and-195.jpg ema75and-195.jpg ema25-and-235.jpg ema25-and-235.jpg
    #23605 quote
    enzo_52
    Participant
    Senior

    thanks Dave, it seem to good for to be real 🙂 anyway my strategy is rudimental, it need position size, and stop loss …. but the Qema problems does not make me get on with TS

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

long-short when Moving average changed color


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
enzo_52 @enzo_52 Participant
Summary

This topic contains 23 replies,
has 5 voices, and was last updated by Dave
9 years ago.

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