dynamic moving average (usd/jpy)

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #50881 quote
    DEIO
    Participant
    Veteran

    hi all,

    here a simple strategy which uses moving averages (fast and slow) that change according to volatility

    of the market.

    I pray who can to test the strategy on a bigger lapse of time.

    Avaiable for any suggestion.

    bye

    DEIO

    CROSS_MM_USD_JPY_results_2.png CROSS_MM_USD_JPY_results_2.png CROSS_MM_USD_JPY_results_1.png CROSS_MM_USD_JPY_results_1.png CROSS_MM_USD_JPY.itf crossmmusdjpyresults-1509350093cp8l4.png crossmmusdjpyresults-1509350093cp8l4.png
    #50905 quote
    Nicolas
    Keymaster
    Master

    Hi DEIO, thanks for sharing this idea with us.

    You will find here the test of the strategy realized on 200.000 bars. this is not a problem for me because as you indicated, the parameters have been optimized over a short period of time. That’s why a walk forward analysis should be conducted to test your concept of dynamic moving average periods.

    In this respect, I am surprised how you calculate them, from where does this idea come from? Even if the calculation seems “wacky” (no offense), it seems that there is a truth in the recognition of periods of range ..

    DV = AverageTrueRange[CLOSE*4](close) * CLOSE

    I “graphed” the DV variable in the screenshot below.

    usdjpy-intraday-strategy.png usdjpy-intraday-strategy.png
    #50907 quote
    Nicolas
    Keymaster
    Master

    I found why the DV variable is sometimes flat, it happens when the calculated period [CLOSE*4] is not a round number and the calculation of the indicator cannot be done. That’s why no orders could be launched at that time, so it does affect a lot the behavior of your strategy. I’m afraid that the strategy could not be validated in its current state 🙁

    The DV variable should be calculated with:

    DV = max(1,round(AverageTrueRange[round(CLOSE*4)](close) * CLOSE))
    
    return dv

    However, this could also lead us to find the right threshold to determine a range period or not.

    range-indicator.png range-indicator.png
    #50921 quote
    DEIO
    Participant
    Veteran

    Hi Nicolas,

    you are right about rounding (in the fisrt version I used it and during the tests I forgot to insert it again).

    Now I have rounded during the calculation of Averages (fast and slow):

    MMFAST= Average[ROUND(DV/12)](close)
    MMSLOW= Average[ROUND(DV/1)](close)

    On internet  I read about the  idea to generate dynamic averages…

    So my method could be a bit wacky, as you said, but my intent is to find a way to avoid that the two averages were fixed

    during the time, because if in  a certain period is good the combination (fast=2 and slow=10) in onother one is better 1 / 9 and so on..

    DV has been calculated this way in order to have the possibility to obtain the fast average value (by division by a number – the proper one is now 12 ), while  slow average remain DV (rounded  !!)   🙂

    Obviously for other crosses, parameters must be reviewed.

    Please let me know.

    bye

    dyn_cross_average_usdjpy_res1.png dyn_cross_average_usdjpy_res1.png dyn_cross_average_usdjpy_res2.png dyn_cross_average_usdjpy_res2.png dyn_cross_average_usdjpy.itf
    #50930 quote
    Nicolas
    Keymaster
    Master

    I didn’t review you code but the rounded value must be made with the averagetruerange period first, this is where is the trouble, because this is where is calculated the “dynamic” period. So DV calculation must be replaced with the version I post here.

    #50942 quote
    DEIO
    Participant
    Veteran

    hi Nicolas,

    here the code reviewed with a little modify on DV calculation (in addition to your suggestion).

    Please le t me know if in the past it works or not.

    thx again.

     

    //-------------------------------------------------------------------------
    // CROSS_MM
    // USD/JPY
    // TF 45 MIN
    //----------------------------------------------------------------------------------------
    // DV IS A VARIABLE DEPENDING ON THE VOLATILITY OF THE MARKET
    // THIS WAY AVERAGES (FAST AND SLOW) CHANGE DURING THE TIME, ACCORDING TO THE MERKET BEHAVIOUR
    //-----------------------------------------------------------------------------------------
    // 1 spread point
    // no money management applied
    //----------------------------------------------------------------------------------------
    //if you want not to keep over overnight the position remove the comment from
    // the following parameter:
    //defparam flatafter = 211500
    //-----------------------------------------------------------------------------------------
    defparam flatbefore = 071500
    SIZE = 1
    DV = max(1,round(AverageTrueRange[round(CLOSE*2.5)](close) * Average[320](close)))
    //GRAPH DV
    MMFAST= average[max(1,ROUND(DV/12))] (close)
    MMSLOW= average[max(1,ROUND(DV/1))] (close)
    
    condUP = MMFAST CROSSES OVER MMSLOW
    condDW = MMFAST CROSSES UNDER MMSLOW
    CONDUP2 = HIGH[0] CROSSES OVER high[13]
    CONDDW2 = LOW[0] CROSSES UNDER low[13]
    
    IF CONDUP AND CONDUP2 THEN
    IF SHORTONMARKET THEN
    EXITSHORT AT MARKET
    ENDIF
    IF NOT LONGONMARKET THEN
    BUY SIZE shares at MARKET
    ENDIF
    ENDIF
    IF CONDDW AND CONDDW2 THEN
    IF LONGONMARKET THEN
    SELL AT MARKET
    ENDIF
    IF NOT SHORTONMARKET THEN
    SELLSHORT SIZE shares at MARKET
    ENDIF
    ENDIF
    
    SET STOP PLOSS DV*3
    #50951 quote
    Nicolas
    Keymaster
    Master

    The strategy is no doubt overfit on the recent data (from beginning of 2016), that’s why you should make WFA when optimizing your variables’ periods.

    usdjpy-45-minutes-automatic-trading-result.png usdjpy-45-minutes-automatic-trading-result.png
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

dynamic moving average (usd/jpy)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
DEIO @deio Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Nicolas
8 years, 4 months ago.

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