indicator negative entry or zero parameter error message

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #145026 quote
    sulimaster
    Participant
    Average

    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

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    period = 10
    type = 0
     
    smaHigh=Average[period,type](high)
    smaLow=Average[period,type](low)
    if close>smaHigh then
    Hlv=1
    elsif close<smaLow then
    Hlv=-1
    else
    Hlv=Hlv[1]
    endif
     
    if Hlv<0 then
    sslDown=smaHigh
    else
    sslDown=smaLow
    endif
    if Hlv<0 then
    sslUp=smaLow
    else
    sslUp=smaHigh
    endif
    
    x = AroonUp[10]
    y = AroonDown[10]
    
    ATR = AverageTrueRange[14](close)
    
    //POSITIONPERF(1) < 0 AND TRADEPRICE(2) > TRADEPRICE(1) AND
    IF ((x[1] > y[1]) AND (x[1] > 70)) AND (x > y) THEN
    a = 1
    ELSE
    a = 0
    ENDIF
    
    //POSITIONPERF(1) < 0 AND TRADEPRICE(2) < TRADEPRICE(1) AND
    IF ((x[1] < y[1]) AND (y[1] > 70)) AND (x < y) THEN
    b = 1
    ELSE
    b = 0
    ENDIF
    
    // Conditions to enter long positions
    
    IF NOT LONGONMARKET AND a = 0 AND ATR < 500 AND (x > y) AND (x > 70) AND (sslUp > sslDown) THEN
    BUY 0.2 PERPOINT AT MARKET
    SET STOP LOSS 1.5 * ATR
    ENDIF
    
    // Conditions to exit long positions
    
    IF (sslUP < sslDown) OR (y > x) THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    
    IF NOT SHORTONMARKET AND b = 0 AND ATR < 500 AND (sslDown > sslUp) AND (y > 70) AND (y > x) THEN
    SELLSHORT 0.2 PERPOINT AT MARKET
    SET STOP LOSS 1.5 * ATR
    ENDIF
    
    // Conditions to exit short positions
    
    IF (sslUP > sslDown) OR (x > y) THEN
    EXITSHORT AT MARKET
    ENDIF
    
    c = BARINDEX - TRADEINDEX
    
    IF LONGONMARKET AND (highest[c](high) - TRADEPRICE) > 500 THEN
    SET STOP TRAILING 100
    ELSIF SHORTONMARKET AND (TRADEPRICE - lowest[c](low)) > 500 THEN
    SET STOP TRAILING 100
    ENDIF
    
    #145028 quote
    robertogozzi
    Moderator
    Master

    Try replacing line 73 with this one to make sure C is not zero:

    c = max(1,BARINDEX - TRADEINDEX)
    sulimaster thanked this post
    #145054 quote
    sulimaster
    Participant
    Average

    Thanks 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?

    #145059 quote
    robertogozzi
    Moderator
    Master

    No, 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.

    Nicolas and sulimaster thanked this post
    #145091 quote
    Dow Jones
    Participant
    Veteran

    I 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

    sulimaster thanked this post
    #161017 quote
    Johann
    Participant
    Average
    // Up Conditions
    
    ADLGO1= Close - Average[30](close)>Average[10](Close - Average[30](close))
    ADLGO2= Close - Average[30](close)>0
    
    // Conditions Down
    
    ADSGO1= Close - Average[30](close)<Average[10](Close - Average[30](close))
    ADSGO2= Close - Average[30](close)<0

    Hi 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?

    #161019 quote
    robertogozzi
    Moderator
    Master

    There can’t be an error in those two lines, since all parameters are positive constants.

    The error must be somewhere else.

    #161022 quote
    Johann
    Participant
    Average
    //Inactivity - Longs
    
    If Barindex - Tradeindex = 106 Then
    c = 1
    Else
    c = 0
    Endif
    If close - positionprice < 250 Then
    d = 1
    Else
    d = 0
    Endif
    If Longonmarket and c = 1 and d = 1 Then
    Sell at market
    Endif
    
    //Inactivity - Shorts
    
    If Barindex - Tradeindex >= 68 Then
    e = 1
    Else
    e = 0
    Endif
    If positionprice - close <= 250 Then
    f = 1
    Else
    f = 0
    Endif
    If Shortonmarket and e = 1 and f = 1 Then
    Exitshort at market
    Endif
    
    // Trades
    IF ADLGO1 and ADLGO2 and Average[10](close) CROSSES over Average[40](close) THEN
    BUY 1 CONTRACT AT MARKET
    
    IF  ADSGO1 and ADSGO2 and Average[10](close) CROSSES under Average[40](close) THEN
    SELLSHORT 1 CONTRACT AT MARKET

    Thanks 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…?

    #161036 quote
    robertogozzi
    Moderator
    Master

    I 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.

    #161053 quote
    Johann
    Participant
    Average
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    Timeframe(daily,updateonclose)
    // Up Conditions
     
    ADLGO1= Close - Average[30](close)>Average[10](Close - Average[30](close))
    ADLGO2= Close - Average[30](close)>0
     
    // Conditions Down
     
    ADSGO1= Close - Average[30](close)<Average[10](Close - Average[30](close))
    ADSGO2= Close - Average[30](close)<0
    
    //Inactivity - Longs
    Timeframe(default)
    If Barindex - Tradeindex = 106 Then
    c = 1
    Else
    c = 0
    Endif
    If close - positionprice < 250 Then
    d = 1
    Else
    d = 0
    Endif
    If Longonmarket and c = 1 and d = 1 Then
    Sell at market
    Endif
    
    
    //Inactivity - Shorts
    
    If Barindex - Tradeindex >= 68 Then
    e = 1
    Else
    e = 0
    Endif
    If positionprice - close <= 250 Then
    f = 1
    Else
    f = 0
    Endif
    If Shortonmarket and e = 1 and f = 1 Then
    Exitshort at market
    Endif
    
    
    // Trades
    IF ADLGO1 and ADLGO2 and Average[10](close) CROSSES over Average[40](close) THEN
    BUY 1 CONTRACT AT MARKET
    Endif
    
    IF  ADSGO1 and ADSGO2 and Average[10](close) CROSSES under Average[40](close) THEN
    SELLSHORT 1 CONTRACT AT MARKET
    Endif
    Set stop ploss 250
    Set target pprofit 250

    Apologies…I have added the missing variables so that it can run. Thanks for helping…

    #161054 quote
    robertogozzi
    Moderator
    Master

    I just run it in AutoTrading.

    I’ll wait for errors, if any, then I’ll report what happened.

    Johann thanked this post
    #161090 quote
    robertogozzi
    Moderator
    Master

    It already entered a couple of trades with no errors.

    Johann thanked this post
    #161103 quote
    Nicolas
    Keymaster
    Master

    Let me know if that error occur again please.

    Johann thanked this post
    #161515 quote
    Johann
    Participant
    Average

    Yes thank you. I have experienced the same thing it did a couple of trades no problem and then suddenly it happened…?

    #161516 quote
    Johann
    Participant
    Average

    Will do thank you…

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.

indicator negative entry or zero parameter error message


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
sulimaster @sulimaster Participant
Summary

This topic contains 15 replies,
has 6 voices, and was last updated by juanj
5 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/23/2020
Status: Active
Attachments: No files
Logo Logo
Loading...