Optimization moving average crossing strategy
Forums › ProRealTime English forum › ProOrder support › Optimization moving average crossing strategy
- This topic has 185 replies, 11 voices, and was last updated 2 years ago by
slevinkelevra.
-
-
03/21/2020 at 12:00 AM #122782
To avoid comparing the same MA
That’s great Jan, should speed things up too, 70 less pairs to check.
I think that only has to be added to one set of the MAs, no? ie not the MAtypeV2 as well
I have tried altering the period but so far 15 on both sides seems to give the best result.
03/21/2020 at 12:16 AM #122783Best optimization for 200k:
ONCE MAType = 3
ONCE MATypeV2 = 91 user thanked author for this post.
03/21/2020 at 12:23 AM #122786Excellent – thanks Francesco!
That combination does well enough in the ancient history, but more importantly it’s getting good results this year — 3 and 9 it is.
03/21/2020 at 12:27 AM #122787@Jan — forget my query about the alteration to the code, of course it only has to be added once at the beginning of the list. Brain fog.
03/21/2020 at 10:06 AM #122790Hi Nonetheless, thanks for the reply, not sure what you meant ” @jan — forget my query about the alteration to the code, of course it only has to be added once at the beginning of the list. Brain fog.”
Have a nice weekend.
To avoid comparing the same MA (assuming the periods remain fixed), which is then meaningless, the very simple code is:
//Before all average definitions:
if MAType <> MATypeV2 then
//after all average definitions
Endif
You have to do this code AROUND all averages, both MAType and MATypeV2 in my opinion.
I think that if you code it only around the MAType defined averages, the first set, the strategy optimizing would give an error because when both (MAType and MATypev2) are the same, MAType would be excluded and undefined, which results in Nothing (MAType) crossing a average MATypeV2, which should give a error.
03/21/2020 at 10:54 AM #122794not sure what you meant
Because my first thought was that “if MAType <> MATypeV2 then” had to be added to each MA — ie 140 times, but of course it’s just once at the beginning of the list. That was the foggy brain part. Never mind… have a great weekend!
03/21/2020 at 1:26 PM #12282103/21/2020 at 3:31 PM #122832Here’s another way of using this. The attached itf isolates just the ‘search engine’ part so that it can be inserted into any existing strategy. For example, if you had certain indicators and conditions on a daily TF, you could insert this on a 1h TF and it will find a pair of crossing MAs to use as additional entry conditions within the context of your other filters and parameters etc.
Very effective!
2 users thanked author for this post.
03/21/2020 at 7:41 PM #12286703/21/2020 at 8:17 PM #12286903/21/2020 at 9:11 PM #12287203/21/2020 at 9:54 PM #122873Try below … as without the Flatbefore (which you didn’t have) then all times are flat after … if you understand my logic?
123456DEFPARAM cumulateOrders = False // Cumulating positions deactivateDefparam flatafter = 160000 //close the position at 16:00 (day trading) /could be switched offDefparam flatbefore = 090000 //you don't have this in your codeSET TARGET pPROFIT 150once StartE = 90000 //start time for opening positionsonce StartL = 110000 //ending time for opening positions (only trading in the morning)03/21/2020 at 11:00 PM #122876hi Frenqle,
hard to test in the weekend.
What do mean with ” after a few seconds, minutes or hours (without reason).” you tried different timeframes ? If you had used the hourly timeframe, did it then stop immediately ?
It seems consistent with the base code.
Did you try to leave the original code and set it fixed to the required 2 averages, does that work ? (I saw you stripped to code to only the 2 averages you want)
KR Jan
03/22/2020 at 12:10 AM #122879Would there be possible to make a code that look at a higher TimeFrame pair crossing, and when that happened execute an order on a lower time frame for an optimized crossing for that timeframe? Or would that just result in very few trades? Just been doing ProRealTime for a week so thats out of my competence level =)
What I want to do is, find a optimal crossing for a long position on lets say the daily or 4H chart, and when that happened, look for a optimized crossing for long position on a much lower timeframe like 15 min, 5 min, etc. So we just take trades in the “right” trend at the moment. And wise versa for the short position. That should improve the winning %?
Awesome code both Jan and Nonetheless, thank you!
03/22/2020 at 12:31 AM #122884@dnystrom I dont think you would want an actual crossover in both time frames as that would be a fairly rare occurrence and, as you say, result in v few trades. Better would be to use some kind of trend indicator in the daily TF, then insert the part of the code i posted above (MACross finder) in the shorter TF and let it find the best crossover to work in conjunction with your daily filter.
It’s possible of course to load it in both TFs and optimize them separately, but I wouldn’t expect it to work very well. (or maybe it would – try it and let us know!)
-
AuthorPosts
Find exclusive trading pro-tools on