Optimization moving average crossing strategy with “machine learning”

Optimization moving average crossing strategy with “machine learning”

This is a “machine learning” strategy for finding the best crossing strategy, comparing 70 different averages with each other, given a certain time frame and a certain market.

(The source of the very most of the averages is https://www.prorealcode.com/prorealtime-indicators/average-filter-regression/ posted by Laurenzo in 2017)

The strategy is simple:
If the first average crosses above the second average, go buy long
and vice versa if the first average crosses under the second average, sell short

It can be used for currencies and indices, presumably also for stocks (non-daytrading)

This strategy determines which of the 70 different averages is to be crossed with which of the same 70 different averages to give the best result in a certain market in a certain time frame, what in my opinion can be seen as a kind of  “machine learning”

Further added to this strategy:   (up to the user to adjust those variables if wanted)

  1. to protect the position, a stop loss (TSL) is added  (coded TSL = round(100/10000*close))
  2. exit a position every day at 16:00 hr (coded Defparam Flatafter = 160000) (Daytrading)
  3. limit to only one trade per day  (coded OTD = Barindex – TradeIndex(1) > IntradayBarIndex, If using “TradeIndex(3)”, it would allow 2 opening trades per day, TradeIndex(5) would allow 3 trades per day, and so on.
  4. Opening trades only between 8:00 and 11:30, for American trades other times can be set.

There are 70 different types of averages, (listed below), which are used to cross each other (the first is named MAType, to be crossing the second MATypeV2)

To limit zigzagging of the averages due to market noise, an exponential average of 30 is added before the crossing condition is measured (Coded as wAFR = exponentialaverage[30](AFR) and wAFRv2 = exponentialaverage[30](AFRv2))

To limit the possibilities, the period is set for all average-types to 15 (Coded as Period = 15, Period2 = 15), periods may be adjusted.

Different stop distances can be used or a trailing stop can be used.

Be aware that if you use this “machine learning” on a small set of data, the outcome will be over- fitted and a different optimized set of averages for a different small set of data will appear (this happens with all strategies, robustness of the strategy has to be tested).

Be aware when running the given strategy, already 70 x 70 combinations has to be optimized, which is already 4.900 combinations, which makes the optimizing process (very) slow. It might be a good idea to split the combination into 5 sets, lets say from 0 to 13 averages comparing to the 69 averages, and next 14 to 26 comparing to 69 averages, and so on, then taking the best from the 5 sets.

I run the code first without In Sample/Out of Sample, to find the  top 10 best average combinations, and around those top 10  run several In Sample/Out of Sample optimizations.

For In Sample/Out of Sample optimizations use 66% IS and 34% OOS, non repeated (not five runs)

The code is extremely long (> 3.600 lines), due to defining 70 and 70 different averages. Maybe it can be coded shorter ?

The crossing strategy itself can be found at the last rows !

I was not aware that PRT allows more then 3.600 lines of code as a strategy!

  1. Ahrens Moving Average
    1. Adjustable Lag FIR
    2. Arnaud Legoux Moving Average
    3. 2-Pole Butterworth Smoothing Filter
    4. 3-Pole Butterworth Smoothing Filter
    5. Corrected Moving Average by A.Uhl
    6. d9 Unscented Kalman Filter (Responsiveness Version)
    7. d9 Unscented Kalman Filter
    8. Double Exponential Moving Average
    9. Exponential Least Square Moving Average
    10. Exponential Moving Average
    11. Elastic Volume Weighted Moving Average
    12. Fast Adaptive Trend Line
    13. Fractional-Bar Quick Moving Average
    14. Fractal Adaptive Moving Average
    15. Generalized DEMA
    16. 1-Pole Gaussian Filter
    17. 2-Pole Gaussian Filter
    18. 3-Pole Gaussian Filter
    19. 4-Pole Gaussian Filter
    20. Hull Moving Average
    21. IE/2 Combination of LSMA and ILRS
    22. Integral of Linear Regression Slope
    23. iTrend by John Ehlers
    24. Jurik Moving Average (Responsiveness Version)
    25. Jurik Moving Average
    26. Kaufman Adaptive Moving Average
    27. Kalman Filter by John Ehlers
    28. Kalman Filter (Responsiveness Version)
    29. Kalman Filter
    30. Leader Exponential Moving Average
    31. Laguerre Filter by John Ehlers
    32. Least Square Moving Average
    33. McGinley Dynamic
    34. Middle High Low Range Moving Average
    35. McNicholl Moving Average
    36. Non Lag Moving Average (Responsiveness Version)
    37. Non Lag Moving Average
    38. One More Average
    39. Pentuple Exponential Moving Average
    40. Parabolic Weighted Moving Average
    41. Quadruple Exponential Moving Average
    42. Regularized EMA by Chris Satchwell
    43. Reference Fast Trend Line
    44. Reference Slow Trend Line
    45. Slow Adaptive Trend Line
    46. Simple Moving Average
    47. 2-Pole Super Smoothing Filter
    48. 3-Pole Super Smoothing Filter
    49. Smoothed Simple Moving Average
    50. Sine Weighted Moving Average
    51. T3 Moving Average
    52. Triple Exponential Moving Average
    53. Triangular Moving Average
    54. Time Series Average
    55. Variable Index Dynamic Average
    56. Variable Moving Average
    57. Volume Weighted Average Price
    58. Wilder Moving Average
    59. Weighted Least Square Moving Average
    60. Weighted Moving Average
    61. Zero Lag BMT
    62. Zero Lag Double Exponential Moving Average
    63. Zero Lag FIR Filter
    64. Zero Lag IIR Filter
    65. Zero Lag John Ehlers
    66. Zero Lag Weighted BMT
    67. Range based AV high + STD – low – STD
    68. Average highest [period] and lowest[period]
    69 DEMA adjusted by itself

Please download the attached itf (200308-Averages-crossing.itf) to play around with this strategy.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. criscolci • 234 days ago #

    Wow!

  2. MaoRai54 • 233 days ago #

    hello Jan,
    this is a fantastic idea but, as per I understood looking into the system, I think it cannot work as an automatic program. I mean that

  3. MaoRai54 • 233 days ago #

    hello Jan,
    this is a fantastic idea but, as per I understood looking into the system, I think it cannot work as an automatic program. I mean that the program is testing the 69+69 options but once it has ended you’ll have 2 fixed numbers as variables. Then you can use it in automatic run. So the variables chosen are referring only to the moment of the test. Am I right?

  4. Jan • 233 days ago #

    Yes, that is correct, it helps you select the 2 best kind of averages (out of 70), based on past data, given a market and given a time frame. Then after proper testing, you let the algo running on future market data with this setting.

    • kvsagar • 14 days ago #

      Thanks for sharing this Jan, I have following settings and winning rate is 70% on 30mins – GBPUSD pair,

      DEFPARAM cumulateOrders = False // Cumulating positions deactivate
      Defparam flatafter = 160000 //close the position at 16:00 (day trading) /could be switched off

      once StartE = 080000 //start time for opening positions
      once StartL = 113000 //ending time for opening positions (only trading in the morning)
      once N = 1 // number of contracts

      once Period = 15 //period1 // // set fixed to limit possible combinations of optimisations
      once Period2 = 15 // period2 second set of 69 averages // // set fixed to limit possible combinations of optimisations

      MAType = 5
      MATypeV2 = 10

      Series = (open+high+low+Close)/4 // kind of close of a bar
      Seriesv2 = (open+high+low+Close)/4 // kind of close of a bar

      OTD = Barindex – TradeIndex(3) > IntradayBarIndex // limits the (opening) trades till x per day (OTD One Trade per Day)
      TSL = round(50/10000*close) // dynamic trailing stop loss 0.5 %

  5. MaoRai54 • 233 days ago #

    OK Jan, do you see a way to let it test and run in automatic mode? something like a loop that anytime is testing the best variables

  6. Jan • 233 days ago #

    Interesting discussion.
    This algo will be based upon optimal settings, given past data, then assuming the past pattern of data will be repeated, or at least be repeated so much that it delivers profitable trades for the future.

    If the model would be using something like a loop that anytime it is testing the best variables, the measures have to be based upon the (short term) past, as future prices still have to come. . .
    The question is then of course: will the continuously (short term) past optimal crossing deliver better results for future trading than a setting based upon long term historical data or not ?

    If you want something like a loop that anytime is testing the best variables, you do NOT need to have 70 averages to test every time, a simple average compared with the close would already be sufficient and then let the system calculate the best average crossing based upon the last (for example) 40 bars every time. As said the concept is then based upon the assumption that the continuously measured (short term) price movements better predict future price movements as fixed settings, based upon many price movements over a long term. If you or anybody else know more about this, please let me know.

    • hudavlasti • 199 days ago #

      Is there any configuration for this system that tests the best variables

  7. MaoRai54 • 233 days ago #

    Jan, I’ve understood. Maybe in standard conditions it’s better to test the algo on the maximum time period. But in this period of coronavirus I think, even if we are always testing on past data, it would be better to test on a short period. In fact I’ve tested it for Eu/$ and Dax on 5 minutes base in the period 2march up today and I got gorgeous results with 100% winning trades. While I’m now testing them on 5m and 100.000 and I see only 50%-60% of winning and a low average earning value. If this volatily period will continue I think your algo is really amazing.!!!!

    • kvsagar • 16 days ago #

      Hi MaoRai54, Did you manage to set the variables in AutoTest, I am trying to create AutoTrading and it’s giving variable errors. Thanks

  8. frenqle • 233 days ago #

    Been playing around with this awesome code!!!
    where can i adjust the matype? i removed the variables allready.. but im a bit stuck.. my coding knowledge only goes soo far.
    because it wont let me prepare for auto trade?

  9. MaoRai54 • 233 days ago #

    Frenqle, if you remove the variables without fixing their values you cannot go for auto trade

  10. Jan • 233 days ago #

    Just delete MAType and MATypeV2 at Optimization parameters (straight above the first line of the code)

    Then type in the code
    Once MAType = what you want to select
    Once MATypeV2 = what you want to select

    Just a common warning, which is valid for every algo-strategy: make sure it is robust and properly tested, including In Sample and Out of Sample testing.

  11. frenqle • 233 days ago #

    dankjewel jan!!

  12. bertrandpinoy • 232 days ago #

    i can t make it work for real, can you better details the process please

    • bertrandpinoy • 231 days ago #

      hi Juan, yes of couse the file is imported. can you send sreenshoot of the process? i m blocked..

  13. Jan • 232 days ago #

    Could ypu be more specific ?
    Have you imported the itf-file already ?

    For let the strategy run (after importing the file):
    Just delete MAType and MATypeV2 at Optimization parameters (straight above the first line of the code)

    Then type in the code
    Once MAType = what you want to select
    Once MATypeV2 = what you want to select

    Hope it helps.

    • Jan • 231 days ago #

      Hi bertrandpinoy
      Where exactly are you blocked ?
      If you import the file, you can, given a time frame and a larger period, determine which crossing(s) of 2 averages gives the best results (like a top 10).
      Next step is to test this upon another set of data, see if the optimum averages varies significantly or not from the previous test.
      And then do an In Sample test of 66% and an Out of Sample Test with 34%, to determine if the best crossings of averages remain the same with the first test. You may restrict the chooseable averages to decrease the time for running this test.
      If you find your best 2 averages, follow the steps as I described below.
      Hope it helps you out.
      KR Jan

    • bertrandpinoy • 230 days ago #

      Hello Juan I manage to make very promising backtets. unfortunately I fail to launch the program in real mode, what a pity. Certainly my amateurism in the use of variables. damage.Maybe you can attach an ITF file that allows actual use on the CAC40?

  14. jevve • 231 days ago #

    Hi Jan

    How do i make it run Automatic trading. I get this message “Replace variables with specific values”?
    I guess its the the statement you made above, but i still cant get it right!?
    Thanks

  15. Jan • 231 days ago #

    Hi Jevve,
    yes, it is certainly the message above. KR Jan

  16. jevve • 231 days ago #

    Hi Jan
    After deleting the MAType and MATypev2 in the optimization, i then must type in the code
    Once MAType = what you want to select
    Once MATypeV2 = what you want to select

    But where exactly in the code should i type it in?
    thanks

  17. Jan • 231 days ago #

    Hi Jevve,
    Once MAType = 15 that is one of the moving averages of 0-69
    Once MATypev2 = 25 that is one of the second range of moving averages of 0-69

    Just a common warning, which is valid for every algo-strategy: make sure it is robust and properly tested, including In Sample and Out of Sample testing, before letting it trade automatically with real money.

    • frenqle • 231 days ago #

      which variables should i fill in for in and out of sample? i dont understand these labels and maximum and minimum area’s?

  18. Jan • 231 days ago #

    Hi Jevve,

    Sorry, just to answer your question: you can type it just below the defined periods, like line 29 in the code. (It has to be coded above all the definitions of the 70+70 averages)
    KR Jan

    • Jan • 231 days ago #

      Hi Frenqle,

      Determine which crossing(s) of 2 averages gives the best results (like a top 10), without In Sample Out of Sample turned on.
      (Next step is to test this upon another set of data, see if the optimum averages varies significantly or not from the previous test.)
      And then do an In Sample test of 66% and an Out of Sample Test with 34%, with 1 iteration) to determine if the best crossings of averages remain the same with the first test. You may restrict the chooseable averages (range 0-69 and 0-69) to a smaller range which fits around your best results, to decrease the time for running this test. (Check in the code of the chosen range are somewhere the same sort of averages as the best crossings)
      If the IS/OOS values of averages which is in fact based upon optimizing 66% of the first test set of data, varies significant from the averages chosen averages from the first set, it seems that the crossing is over fitted. This is only true,when the averages from the IS/OOS significantly differ from initial test.
      Hope it helps you out. En een goed weekend
      KR Jan

  19. darbes • 231 days ago #

    interessant : comment faire pour l’utiliser en live (message erreurs sur les variables) ?

  20. darbes • 231 days ago #

    Interesting : how to make it working in pro order (error message due to variables) ?

  21. Jan • 231 days ago #

    See comments above at answers at questions from Jevve, and I should do some additional testing and In Sample Out of Sample, as answered to questions of Frenqle, hopes it helps you out .
    A good weekend.
    KR Jan

  22. Marcus Quartus Aurius • 227 days ago #

    Thank you Sir ! it’s amazing code.

  23. frenqle • 225 days ago #

    Dear Jan, i managed to test your code and put it into automatic trading.. it runs for a few minutes and then it quits without any reason.. do you care to have a look?

    • bertrandpinoy • 225 days ago #

      Hello Frenqle, would you be so kind as to send me the working ITF file please? I can’t make it work myself…thank you in advance.

    • gkjefferys • 219 days ago #

      Hello Frenqle if possible please could you also send me the working ITF file please … I also can’t make mine work…Thank you very much
      gkjefferys@gmail.com

  24. Jan • 225 days ago #

    Hi Frenqle

    maybe it has to do with the stop loss setting. Normally when it stop in auto trading there is a warning sign at that strategy, if you click on that, maybe it gives a reason why it stopped.

    Generally speaking, in this volatile markets, stops of 1 % are very often stopped out too soon.
    Also in this very very volatile market, trending strategies often do not work (for example today Dow at opening – 3% and then 40 minutes later +1% is not to say trending)

    • frenqle • 225 days ago #

      Hi Jan,
      It just closes without a reason. Even in the report, it says nothing. it does not give any reason.
      Very weird, Can I send you the code?

  25. darbes • 225 days ago #

    I put line 29 the Matype and Matypv2 = to optimized level but still to go to live pro order is asking to remove variables. Which variables are involved ?

    • frenqle • 225 days ago #

      Hi Jan, It just closes without a reason.. even in the report it says nothing.. it doesnot give any reason

    • Jan • 224 days ago #

      Hi darbes,
      Did you delete MAType and MATypeV2 at “Optimization parameters” (straight above the first line of the code)

    • Jan • 224 days ago #

      The topic nontheless has opened, is https://www.prorealcode.com/topic/optimization-moving-average-crossing-strategy/

      frenqle, you can add your version of the code over there, then I will have a look why it stops in automatic trading.
      KR Jan

  26. nonetheless • 224 days ago #

    I opened a topic in the ProOrder forum to make discussion of this easier. Also uploaded 3 algos created with this amazing tool – thanks Jan!

  27. darbes • 224 days ago #

    Sorry Jan,
    Code is starting with Defparam, I do not find optmization. Where could I desactivate it ?
    Best JC

  28. darbes • 224 days ago #

    Hi Jan
    It is OK I found it
    Best

  29. gkjefferys • 221 days ago #

    Once MAType = 15 that is one of the moving averages of 0-69
    Once MATypev2 = 25 that is one of the second range of moving averages of 0-69

    Please can you tell me where i find this … what lines
    thanks very much

  30. darbes • 219 days ago #

    Hi Jan
    I have put live the strategy and so far so good 3 winning deals over 3> But why did you choose to exit position at 4PM. It is not adding an additional closing risk instead of a take profit ?
    Best
    JC

    • Jocke • 187 days ago #

      Hi darbes can you share the code you are using I cant get it to work in auto.
      And great work Jan

  31. Jan • 218 days ago #

    Hi gkjefferys, the lines can be found somewhere at the top cq must be added somewhere at line +/-15 if that answers your question.

    Hi Darbes, exit 16:00 hrs is daytrading, you can whipe that out, but that increase your risk, but also can increase your profit, be aware of overnight interest costs of the CFD you trade

  32. darbes • 218 days ago #

    I see. An alternative to take profit is to reduce on forex the TSL below 1% as forex vol is lower during the day. I will first work on this side to avoid closing position in a lottery way at 4PM.

  33. J. • 214 days ago #

    Very interesting Jan, thank you for sharing. This could be a template for many ‘machine learning’ solutions in PRT, I’ll go and see if I can tweak some things, maybe make the code shorter, or add in other indicators while I’m in quarantine :).

    • nilsla1981 • 208 days ago #

      Hi J., any progress? Greetings from Germany.Nils

  34. jmf125 • 211 days ago #

    Thank You for sharing that code Jan. One quick question any specific reason why you selected 15 as period and period2. Why these specific values ? And why not different values ?

  35. Jan • 208 days ago #

    The source of the very most of the averages is from Laurenzo, he used 15 as a standard average. https://www.prorealcode.com/prorealtime-indicators/average-filter-regression/ posted by Laurenzo in 2017

  36. Jan • 208 days ago #

    I have added the Close itself as an 71th “average”

  37. nilsla1981 • 207 days ago #

    Can I make the average lines visible in a chart? How can I see in the code what is the valid averages for buy and sell?

    • Jan • 200 days ago #

      Yes you can, please find the code at https://www.prorealcode.com/topic/optimization-moving-average-crossing-strategy/page/4 as mentioned before the averages are posted by posted Laurenzo in 2017

  38. sebastien4484 • 206 days ago #

    Hi, if you fix MAType=45 and MATypeV2=1, on EUR/USD 15min, backtest on 100 000 units, you get a pretty good linear curve. And as the variables are all fixed, in theory it is possible to launch it in automatic trading.

  39. danistuta • 205 days ago #

    ProRealtime 11 says error code line 24: once StartL = 113000, how to fix? Thank you.

    • Jan • 200 days ago #

      Sorry to hear, I just tested the attached itf file in version 10.3, it works fine there. I did not use version 11 yet, not sure what is going wrong. Could you reload the original itf here again and try again ? As it works in 10.3, why should it not work in 11?
      which timeframe do you use ? Do you get the error in the 5 minutes timeframe as well ?

    • Jan • 200 days ago #

      sebastien4484 Have you also found the results with some In Sample/Out of Sample testing, like 66% IS 34% OOS ?

  40. Oliviertrader2020 • 177 days ago #

    Excellente idée ! Je vais m’en servir comme base intellectuel pour réfléchir au test qui pourrait être fait entre différents indicateurs, différents règlages, et différentes bougies.

  41. Jan • 175 days ago #

    Obviously more averages (then the 70 in the strategy) are thinkable, and could be added, I would add the close itself also.

    Coded the Close itself below
    And
    Averagetruerange[Period](Averagetruerange[Period](Close))
    Averagetruerange[Period*2](Averagetruerange[Period*2](Close))

    To be added for both MAType en MATypeV2, coded below for MAType,

    ========FIRST AVERAGES AFR========================================

    IF MAType = 70 THEN

    Period = MAX(Period, 1)
    IF BarIndex < Period THEN
    AFR = Series
    ELSE
    AFR = Averagetruerange[Period](Averagetruerange[Period](Close))
    ENDIF

    ENDIF

    IF MAType = 71 THEN

    Period = MAX(Period, 1)
    IF BarIndex < Period THEN
    AFR = Series
    ELSE
    AFR = Averagetruerange[Period*2](Averagetruerange[Period*2](Close))
    ENDIF

    ENDIF

    IF MAType = 72 THEN

    AFR = Close
    ENDIF

    ========SECOND AVERAGES AFRV2=========================

    IF MATypeV2 = 70 THEN

    Period2 = MAX(Period2, 1)
    IF BarIndex < Period2 THEN
    AFRV2 = SeriesV2
    ELSE
    AFRV2 = Averagetruerange[Period2](Averagetruerange[Period2](Close))
    ENDIF

    ENDIF

    IF MATypeV2 = 71 THEN

    Period2 = MAX(Period2, 1)
    IF BarIndex < Period2 THEN
    AFRV2 = SeriesV2
    ELSE
    AFRV2 = Averagetruerange[Period2*2](Averagetruerange[Period2*2](Close))
    ENDIF

    ENDIF

    IF MATypeV2 = 72 THEN

    AFRV2 = Close
    ENDIF

  42. Jan • 175 days ago #

    Another try:

    Obviously more averages (then the 70 in the strategy) are thinkable, and could be added, I would add the close itself also.
    Coded the Close itself below And
    Averagetruerange[Period](Averagetruerange[Period](Close))
    Averagetruerange[Period*2](Averagetruerange[Period*2](Close))

    To be added for both MAType en MATypeV2, coded below

    ========FIRST AVERAGES AFR========================================
    IF MAType = 70 THEN
    Period = MAX(Period, 1)
    IF BarIndex < Period THEN
    AFR = Series
    ELSE AFR = Averagetruerange[Period](Averagetruerange[Period](Close))
    ENDIF
    ENDIF
    IF MAType = 71 THEN
    Period = MAX(Period, 1)
    IF BarIndex < Period THEN
    AFR = Series ELSE AFR = Averagetruerange[Period*2](Averagetruerange[Period*2](Close)) ENDIF
    ENDIF
    IF MAType = 72 THEN
    AFR = Close
    ENDIF
    ========SECOND AVERAGES AFRV2=========================
    IF MATypeV2 = 70 THEN
    Period2 = MAX(Period2, 1)
    IF BarIndex < Period2 THEN
    AFRV2 = SeriesV2
    ELSE AFRV2 = Averagetruerange[Period2](Averagetruerange[Period2](Close))
    ENDIF
    ENDIF
    IF MATypeV2 = 71
    THEN Period2 = MAX(Period2, 1)
    IF BarIndex < Period2 THEN
    AFRV2 = SeriesV2
    ELSE AFRV2 = Averagetruerange[Period2*2](Averagetruerange[Period2*2](Close))
    ENDIF
    ENDIF
    IF MATypeV2 = 72 THEN
    AFRV2 = Close
    ENDIF

  43. danistuta • 173 days ago #

    Hi, thank you…now it works with prorealtime 10.3:-) I’d like test on EUR/USD…could you suggest a winning setup?

    • Jan • 157 days ago #

      Just run the code for this pair, make sure you have the right spread filled.
      What you could do is running it for 100.000 bars, without IS/OOS setting. With the something like 10 most profitable crossings, make a IS/OOS run (usually I choose 66% IS/34 OOS) (this can change the profitability significantly !) by selecting the outcome-ranges of the first and second averages from the presented (+/- 10) most profitable crossings.
      Alternatively you could run an IS/OOS test run immediately on the 100.000 bars, but the disadvantage is that only 1 setting is presented as an optimum, not a range. I would like to see more seemingly profitable settings, that ‘s why I would like to start without IS/OOS first. But the IS/OOS testing is absolutely a necessary step in developing a (somewhere) robust trading strategy.

  44. oxy75 • 147 days ago #

    Hello. I understood that we were waiting to choose two values ​​between 0 and 69 for the two variables, but I don’t understand how and where we should indicate these values. Thank you for your help.

    EDIT : Ok I just understood. After adding the value: Once MAType = XXX
    Once MATypeV2 = XXX you must save and relaunch the application.

  45. Roi Aglipa • 142 days ago #

    Hi, Any way to project those 2 chosen averages (see below) on the chart?

    “Once MAType = what you want to select
    Once MATypeV2 = what you want to select”

    • Jan • 103 days ago #

      Hi Roi Aglipa,

      A bit late response on my site, Yes , you can project 2 averages, please find the indicator at https://www.prorealcode.com/topic/optimization-moving-average-crossing-strategy/ at page 12, as here I can not attach the ITF file.
      import the ITF file, then you should be able to select the indicator with two MA types.

  46. Adante79 • 119 days ago #

    Hi Jan, tried to test this on Auto… but it’s coming up with an error? Is it possible to upload an Autotrader version without the “Once MAType”? Thanks.

    • Jan • 103 days ago #

      Hi Adante79
      I hope you have already found your answers
      for autotrade, the variables has to be set fixed
      like in the code somewhere at line 20
      Once MAType = 15 that is one of the moving averages of 0-69
      Once MATypev2 = 25 that is one of the second range of moving averages of 0-69

      Propoer testing is necessary !! I have good experiences to avoid unexpected losses, in setting a strategy “live” in Demo for at least one month.

  47. Jan • 103 days ago #

    Also the variables on top ( var1 0-69 and var2 0-69), those variables are needed to determine the best crossing and are not in the code, has to be deleted for Auto Trading

  48. Jan • 93 days ago #

    It might be a good idea to reduce the average to 15 instead of 30 to reduce market noise effects, especially at higher timeframes. “To limit zigzagging of the averages due to market noise, an exponential average of 30 is added before the crossing condition is measured (Coded as wAFR = exponentialaverage[30](AFR) and wAFRv2 = exponentialaverage[30](AFRv2))”

  49. oliverkeim • 62 days ago #

    Hello, Please can you help. I use 10.3 and are not able to set the strategy live.
    “Folgende Veränderung müssen vor der Übermittlung des Codes an Proorder vorgenommen werden: Ersetzen Sie die Variable durch spezifische Werte. ( MA Type is set 10 & 30)
    Thanks
    Olli

  50. lisamitch50 • 4 days ago #

    Hi Jan, wondering i you can help please, can you let me know how i now implement the strategy the system has found please.
    Great code by the way and would LOVE to talk to you more about it. Please let me know if we can chat about it more. But i am struggling to “Use” the strategy that i feel fits my portfolio and way.. Many thanks.

  51. fleglo • 2 days ago #

    Hello Jan, thank you very much for this tremendous and huge work done.
    It is really a fantastic time saving. After filtering here and there and adjusted to my creterias, it works properly. Thanks again for the time saving.
    Bravo!
    Fred

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+29 more likes

