indicator negative entry or zero parameter error message
Forums › ProRealTime English forum › ProOrder support › indicator negative entry or zero parameter error message
- This topic has 15 replies, 6 voices, and was last updated 3 years ago by juanj.
-
-
09/23/2020 at 6:16 AM #145026
Hi
My live system (with IG) was automatically stopped with the error – indicator negative entry or zero parameter. My code is below and I am struggling to understand why this happened.
I have back tested the system for several months on a tick by tick mode and had no such issues / errors. The live system was trading on the wall street (DFB) instrument using daily chart.
Can you spot any error in the code? Any thoughts?
Thanks
Sachin
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedperiod = 10type = 0smaHigh=Average[period,type](high)smaLow=Average[period,type](low)if close>smaHigh thenHlv=1elsif close<smaLow thenHlv=-1elseHlv=Hlv[1]endifif Hlv<0 thensslDown=smaHighelsesslDown=smaLowendifif Hlv<0 thensslUp=smaLowelsesslUp=smaHighendifx = AroonUp[10]y = AroonDown[10]ATR = AverageTrueRange[14](close)//POSITIONPERF(1) < 0 AND TRADEPRICE(2) > TRADEPRICE(1) ANDIF ((x[1] > y[1]) AND (x[1] > 70)) AND (x > y) THENa = 1ELSEa = 0ENDIF//POSITIONPERF(1) < 0 AND TRADEPRICE(2) < TRADEPRICE(1) ANDIF ((x[1] < y[1]) AND (y[1] > 70)) AND (x < y) THENb = 1ELSEb = 0ENDIF// Conditions to enter long positionsIF NOT LONGONMARKET AND a = 0 AND ATR < 500 AND (x > y) AND (x > 70) AND (sslUp > sslDown) THENBUY 0.2 PERPOINT AT MARKETSET STOP LOSS 1.5 * ATRENDIF// Conditions to exit long positionsIF (sslUP < sslDown) OR (y > x) THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT SHORTONMARKET AND b = 0 AND ATR < 500 AND (sslDown > sslUp) AND (y > 70) AND (y > x) THENSELLSHORT 0.2 PERPOINT AT MARKETSET STOP LOSS 1.5 * ATRENDIF// Conditions to exit short positionsIF (sslUP > sslDown) OR (x > y) THENEXITSHORT AT MARKETENDIFc = BARINDEX - TRADEINDEXIF LONGONMARKET AND (highest[c](high) - TRADEPRICE) > 500 THENSET STOP TRAILING 100ELSIF SHORTONMARKET AND (TRADEPRICE - lowest[c](low)) > 500 THENSET STOP TRAILING 100ENDIF09/23/2020 at 7:37 AM #145028Try replacing line 73 with this one to make sure C is not zero:
1c = max(1,BARINDEX - TRADEINDEX)1 user thanked author for this post.
09/23/2020 at 11:03 AM #145054Thanks Roberto
Also, in lines 49 and 62, is NOT LONGONMARKET and NOT SHORTONMARKET required as per the code to execute long / short trades?
I thought different live systems did not communicate with each other and executed trades independently. However IG have told me that if there is already a long (or short) trade on an instrument, then a separate live system will not execute another long (or short) trade on the same instrument if NOT LONGONMARKET or NOT SHORTONMARKET is included in lines 49 and 62 i.e. it looks at open positions in the whole trading account not just the trading system itself
Your thoughts please?
09/23/2020 at 11:16 AM #145059No, they are not required, bu since you embed a stop loss calculation within those IF…ENDIF’s , even when already OnMarket your SL would change despite no further position is opened.
I always use NOT [Long/Short]ONMARKET, unless I move the calculation elsewhere to make sure SL is not always changed.
2 users thanked author for this post.
09/23/2020 at 4:04 PM #145091I have back tested the system for several months on a tick by tick mode and had no such issues / errors
Likely back test cannot catch it 🙂
I did a test before to purposely create division with zero, back test run fine, but live will not, #140253
1 user thanked author for this post.
02/11/2021 at 8:27 AM #161017Zero parameter123456789// Up ConditionsADLGO1= Close - Average[30](close)>Average[10](Close - Average[30](close))ADLGO2= Close - Average[30](close)>0// Conditions DownADSGO1= Close - Average[30](close)<Average[10](Close - Average[30](close))ADSGO2= Close - Average[30](close)<0Hi Roberto,
I get the zero parameter error on the above code as well, use it as a condition for long/short entries. Any suggestion of how I should change it to avoid the zero issue?
02/11/2021 at 8:38 AM #161019There can’t be an error in those two lines, since all parameters are positive constants.
The error must be somewhere else.
02/11/2021 at 9:04 AM #1610221234567891011121314151617181920212223242526272829303132333435363738//Inactivity - LongsIf Barindex - Tradeindex = 106 Thenc = 1Elsec = 0EndifIf close - positionprice < 250 Thend = 1Elsed = 0EndifIf Longonmarket and c = 1 and d = 1 ThenSell at marketEndif//Inactivity - ShortsIf Barindex - Tradeindex >= 68 Thene = 1Elsee = 0EndifIf positionprice - close <= 250 Thenf = 1Elsef = 0EndifIf Shortonmarket and e = 1 and f = 1 ThenExitshort at marketEndif// TradesIF ADLGO1 and ADLGO2 and Average[10](close) CROSSES over Average[40](close) THENBUY 1 CONTRACT AT MARKETIF ADSGO1 and ADSGO2 and Average[10](close) CROSSES under Average[40](close) THENSELLSHORT 1 CONTRACT AT MARKETThanks Roberto,
I will try and run it again. This is the rest of the code…? I do not see anything funny except maybe barindex-tradeindex…?
02/11/2021 at 10:15 AM #161036I can’t run it because some variables are missing.
Anyway, and ENDIF is missing at the end. Actually two ENDIF’s are missing but you can get rid of one just replacing IF at line 37 with ELSIF (which is logically correct).
As to barindex-tradeindex… it is never used as an index, just for comparisons.
02/11/2021 at 11:28 AM #161053123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedTimeframe(daily,updateonclose)// Up ConditionsADLGO1= Close - Average[30](close)>Average[10](Close - Average[30](close))ADLGO2= Close - Average[30](close)>0// Conditions DownADSGO1= Close - Average[30](close)<Average[10](Close - Average[30](close))ADSGO2= Close - Average[30](close)<0//Inactivity - LongsTimeframe(default)If Barindex - Tradeindex = 106 Thenc = 1Elsec = 0EndifIf close - positionprice < 250 Thend = 1Elsed = 0EndifIf Longonmarket and c = 1 and d = 1 ThenSell at marketEndif//Inactivity - ShortsIf Barindex - Tradeindex >= 68 Thene = 1Elsee = 0EndifIf positionprice - close <= 250 Thenf = 1Elsef = 0EndifIf Shortonmarket and e = 1 and f = 1 ThenExitshort at marketEndif// TradesIF ADLGO1 and ADLGO2 and Average[10](close) CROSSES over Average[40](close) THENBUY 1 CONTRACT AT MARKETEndifIF ADSGO1 and ADSGO2 and Average[10](close) CROSSES under Average[40](close) THENSELLSHORT 1 CONTRACT AT MARKETEndifSet stop ploss 250Set target pprofit 250Apologies…I have added the missing variables so that it can run. Thanks for helping…
02/11/2021 at 11:40 AM #161054I just run it in AutoTrading.
I’ll wait for errors, if any, then I’ll report what happened.
1 user thanked author for this post.
02/11/2021 at 2:46 PM #16109002/11/2021 at 3:50 PM #16110302/15/2021 at 5:09 PM #16151502/15/2021 at 5:10 PM #161516 -
AuthorPosts
Find exclusive trading pro-tools on