ADX+EMAS Strategy – Appreciate comments!
Forums › ProRealTime English forum › General trading discussions › ADX+EMAS Strategy – Appreciate comments!
- This topic has 16 replies, 4 voices, and was last updated 6 years ago by CA.
-
-
10/30/2018 at 7:47 PM #83815
Hello!
I have been working on a new strategy for catching trends and I have come up with a code. What I have been doing is optimizing the code for having a specific set of parameters for each currency pair.
So far in the BT I have gotten good results with some pairs E.G. AUD/JPY.
After I get the best variables for the pair I improve the strategy with an optimzed trainling stop.
I will just leave the code here for the AUD/JPY example. Please just let me know what you think:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253SHORT = 10LONG = 38PERIODOADX = 16PERIODOSDECRUCE =20PERIODODECRUCE2 = 50// LongsCondition1 = ADX[PERIODOADX] CROSSES OVER PERIODOSDECRUCECondition2 = ExponentialAverage[SHORT](Close) > ExponentialAverage[LONG](Close) AND LOW[1] > ExponentialAverage[SHORT](Close)Condition3 = ExponentialAverage[SHORT](Close) < ExponentialAverage[LONG](Close) AND HIGH[1] < ExponentialAverage[SHORT](Close)IF NOT LongOnMarket AND Condition1 AND Condition2 THENBUY 1 CONTRACTS AT MARKETENDIF// Exit longsIf LongOnMarket AND ADX[PERIODOADX] >= PERIODODECRUCE2 thenallowtrailing = 1elseallowtrailing = 0endifif allowtrailing thenSET STOP pTRAILING TRAILINGnendifIf LongOnMarket AND (ExponentialAverage[SHORT](Close) CROSSES UNDER ExponentialAverage[LONG](Close)OR ADX[PERIODOADX] < PERIODOSDECRUCE) THENSELL AT MARKETENDIF// ShortsIF NOT ShortOnMarket AND Condition1 AND Condition3 THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Exit shortsIF ShortOnMarket AND ADX[PERIODOADX] >= PERIODODECRUCE2 thenallowtrailing = 1elseallowtrailing = 0endifif allowtrailing thenSET STOP pTRAILING TRAILINGnendifIF ShortOnMarket AND (ExponentialAverage[SHORT](Close) CROSSES OVER ExponentialAverage[LONG](Close) OR ADX[PERIODOADX] < PERIODOSDECRUCE) THENEXITSHORT AT MARKETENDIFSET STOP LOSS 150// Stops1 user thanked author for this post.
10/30/2018 at 10:18 PM #83826What Timeframe is above code optimised for please?
What value are you using for TRAILINGn ?
Please can you post your equity curve and Performance results?
I’ve optimised TRAILINGn on every TF from 1 Min to 1 Day (on AUD/JPY).
10/30/2018 at 10:21 PM #8382710/30/2018 at 10:27 PM #8382810/30/2018 at 10:58 PM #8382910/30/2018 at 11:26 PM #83832Something odd here? Attached is what I get! 🙂
Am I reading that correct … you are buying 1,000 Contracts on AUDJPY??
I’ll have to collect my thoughts as I see you show performance results for Spot AUD/JPY??
Anybody reading this got any comments??
10/31/2018 at 12:28 AM #8383610/31/2018 at 6:56 AM #83839Hi CA,
What I think is that you start your journey of automatic trading like me ( or most of us)
first: to much variables means overfitting which means the code only works in the past but not in the future
second: test it 100000 bars (it means at much data as possible)
third: walk forward test, if it works in the walk forward test, then you have a nice code.
Kind Regards
1 user thanked author for this post.
10/31/2018 at 9:06 AM #83842I only buy 1 contact per operation.
So why does this say 1000 as the Lot size then (see red arrow on attached)?
Or has sleep done me no good or even my coffee is not working this morning?? 🙂
Could you show me the code you are using. It is quite wierd!!
I am using testing your code with TRAILINGn at value 133 as you show in your screen shot of optimised results.
Are you sure you have the tick by tick box selected??
10/31/2018 at 9:34 AM #83845We need to get to the bottom of this, I hate oddities like this, but I am driven to investigate!!!! hahahha
This is the code / your code I am using
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253SHORT = 10LONG = 38PERIODOADX = 16PERIODOSDECRUCE =20PERIODODECRUCE2 = 50// LongsCondition1 = ADX[PERIODOADX] CROSSES OVER PERIODOSDECRUCECondition2 = ExponentialAverage[SHORT](Close) > ExponentialAverage[LONG](Close) AND LOW[1] > ExponentialAverage[SHORT](Close)Condition3 = ExponentialAverage[SHORT](Close) < ExponentialAverage[LONG](Close) AND HIGH[1] < ExponentialAverage[SHORT](Close)IF NOT LongOnMarket AND Condition1 AND Condition2 THENBUY 1 CONTRACTS AT MARKETENDIF// Exit longsIf LongOnMarket AND ADX[PERIODOADX] >= PERIODODECRUCE2 thenallowtrailing = 1elseallowtrailing = 0endifif allowtrailing thenSET STOP pTRAILING 133endifIf LongOnMarket AND (ExponentialAverage[SHORT](Close) CROSSES UNDER ExponentialAverage[LONG](Close)OR ADX[PERIODOADX] < PERIODOSDECRUCE) THENSELL AT MARKETENDIF// ShortsIF NOT ShortOnMarket AND Condition1 AND Condition3 THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Exit shortsIF ShortOnMarket AND ADX[PERIODOADX] >= PERIODODECRUCE2 thenallowtrailing = 1elseallowtrailing = 0endifif allowtrailing thenSET STOP pTRAILING 133endifIF ShortOnMarket AND (ExponentialAverage[SHORT](Close) CROSSES OVER ExponentialAverage[LONG](Close) OR ADX[PERIODOADX] < PERIODOSDECRUCE) THENEXITSHORT AT MARKETENDIFSET STOP LOSS 150// Stops10/31/2018 at 9:46 AM #8384610/31/2018 at 10:02 AM #83850HAHAHAHHAHAHAHAHHAHAHAHAHAH
It’s all my error!!!!!!!!!!! I’m glad I am driven to investigate!!!!!!!!!!!!!
I had my capital set at 10,000 (as always) but for this test, starting capital needs increasing by at least a factor of 10 to account for GBP to Yen exchange rate!
I get same / similar to you now you!!!!!!!!!!
A useful lesson learnt (for me!!!!!!!)
Results attached over 100k bars
Well done @CA
(Apologies for my doubts!)
1 user thanked author for this post.
10/31/2018 at 2:03 PM #8386810/31/2018 at 2:08 PM #83870Thank you GraHal! So for you it worked! So your opinion is that (at last in theory) it is a good code? I’ll start FT next week as I am still woking out on which par it work and optimizing vales. Later I will post the inicial code from where I start optimiza tío, which, as I said to Leo, have even worked under walk forward optimization.
Any way happy you get to solve what was affecting the code! 🙂
10/31/2018 at 5:01 PM #83884Be aware that SET STOP PTRAILING will certainly not act the same way in live as in backtest, due to the minimal stop level that it is used as the step of stoploss moving. You should use one of the trailing code you’ll find around in the website.
-
AuthorPosts
Find exclusive trading pro-tools on