Related users ' posts
willi Ich habe meinen Fehler gefunden: Das lambda war für meine eingestellte Zeiteinheit zu groß g...
Fabian Hi Nicolas, do you plan to release this indicator in version 10.3 as well or is this not ...
Nicolas No because it needs arrays! :)
KarlBenjamin Thankyou so much Nicholas! Hopefuly this is the last piece of the puzzle. Many thanks!
Juan Gonzalez Que buen contenido! No tienes alguno que me permita operar Order Flow? Gracias
XXXXVII Fixed ITF Trend Background //Indicateur CCI ID2 = CCI[50] => 60 ID3 = CCI[100] => 60...
Sanglier thanks ! i have been looking forward to find something like this
Screw27 Hi man, I installed the indicator and i don't know why but my graph it is so big
HelixKing sounds interesting I'll take a look
Darren Nash Thanks Souhail, in the end i just copy/paste the logic with variables and it works. I rem...
Darren Nash One thing to note also for DOW trading if using IG, change the buy/sell qty from 1 to 2
mostafa samady How can I optimize it for DAX 30? Thanks!
born2trading hello Nicolas, sorry for off-topic question, but can you tell me what kind of indicator you ...
Nicolas Not an indicator but an option in PRT v11.
Screw27 Salut nicolas j'aimerais savoir tes résulats grace a cettte methode
pyhrus Pourriez-vous nous proposer une version adaptée pour PRT V13.0 , ou nous préciser les instr...
pyhrus Erratum : je veux parler de la version V10.3 , bien sur ...
pyhrus P.S : IG , que j'ai contacté ,m'indique que la version V11 , ne sera pas disponible avant un...
Nicolas Bien sûr, pourquoi pas ?
ribes65 Bonjour Nicolas, Merci pour votre travail. Est-il envisageable de créer un screener pour ...
Nicolas Bien sûr, merci de formuler une demande dans le forum des screeners pour prorealtime. En res...
Nicolas Poni qui la tua domanda se è correlata a questo indicatore, altrimenti apri un nuovo argomen...
PhilipSchultz Hi Nicolas, can i backtest this indicator? And if so, how do i do it? I have tried, but don´...
Nicolas Sure, use the forums to create a new topic to ask for it Please respect the posting rules ...
Nicolas How to import file page: in the help section of the website explains howto
kenssa import through the indicator page/window in the Proreal time
chicoteca Buenas, no consigo que se me muestre en el chart de DAX. ¿Cómo procedo? Gracias.-
Stockastiss Can this code be simply transferred into Backtestingcode so one doesnt need to use call ? (i...
Vonasi Sorry for the late reply. Add the code to your strategy and remove line 5 and line 39. Chang...
swedshare You got some potential here. A couple of things I think about: 1, The opening hours in this...
phoentzs Ich habe hier mit Spread 2 gerechnet, also etwa dem Mittelwert zwischen Tag und Nacht. Das G...
phoentzs Hab festgestellt, das US500 fast noch besser funktioniert als der Dax. Was aber auch daran l...
leofi https://www.prorealcode.com/topic/simple-average-with-visual-color/
leofi Go visit www.prorealcode.com/topic/simple-average-with-visual-color/ and watch 2em post
Dritan Hi,I am new on Prorealtime and coding.I downloaded the indi but I have it on a separate wind...
Alps007 Hi Nicolas. Happy New Year. Can you please program me several MACD divergence screeners ...
Arlei Zanin Hello Nicolas, would it be possible to convert the Cloud to Pascal language? Thank you.
ashee i want it in MT4
Nicolas You should open a new topic to discuss about the strategy and its coding.
dvlukic Hello Nicolas, How could plot this indicator over the price series? Thanks Dave
Nicolas Just add it on the price series.
Byggtrader Hi Nicolas! How do I get the indicator in the price chart? It only stays under i new chart.
Nicolas Just add it on the price chart by using the wrench on the left upper side of the chart (pric...

Top