PP4h Opinion and optimization
Forums › ProRealTime English forum › ProOrder support › PP4h Opinion and optimization
- This topic has 7 replies, 4 voices, and was last updated 3 years ago by BobOgden.
-
-
10/21/2020 at 2:30 PM #147999
Hello every one ! 😀
I wanted to try something with the PP4H. I’ve done this code, I think it is quite nice but not long of backtest so…!
This code is simply the entry of position on the 4h pp between 9:05 and 12:50. By the close(2) crossing it for the first time of the day with a trailing stop 🙂
Tell me what you think about it and if you think that something should be change/optimize 😉
@Paul, maybe this could interest you as I think you like this kind of code 🙂PP4H123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101//-------------------------------------------------------------------------// Code principal : PP4h avec trailing stop//-------------------------------------------------------------------------// Définition des paramètres du code// Cumul des positions désactivéDEFPARAM CumulateOrders = FalseDEFPARAM PRELOADBARS = 100000000//************************************************************************//Horaires de trading// 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 = 090000// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"DEFPARAM FLATAFTER = 173000// 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 = 090500timeEnterBefore = 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 = 125000timeEnterAfter = 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//************************************************************************// Calcul Points Pivots 4hInt = (OpenTime[1] < 010000 AND OpenTime > 010000) OR (OpenTime[1] < 050000 AND OpenTime > 050000) OR (OpenTime[1] < 090000 AND OpenTime > 090000) OR (OpenTime[1] < 130000 AND OpenTime > 130000) OR (OpenTime[1] < 170000 AND OpenTime > 170000) OR (OpenTime[1] < 210000 AND OpenTime > 210000) OR (Openday <> Openday[1] AND DayOfWeek < DayOfWeek[1])IF (OpenTime Mod 40000 = 10000) OR Int THENmyLastHigh = myHighmyLastLow = myLowmyLastClose = Close[1]myHigh = HighmyLow = LowPremierpassage=0ELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)ENDIFPP = (myLastHigh + myLastLow + myLastClose) / 3// Conditions pour ouvrir une position acheteusec1 = (close[2] CROSSES UNDER pp)IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 40ENDIF// Conditions pour ouvrir une position en vente à découvertc2 = (close[2] CROSSES OVER pp)IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENSELLSHORT 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 40ENDIF//************************************************************************//trailing stop functiontrailingstart = 5 //trailing will start @trailinstart points profittrailingstep = 1 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart THENnewSL = tradeprice(1)+trailingstepENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep THENnewSL = newSL+trailingstepENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart THENnewSL = tradeprice(1)-trailingstepENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep THENnewSL = newSL-trailingstepENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF1 user thanked author for this post.
10/21/2020 at 5:47 PM #14802310/21/2020 at 5:53 PM #14802510/21/2020 at 7:48 PM #14802810/22/2020 at 9:24 AM #14805910/23/2020 at 2:39 PM #148246Thnx, I’ve found that “int” parameter doesn’t make a change if it’s added or not. Could be different today. But the limited data and the number of trades doesn’t make things easy to test. Maybe put it in demo and let’s see how it works out.
10/23/2020 at 7:13 PM #14827710/29/2020 at 10:21 PM #148944Hey Tanou,
I’ve tried using your calculation code for 4h PP but I still find some discrepancies now and again. For example, today, October 29th, the real 4h PP from 9 to 13 is supposed to be 26 756.9 on DJI. Your algo found 26 752.07.
Would you have any idea as to why?
-
AuthorPosts
Find exclusive trading pro-tools on