Error indicator negative entry or zero parameter
Forums › ProRealTime English forum › ProOrder support › Error indicator negative entry or zero parameter
- This topic has 17 replies, 4 voices, and was last updated 1 year ago by robertogozzi.
-
-
03/10/2021 at 9:32 AM #163679
Hello everyone! 😀
I hope you are well!
I launched live a code yesterday and today it has been stopped with the message ” indicator negative entry or zero parameter” and I can’t find why and where could be the error…
Could someone give me a hint?
Thanks! 😀
PP4H V2 Tanou123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154//-------------------------------------------------------------------------// Code principal : PP4H V1//-------------------------------------------------------------------------// 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 = 5 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=0DebutOpen = BarindexELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)ENDIFPP = (myLastHigh + myLastLow + myLastClose) / 3hh = highest[85](high)ll = lowest[85](low)if (hh-ll)<20 thenRang = 0elseRang = 1EndifBarresDepuisOpen = Barindex - DebutOpenHighSinceOpen = highest[BarresDepuisOpen](high)LowSinceOpen = lowest[BarresDepuisOpen](low)DiffHighSinceOpen = HighSinceOpen - ppDiffLowSinceOpen = pp - LowSinceOpenIf DiffHighSinceOpen>25 or DiffLowSinceOpen>25 thenRang2 = 1elseRang2 = 0Endif// Conditions pour ouvrir une position acheteusec1 = (close[1] CROSSES UNDER pp)IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry and Rang and Rang2 THENBUY 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 60ENDIF// Conditions pour ouvrir une position en vente à découvertc2 = (close[1] CROSSES OVER pp)IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry and Rang and Rang2 THENSELLSHORT 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 50ENDIFIf time>=090500 and time<=125000 thenIf Premierpassage=0 and c1 or c2 thenPremierpassage=1endifEndif//************************************************************************//trailing stop functiontrailingstartL = 21 //LONG trailing will start @trailinstart points profittrailingstartS = 21 //SHORT trailing will start @trailinstart points profittrailingstep = 11 //trailing step to move the "stoploss"breakeven = 0 //Activate or not the Brakevenbreakevenlevel = 15 //Level of activation of the breakevenPointsToKeepBreakeven = 1//reset the stoploss valueIF NOT ONMARKET THENnewSL=0BreakevenStop=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)If Breakeven and BreakevenStop=0 thenIF close-tradeprice(1)>=breakevenlevel*pipsize THENBreakevenStop = tradeprice(1) + PointsToKeepBreakevenEndifEndif//first move trailing stopIF newSL=0 AND close-tradeprice(1)>=trailingstartL*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)If Breakeven and BreakevenStop=0 thenIF tradeprice(1)-close>=breakevenlevel*pipsize THENBreakevenStop = tradeprice(1) - PointsToKeepBreakevenEndifEndif//first move trailing stopIF newSL=0 AND tradeprice(1)-close>=trailingstartS*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positions with trailing stopIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//stop order to exit the positions with breakevenIF BreakevenStop>0 THENSELL AT BreakevenStop STOPEXITSHORT AT BreakevenStop STOPENDIF//************************************************************************03/10/2021 at 9:50 AM #163682Try replacing lines 57-58 with:
12HighSinceOpen = highest[max(1,BarresDepuisOpen)](high)LowSinceOpen = lowest[max(1,BarresDepuisOpen)](low)because the first time BarresDepuisOpen retains 0.
03/10/2021 at 10:14 AM #16368703/10/2021 at 10:42 AM #163691No, I think that can only be the cause.
08/28/2023 at 10:45 AM #219936I have had virtually the same problem and although it works if you leave the code in the main algo, it still gives the error when you place the code in an indicator.
Would you know why it behaves differently in an indicator vs main algo ?
08/30/2023 at 10:59 AM #220055I assume you are talking about the syntax error regarding the variable BREAKEVEN.
As you can see it’s coloured in blue, this means it’s a reserved keyword (now, it wasn’t at the time the code was written). You only have to replace it with a name of your choice, whenever it occurs, usually adding (at the beginning or at the end of that name) any character of yoiur choice so that it’s no more recognized as a keyword.
I replaced it with MYBREAKEVEN (all variables and keywords are case insensitive):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154//-------------------------------------------------------------------------// Code principal : PP4H V1//-------------------------------------------------------------------------// 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 = 5 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=0DebutOpen = BarindexELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)ENDIFPP = (myLastHigh + myLastLow + myLastClose) / 3hh = highest[85](high)ll = lowest[85](low)if (hh-ll)<20 thenRang = 0elseRang = 1EndifBarresDepuisOpen = Barindex - DebutOpenHighSinceOpen = highest[BarresDepuisOpen](high)LowSinceOpen = lowest[BarresDepuisOpen](low)DiffHighSinceOpen = HighSinceOpen - ppDiffLowSinceOpen = pp - LowSinceOpenIf DiffHighSinceOpen>25 or DiffLowSinceOpen>25 thenRang2 = 1elseRang2 = 0Endif// Conditions pour ouvrir une position acheteusec1 = (close[1] CROSSES UNDER pp)IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry and Rang and Rang2 THENBUY 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 60ENDIF// Conditions pour ouvrir une position en vente à découvertc2 = (close[1] CROSSES OVER pp)IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry and Rang and Rang2 THENSELLSHORT 1 CONTRACT AT MARKETPremierpassage=1SET STOP pLOSS 50ENDIFIf time>=090500 and time<=125000 thenIf Premierpassage=0 and c1 or c2 thenPremierpassage=1endifEndif//************************************************************************//trailing stop functiontrailingstartL = 21 //LONG trailing will start @trailinstart points profittrailingstartS = 21 //SHORT trailing will start @trailinstart points profittrailingstep = 11 //trailing step to move the "stoploss"mybreakeven = 0 //Activate or not the Brakevenbreakevenlevel = 15 //Level of activation of the breakevenPointsToKeepBreakeven = 1//reset the stoploss valueIF NOT ONMARKET THENnewSL=0BreakevenStop=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)If mybreakeven and BreakevenStop=0 thenIF close-tradeprice(1)>=breakevenlevel*pipsize THENBreakevenStop = tradeprice(1) + PointsToKeepBreakevenEndifEndif//first move trailing stopIF newSL=0 AND close-tradeprice(1)>=trailingstartL*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)If mybreakeven and BreakevenStop=0 thenIF tradeprice(1)-close>=breakevenlevel*pipsize THENBreakevenStop = tradeprice(1) - PointsToKeepBreakevenEndifEndif//first move trailing stopIF newSL=0 AND tradeprice(1)-close>=trailingstartS*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positions with trailing stopIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//stop order to exit the positions with breakevenIF BreakevenStop>0 THENSELL AT BreakevenStop STOPEXITSHORT AT BreakevenStop STOPENDIF//************************************************************************09/01/2023 at 11:55 AM #220176Thanks for you response Roberto. But no I wasn’t talking about the variable BREAKEVEN.
I have the following code in the main algo, and it works fine in real time. If I move this piece of code in an indicator and call the indicator in the main algo , I am getting an error saying a zero or negative parameter ….
any idea why it would behave differently if in main algo or in the indicator section ? Thanks in advance
If Month <> Month[1] and Barindex > 0 then
monthlyHigh = Highest[BarIndex – lastMonthBarIndex](dailyHigh)monthlyLow = Lowest[BarIndex – lastMonthBarIndex](dailyLow)
lastMonthBarIndex = BarIndex
ENDIF09/02/2023 at 10:28 AM #220207I added that code as an indicator of its own, then calling it from the strategy, and it works as expected.
I placed those lines in your code above and it works fine like in the indocator.
I couldn’t spot anything wrong.
You should post the whole code for both the strategy and the indicator, specifying the instrument, timeframe and units used.
09/03/2023 at 9:39 AM #22023309/03/2023 at 11:08 AM #220237The code is below inspired from Reiner – Pathfinder that I am trying to use as one indicator to buy or sell. If I insert in the main algo it works but stopped working as I put it in an indicator
It does not really matter, I can continue to have it in the main algo but just tidier to use as an indicator to simplify the view of the main code.
And also curious to understand why it works in one case and fails in the other.main algo123timeframe(4h, updateonclose)Cbuy, Csell =Call "JM INDICATOR V0.1"JM Indicator v0.112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364ONCE periodFirstMA = 6ONCE periodSecondMA = 10ONCE periodThirdMA = 4// filter parameterONCE periodLongMA = 160ONCE periodShortMA = 40ONCE lastweekbarindex =0once lastmonthbarindex = 0// calculate daily high/lowdailyHigh = DHigh(1)dailyLow = DLow(1)// calculate weekly high/lowIf DayOfWeek < DayOfWeek[1] and barindex > 0 thenweeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)lastWeekBarIndex = BarIndexENDIF// calculate monthly high/lowIf Month <> Month[1] and barindex > 0 thenmonthlyHigh = Highest[BarIndex - lastMonthBarIndex](dailyHigh)monthlyLow = Lowest[BarIndex - lastMonthBarIndex](dailyLow)lastMonthBarIndex = BarIndexENDIF// calculate signalline with multiple smoothed averagesfirstMA = WilderAverage[periodFirstMA](close)secondMA = TimeSeriesAverage[periodSecondMA](firstMA)signalline = TimeSeriesAverage[periodThirdMA](secondMA)// filter criteria because not every breakout is profitablec1 = close > Average[periodLongMA](close)c2 = close < Average[periodLongMA](close) c3 = close > Average[periodShortMA](close)c4 = close < Average[periodShortMA](close)// long position conditionsl1 = signalline CROSSES OVER monthlyHighl2 = signalline CROSSES OVER weeklyHighl3 = signalline CROSSES OVER dailyHighl4 = signalline CROSSES OVER monthlyLow// short position conditionss1 = signalline CROSSES UNDER monthlyHighs2 = signalline CROSSES UNDER monthlyLows3 = signalline CROSSES UNDER dailyLowCondAchat = ((l1) OR (l4) OR (l2)OR (l3 AND c2))CondVente= ((s2 AND c4) OR (s3 AND c1))RETURN CondAchat, CondVente09/03/2023 at 11:33 AM #22023809/03/2023 at 11:44 AM #22024009/03/2023 at 11:58 AM #22024209/03/2023 at 12:49 PM #220247Hi,
That’s right, I hadn’t read everything yet… 🙂
I personally think that error message is due to the “Crosses Over” and “Crosses Under”…
Perhaps it would be better to use “greater than (>) ” and “smaller than (<)” here…
(remark: there is no WeeklyLow in the code…?)
09/03/2023 at 8:27 PM #220275 -
AuthorPosts
Find exclusive trading pro-tools on