Error with historical data
Forums › ProRealTime English forum › ProOrder support › Error with historical data
- This topic has 25 replies, 4 voices, and was last updated 5 years ago by
Tanou.
-
-
10/01/2020 at 9:41 AM #146062
The issue seems to happen only on TF involving seconds (1 or 10-second TF’s), probably because in a day there are more than 10000 bars of 1 seconds, so it cannot calculate correctly something.
It doesn’t occur on 1-minute TF and greater.
10/01/2020 at 9:46 AM #14606410/01/2020 at 9:48 AM #146066It’s weird that if a day has more than 10K bars, why does the code suggested by Nicolas work:
1234567DEFPARAM PRELOADBARS = 3000DEFPARAM CumulateOrders = FalseHt = DHigh(1)Bs = DLow(1)C = DClose(1)Pivot = (Ht + Bs + C) / 3buy at -Pivot LIMIT?
It shouldn’t because it needs more than 10K 1-second bars to compute the Daily PIVOT!
10/01/2020 at 9:57 AM #14606710/01/2020 at 10:36 AM #146070Try with:
123456789IF openday<>openday[1] THENPlusHaut = HighPlusBas = LowPP = (PlusHaut[1] + PlusBas[1] + Close[1]) / 3Premierpassage=0ELSEPlusHaut = Max(High,PlusHaut[1])PlusBas = Min(Low,PlusBas[1])ENDIFor
123456789IF intradaybarindex=0 THENPlusHaut = HighPlusBas = LowPP = (PlusHaut[1] + PlusBas[1] + Close[1]) / 3Premierpassage=0ELSEPlusHaut = Max(High,PlusHaut[1])PlusBas = Min(Low,PlusBas[1])ENDIF10/01/2020 at 12:45 PM #146080With the second option it perfectly works! Thank you so much @Nicolas! I hope one day I’ll be able to get half of your knowledge..! 😀
I just have another question regarding the following code. I don’t get any error but the calculation of the PP month isn’t right when I implement it in real. Do you have suggestions?
@Nicolas, any magic tricks? 😀Thanks!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------DEFPARAM Preloadbars = 5000// Cumul des positions désactivéDEFPARAM CumulateOrders = False//************************************************************************//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 = 080000// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"DEFPARAM FLATAFTER = 170000// 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 = 080000timeEnterBefore = 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 = 170000timeEnterAfter = 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//************************************************************************IF OpenMonth <> OpenMonth[1] 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 CROSSES UNDER pp)IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 55ENDIF// Conditions pour ouvrir une position en vente à découvertc2 = (close CROSSES OVER pp)IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENSELLSHORT 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 55ENDIF//************************************************************************//trailing stop functiontrailingstart = 15 //trailing will start @trailinstart points profittrailingstep = 5 //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 STOPENDIF10/01/2020 at 12:49 PM #14608110/01/2020 at 3:07 PM #146091Depends of the timeframe, but 10.000 bars might not be enough to calculate correctly the monthly high/low/close at start of the strategy. I suggest you use an higher timeframe only for this part, in order to compute the monthly pivot points correctly.
10/01/2020 at 5:25 PM #146118I tried but the monthly pp is not correct it’s something like 8550 which is completely out as it should be 12859..
I’m sure I’ve done a stupid mistake but I can’t figure out where…! Moreover I can’t write “Premierpassage=0” in this part as it doesn’t accept to be modify in another UT and I don’t know how to solve it..:
12345ELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)Premierpassage=0ENDIFThanks so much for your help @Nicolas
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------DEFPARAM Preloadbars = 10000// Cumul des positions désactivéDEFPARAM CumulateOrders = False//************************************************************************//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 = 080000// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"DEFPARAM FLATAFTER = 170000// 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 = 080000timeEnterBefore = 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 = 170000timeEnterAfter = 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//************************************************************************timeframe(20 minutes,updateonclose)IF OpenMonth <> OpenMonth[1] THENmyLastHigh = myHighmyLastLow = myLowmyLastClose = Close[1]myHigh = HighmyLow = LowELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)ENDIFpp = (myLastHigh + myLastLow + myLastClose) / 3//************************************************************************timeframe(default)// Conditions pour ouvrir une position acheteusec1 = (close CROSSES UNDER pp)IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 55ENDIF// Conditions pour ouvrir une position en vente à découvertc2 = (close CROSSES OVER pp)IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENSELLSHORT 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 55ENDIF//************************************************************************//trailing stop functiontrailingstart = 15 //trailing will start @trailinstart points profittrailingstep = 5 //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 STOPENDIFgraph pp as "pp"10/02/2020 at 7:50 AM #14613310/02/2020 at 8:46 AM #146147Hello Nicolas,
Thank you for your answer!
Here’s what I’ve done.
Do you spt any mistakes?
Cheers 🙂
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Code principal : MonSystème//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Code principal : PPM avec trailing stop//-------------------------------------------------------------------------DEFPARAM Preloadbars = 10000// Cumul des positions désactivéDEFPARAM CumulateOrders = False//************************************************************************//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 = 080000// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"DEFPARAM FLATAFTER = 170000// 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 = 080000timeEnterBefore = 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 = 170000timeEnterAfter = 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//************************************************************************timeframe(5 minutes,updateonclose)If Month<>Month[1] thenmonthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]monthlyLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]lastMonthBarIndex = BarIndexpp = (monthlyHigh + monthlyLow + Close[1]) / 3endiftimeframe(default)If Month<>Month[1] thenPremierpassage=0Endif//************************************************************************// Conditions pour ouvrir une position acheteusec1 = (close CROSSES UNDER pp)IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 55ENDIF// Conditions pour ouvrir une position en vente à découvertc2 = (close CROSSES OVER pp)IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THENSELLSHORT 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 55ENDIF//************************************************************************//trailing stop functiontrailingstart = 15 //trailing will start @trailinstart points profittrailingstep = 5 //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 STOPENDIF -
AuthorPosts
Find exclusive trading pro-tools on