# 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)
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
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
13. Fractional-Bar Quick 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
27. Kalman Filter by John Ehlers
28. Kalman Filter (Responsiveness Version)
29. Kalman Filter
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
42. Regularized EMA by Chris Satchwell
43. Reference Fast Trend Line
44. Reference Slow 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]

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?

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

1. • 03/10/2020 #

Wow!

2. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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.

• • 03/10/2020 #

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

TSL = round(50/10000*close) // dynamic trailing stop loss 0.5 %

5. • 03/10/2020 #

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. • 03/10/2020 #

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.

• • 03/10/2020 #

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

7. • 03/10/2020 #

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.!!!!

• • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

10. • 03/10/2020 #

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.

• • 03/10/2020 #

Hi Jan.
Is there any way to help us find a developer to program an algo-strategy for automatic trading?

11. • 03/10/2020 #

dankjewel jan!!

12. • 03/10/2020 #

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

• • 03/10/2020 #

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

13. • 03/10/2020 #

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.

• • 03/10/2020 #

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

• • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

16. • 03/10/2020 #

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. • 03/10/2020 #

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.

• • 03/10/2020 #

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

18. • 03/10/2020 #

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

• • 03/10/2020 #

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. • 03/10/2020 #

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

20. • 03/10/2020 #

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

21. • 03/10/2020 #

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

• • 03/10/2020 #
22. • 03/10/2020 #

Thank you Sir ! it’s amazing code.

23. • 03/10/2020 #

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?

• • 03/10/2020 #

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.

• • 03/10/2020 #

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. • 03/10/2020 #

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)

• • 03/10/2020 #

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. • 03/10/2020 #

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 ?

• • 03/10/2020 #

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

• • 03/10/2020 #

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

• • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

28. • 03/10/2020 #

Hi Jan
It is OK I found it
Best

29. • 03/10/2020 #

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. • 03/10/2020 #

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

• • 03/10/2020 #

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

31. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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 :).

• • 03/10/2020 #

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

34. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

37. • 03/10/2020 #

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?

• • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

• • 03/10/2020 #

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 ?

• • 03/10/2020 #

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

40. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

• • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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”

• • 03/10/2020 #

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. • 03/10/2020 #

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.

• • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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. • 03/10/2020 #

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

52. • 03/10/2020 #

Hi Jan! In your opinion is it possible to set an instruction that every day, at a certain time f.e. 07am, automatically set the best value for the day?

• • 03/10/2020 #

Some late response of my site: same kind of question also asked in the beginning by MaoRai54,
Your idea is to quasi optimise the “best” crossing every day. Therefore you should also determine the period to be back-tested every day.
Please bear in mind that a short period with only a few trades is not very reliable, a different period with more trade may give completely different best crossings.

The main assumption is that the / a short last period gives the best guidance for short term future movements, which I tend to believe is true.

Program code concept could be as follows (not worked out yet), maybe the community gives excellent tips.
When time = 70000 then
Do for x bars backwards until now (period choosen for optimise crossing)
For Avg1 to Avg 67 do
For Avg21 to Avg2 67 do
determine trade result for the period, given the crossing
Next
Next

Select Avg and Avg2 which have given the best trade result

Run the av crossing trading algo with the daily selected best Avg and Avg2

Be aware that running this kinds of code could be (terrible) slow ! This is true if you test this, I have not yet tested it in a strategy.

Lots of discussion can be found at topic https://www.prorealcode.com/topic/machine-learning-in-proorder/

53. • 03/10/2020 #

To activate it, I read that I have to remove the first 2 rows of code MATV1 and MATv2 …
I can’t figure out where I am and if I need to delete the whole row or replace with other parameters
Can you paste the code exactly by mentioning the line numbers?
Thanks

• • 03/10/2020 #

Sorry,
I found where I need to set MatV1 and 2
But to have it exactly identical to the BackTest with the 69 averages, how should I set it?

54. • 03/10/2020 #

Thank you for that amazing program ! 🙂

55. • 03/10/2020 #

bonsoir
comment faire les tests In Sample et Out of Sample.? je ne comprend pas le sens

56. • 03/10/2020 #

I would be surprised if this is anything but datamining TBH but i will have a play and see what we find .

57. • 03/10/2020 #

Hello Jan, thanks for your amazing work! 🙂

I have one question: How much data have you found to be most efficient for optimizing the model? 1 – 2 months or longer?

58. • 03/10/2020 #

Jan, hello and congratulations!
This algo-strategy works wonderfully for time-frames longer than 5 minutes.
Help: How do I use it in “real trading mode” with ProRealTime version 11.1 for auto-trading?

59. • 03/10/2020 #

Dear Jan,
I just tested the code and manage to follow the whole process except that I am blocked at this last step (as many of us it seems).
I use PRT V11.1.
Could you please let me know what has to be corrected in line 22 ? See attached picture for details

