Dax / UT 2mn / Long only.
Forums › ProRealTime English forum › ProOrder support › Dax / UT 2mn / Long only.
- This topic has 11 replies, 3 voices, and was last updated 7 years ago by Nicolas.
-
-
07/06/2017 at 7:54 PM #39966
Dear Nicolas,
I am pleased to share the following strategy.
The trade is triggered by the MACD histo / TF – 2mn / Instrument: DAX, 1eur.
I stand ready for your kind feedback.
IMPORTANT: Great forum, thx to Nicolas, Maz, Ale, Maverick 😉 , and everyone else for your ideas and bit of codes !
DJ
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556//// Définition des paramètres du codeDEFPARAM CumulateOrders = False// Cumul des positions désactivé// Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".DEFPARAM FLATBEFORE = 091500// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"DEFPARAM FLATAFTER = 220000// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiéenoEntryBeforeTime = 091500timeEnterBefore = time >= noEntryBeforeTime// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiéenoEntryAfterTime = 220000timeEnterAfter = time < noEntryAfterTime// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiésdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions pour ouvrir une position acheteuseindicator1 = MACDline[16,26,9](close)c1 = (indicator1 > 0)indicator2 = MACD[16,26,9](close)c2 = (indicator2 CROSSES OVER 0)IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETENDIF//trailing stoptrailingstop = 28//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0priceexit = 0endif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendifSET STOP ploss 120SET TARGET pPROFIT 2001 user thanked author for this post.
07/06/2017 at 8:44 PM #3997307/07/2017 at 10:51 AM #40010Thanks Inertia. I moved the topic to ProOrder section and add the code with the correct button to insert code 🙂
It’s great you made the walk forward analysis! So the only setting you optimized is the “trailingstop” variable? Any change to get a short version to see how it goes?
07/07/2017 at 10:21 PM #40052Thank you Nicolas. Yes for the “trailingstop”, and replaced the MACD 12 26 9 by 16 26 9…Is that the correct way to do a WF ?
Attached the short version…How does this sounds like ?
DJ
Dax 15 TF Short only123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960//Dax 15mn / short only// Définition des paramètres du codeDEFPARAM CumulateOrders = False // Cumul des positions désactivé// Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".DEFPARAM FLATBEFORE = 091500// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"DEFPARAM FLATAFTER = 214500// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiéenoEntryBeforeTime = 091500timeEnterBefore = time >= noEntryBeforeTime// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiéenoEntryAfterTime = 214500timeEnterAfter = time < noEntryAfterTime// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiésdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions pour ouvrir une position en vente à découvertindicator1 = MACD[12,26,9](close)c1 = (indicator1 CROSSES UNDER 0)indicator2 = MACDline[12,26,9](close)c2 = (indicator2 < 0)indicator3 = ExponentialAverage[2000](close)c3 = (close < indicator3)indicator4 = ExponentialAverage[2000](close)indicator5 = ExponentialAverage[2000](close)c4 = (indicator4 < indicator5[1])IF (c1 AND c2 AND c3 AND c4) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENSELLSHORT 1 CONTRACT AT MARKETENDIF//trailing stoptrailingstop = 28//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0priceexit = 0endif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendifSET STOP ploss 62//SET TARGET pPROFIT 250//07/08/2017 at 7:30 AM #40068Dear Nicolas,
Attached is the best I can do: => Stop Loss set to 45 and No target (No Limits !!)
OK?
1 user thanked author for this post.
07/08/2017 at 4:23 PM #4009407/08/2017 at 5:11 PM #40097Hi T-rader.
Yes at first. Then it works roughly like a OCO order. Once the value of the trailing stop gain in profit, the original stop will be cxl’d to be moved to the trailing value.
Hope this is clear. 😉
https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
Tx.
07/08/2017 at 7:07 PM #40110I made videos in French to explain the WFA. If you made a backtest for the whole history with optimized variables of one of your OOS period, I think you did not understand how it should work 🙂
Anyway, I think we should be careful with the result of the WF test you made for a main reason, most of the Out Of Sample results have huge WFE (>200%).
Why did you made the test of the short version on a 15 minutes timeframe? While the long one is designed for the 2 minutes one?
07/08/2017 at 7:22 PM #40115Thank you Nicolas. WF’s feedback much appreciated. I’ll have a look asap.
Short version: It doesn’t work well with the TF 2mn. The 15TF works much better for this kind of signal.
The idea would be to start both strategies at once and one may partially cover the losses of the other.
But, agree, it is not a perfect TF match Long Short…
Based on your experience, don’t you think that these 2 strategies, despite their different TF deserve a try ?
Tx again for your time and kind help on it.
DJ
07/08/2017 at 7:43 PM #40118Well, the spread is not the same after 170000, you should reduce the schedules of the strategy or add at least 1 point to the spread in backtests.
I just realized that your short version can’t work effectively because your trailing stop function doesn’t include the short orders but only the long ones!
07/08/2017 at 9:10 PM #40139OMG 🙁 – but thank you…
1 pts added (total of 2).
Attached the versions with and without trailing stop.
Same amount of draw downs in both case … My choice goes logically to the most profitable one.
I will WF it and put them in a demo account see how it goes.
Thank you Nicolas.
07/09/2017 at 9:35 AM #40155 -
AuthorPosts
Find exclusive trading pro-tools on