Using 3 ema for back testing not working
Forums › ProRealTime English forum › ProOrder support › Using 3 ema for back testing not working
- This topic has 16 replies, 4 voices, and was last updated 5 years ago by Vonasi.
-
-
12/16/2018 at 2:20 PM #87219
I am needing a code to buy when 10 ema crosses over the 20 and 50 and sell when the 10 crosses under the 20 and 50.
The issues im having is with this code:
[Moderators edit – code removed as it was unreadable. It can now be found further down the thread.
12/16/2018 at 2:34 PM #8722012/16/2018 at 2:48 PM #87221Alec Imad – I’m not sure what has happened when you have tried to put code in your post but it has turned out unreadable.
It goes like that when you have entered the code correctly using the Enter PRT Code button and then you edit the code on the normal page and then you post the whole message (changes need to be made by going back into the Enter PRT Code box).
Or another way you get all the html commands (?) is if you copy code from another message (which has been correctly entered using the Enter PRT Code button) and then you paste it straight onto a normal message page!
12/17/2018 at 12:17 AM #87235Please update your country flag. Thank you.
12/17/2018 at 9:14 AM #87248Alec Imad – Welcome to the forums.
Please repost your code here so that someone can assist you.
There are some basic rules that you will need to follow when posting in the forums. You have broken most of them already! 🙂
- Ensure your country flag is updated.
- Make sure you post in the correct forum. ProOrder for strategies, Probuilder for indicators etc.
- Do not double post as it leads to wasted time and confusion.
I have deleted your identical question in the ProBuilder forum as it was a double post in the wrong forum and the code was also unreadable in that one!
I’m not sure what you are exactly doing to make the code unreadable but if you want to put code in your posts then just simply click the ‘add PRT Code button’ then type or cut and paste your code into the box and then click ‘add’.
12/17/2018 at 9:31 AM #872501234567891011121314151617181920212223242526// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = ExponentialAverage[10](close)indicator2 = ExponentialAverage[20](close)c1 = (indicator1 CROSSES OVER indicator2 and )indicator3 = ExponentialAverage[10](close)indicator4 = ExponentialAverage[50](close)c2 = (indicator3 CROSSES OVER indicator4)IF c1 and c2 THENBUY 10 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator5 = ExponentialAverage[10](close)indicator6 = ExponentialAverage[20](close)c3 = (indicator5 CROSSES UNDER indicator6)indicator7 = ExponentialAverage[10](close)indicator8 = ExponentialAverage[50](close)c4 = (indicator7 CROSSES UNDER indicator8)IF c3 AND c4 THENSELL AT MARKETENDIFThank you and sorry for breaking the rules.
I have tried looking where to add my country flag but can not find it. I am from australia.
12/17/2018 at 9:47 AM #8725412/17/2018 at 9:53 AM #87255Your problem is because both conditions have to be found on the same bar which is highly unlikely to happen. You need to look for one condition and then set a flag to say that that condition has happened and then only enter a trade if the second condition happens while the first ones flag is still valid. Same for the exit.
1 user thanked author for this post.
12/17/2018 at 10:00 AM #8725712/17/2018 at 10:11 AM #87258You could do below and get attached on DJI @5 Min TF, spread = 4 and Lot size = 1
1234567891011121314151617181920212223242526// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = ExponentialAverage[10](close)indicator2 = ExponentialAverage[20](close)c1 = (indicator1 > indicator2)indicator3 = ExponentialAverage[10](close)indicator4 = ExponentialAverage[50](close)c2 = (indicator3 CROSSES OVER indicator4)IF c1 and c2 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator5 = ExponentialAverage[10](close)indicator6 = ExponentialAverage[20](close)c3 = (indicator5 < indicator6)indicator7 = ExponentialAverage[10](close)indicator8 = ExponentialAverage[50](close)c4 = (indicator7 CROSSES UNDER indicator8)IF c3 AND c4 THENSELL AT MARKETENDIF12/17/2018 at 11:09 AM #8726712/17/2018 at 11:33 AM #87274Thanks GraHal that is a far simpler solution than mine. I do like to complicate things whenever I possibly can so it is always nice to be reminded that there are simpler ways sometimes!
1 user thanked author for this post.
12/17/2018 at 1:37 PM #87285Alec Imad … on the basis that Shorts don’t trigger / play out same as Longs here’s a both ways strategy.
I will Forward Test (on Demo) the Long only and Long & Short version below and report back on here after 1 month or so.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = ExponentialAverage[10](close)indicator2 = ExponentialAverage[20](close)c1 = (indicator1 > indicator2)indicator3 = ExponentialAverage[10](close)indicator4 = ExponentialAverage[50](close)c2 = (indicator3 CROSSES OVER indicator4)IF not shortonmarket and c1 and c2 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator5 = ExponentialAverage[10](close)indicator6 = ExponentialAverage[20](close)c3 = (indicator5 < indicator6)indicator7 = ExponentialAverage[10](close)indicator8 = ExponentialAverage[50](close)c4 = (indicator7 CROSSES UNDER indicator8)IF c3 AND c4 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator1 = ExponentialAverage[30](close)//50indicator2 = ExponentialAverage[85](close)//20c1 = (indicator1 < indicator2)indicator3 = ExponentialAverage[30](close)//50indicator4 = ExponentialAverage[80](close)//75c2 = (indicator3 CROSSES UNDER indicator4)IF not longonmarket and c1 and c2 THENSellShort 1 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator5 = ExponentialAverage[30](close)//50indicator6 = ExponentialAverage[85](close)//20c3 = (indicator5 > indicator6)indicator7 = ExponentialAverage[30](close)//50indicator8 = ExponentialAverage[80](close)//75c4 = (indicator7 CROSSES OVER indicator8)IF c3 AND c4 THENExitShort AT MARKETENDIF12/17/2018 at 1:56 PM #8728812/17/2018 at 2:36 PM #87291You will notice that all the strategies suddenly started making money around February 2018 when the bull market came to an end and we entered a volatile mean reversing market. A simple strategy of EMA’s crossing can be easily be tuned (curve fitted) to this sort of market. Finding the correct EMA values for tomorrow and onward is the hard bit and also knowing when to turn it off as a bull or bear trend has started again is also difficult as you don’t know it is a trend until your mean reversal strategy has already lost you a lot of money usually!
Sorry voice of doom again.
-
AuthorPosts
Find exclusive trading pro-tools on