BR
Philippe
[url=https://postimg.cc/1fcBLjJj][img]https://i.postimg.cc/SNHPz08k/temp.png[/img][/url]

60. • 03/10/2020 #

https://postimg.cc/1fcBLjJj

61. • 03/10/2020 #

Found the needed correction, just send the 2 Defparam lines at the very begining of the code, then no more error.

https://ibb.co/SmhxqBp

• • 03/10/2020 #

Bonjour Filoutube, je suis également bloqué comme vous mais votre dernier lien de photo avec la solution ne fonctionne pas. Pourriez vous m’aider ? Merci bcp !

62. • 03/10/2020 #

I have now played around with this strategy for a while and my gut feeling is that it suffers from over-optimization. If you evaluate all the possible combinations you will find many that give fantastic results, but none of them provided any meaningful robustness upon closer inspection. So, did any of you find any combination on any index/time frame that provided you with any robustness?

63. • 03/10/2020 #

It is a very nice idea, I have taken so many ideas

64. • 289 days ago #

Hi There.. It seems the TSL stop loss is not working.. it does not respond is that correct?

65. • 156 days ago #

Per lasciare che la strategia venga eseguita (dopo aver importato il file):
Basta eliminare MAType e MATypeV2 ai parametri di ottimizzazione (direttamente sopra la prima riga del codice)

Quindi digitare il codice
Once MAType = ciò che si desidera selezionare
Once MATypeV2 = ciò che si desidera selezionare

Spero che ti aiuti.
Ho letto questo post e avendo lo stesso problema, chiedo dove si trova MAType e MATypeV2, io non riesco a trovarlo.
Grazie

Register or

#### Likes

+57 more likes

Related users ' posts
Nicolas
2 months ago
3
Indicators
Hi Nicolas, thaks for your great work here, I need a scanner for the swedish OMX when ma...
Yes, sure please open a new topic in the ProScreener forum section, thank you.
Hello! Thanks for post your indicators. I'd like you to let me know how to draw lines for ...
Nicolas
4 months ago
3
Indicators
Hi Nicolas! I can´t install this indicator. it installs in a separate window not as an av...
No consigo instalarlo en el precio en PRL-version 10
Jiacky
6 months ago
0
Indicators
Sever
12 months ago
0
Indicators
Sever
1 year ago
2
Indicators
Hi Sever, how can I visualize the coloured areas?
Hi Stenozar, You need to add the color zones yourself , just go to Add Color Zone To set ...
Nicolas
1 year ago
2
Indicators
hi nicolas this indicator have 2 wrong borderline and islalastbarupdate. thank you can you h...
That'"s because you are not using PRT v11? Just remove lines 59 to 62
robertogozzi
1 year ago
12
Indicators
Hi Roberto, sorry for my confusing previous posts (forget them). My request is very simple,...
Please start a new topic in ProOrder support.
OK
robertogozzi
1 year ago
32
Indicators
There you go: myMagicTrend = CALL “Magic Trend custom”[20, 14, 1, 5] alpha = 105 b = 0...
exactly :) Thank you all for the help!
Ciao Roberto, ho scaricato l'indicatore e come ti avevano già scritto sopra anch'io vedo la ...
Newbie
2 years ago
0
Indicators
Nicolas
2 years ago
v10.3
15
Indicators
A première vue, sa à l'air d'être un indicateur très puissant sur de petites temporalités, j...
Bonjour Nicolas, Comment transformer cet indicateur en bot sur PRT ?
Cela a déjà été fait, voir ce sujet: https://www.prorealcode.com/topic/strategia-con-lindica...
Nicolas
2 years ago
v10.3
4
Indicators
change the last line with: return v coloured(r,g,b) style(line,2), v+band coloured(168,168,1...
Thanks ... works as i wanted.
Bonjour Nicolas, comme Paolo.B je souhaiterais utiliser cette indicateur au sein d'un code. ...
Nicolas
2 years ago
2
Indicators
Thanks @Nicolas. I tried to use it as Trend in a proorder system, but don't know why, it doe...
He is right. MT and mavgMT are not defined and causing errors.....
JC_Bywan
2 years ago
v11
2
Indicators
Bonjour Noobywan, si je comprends bien l'utilisation de ce code que je trouve particulièr...
Bonjour, quand la question a été posée dans le forum à celui qui avait fait la requête en am...
robertogozzi
2 years ago
0
Indicators
juanj
2 years ago
v10.3
0
Indicators
Nicolas
2 years ago
v10.3
3
Indicators
"style(line,2)" C'è una guida ai parametri che si possono modificare ? Tipo stile della lin...
https://www.prorealcode.com/programming-with-prorealtime/
Tanks
2 years ago
13
Indicators
Écrivez-moi où vous préférez you can easily find me on LinkedIn
C'est payant visiblement sur linkdin je peux pas vous envoyer, discord vous avez ?
Nicolas
2 years ago
v10.3
57
Indicators
C'est dans ce sujet: https://www.prorealcode.com/topic/trendline-une-approche-du-trading/ M...
Bonjour Nicolas, comment est-il possible de backtester cet indicateur? cela fait une erreu...
Oui bien sûr, il doit y avoir pas mal de sujets dans le forum à ce propos.
2 years ago
v10.3
2
Indicators
How do i attach this indicator to my mt5 platform?
You can't! All indicators here are for ProRealTime trading platform: https://www.prorealtime...
Nicolas
2 years ago
v11
12
Indicators
c'est exactement ce que je fais entre les lignes 58 et 64 pour pouvoir tracer la ligne complète
Nicolas, Ces matrices sont-elles des vecteurs unidimensionnels ou multidimensionnels? Depu...
Bonjour Nicolas et RicLg, Merci Nicolas pour cet indicateur intéressant et merci RicLg pour...

Top