Error code: stop or limit at a negative price level

Forums ProRealTime English forum General trading discussions Error code: stop or limit at a negative price level

Viewing 4 posts - 1 through 4 (of 4 total)
  • #19416

    Hi everybody!

    I keep getting this error message when i run my code. Has anyone got this if so how did you fix it?

    https://drive.google.com/file/d/0B9vEKQtm4o6veUY3WHFwdEFKNDA/view?usp=sharing

    Thanks before hand!

    #19426

    You surely made a wrong calculation of your stoploss or takeprofit values that are negative ones. These values must be absolute (above 0).

    I could help much further if you can share the code here.

    You can also attach pictures to your post, instead of adding them to your own google drive.

    #19450

     

    //————————————————————————-

    // Main code : SAF40 Mini 1H

    //————————————————————————-

     

    // indicators and parameters

    defparam cumulateorders = false

     

    possize = 2

    // Förklaring vad fastma / slowma [8,1] innebär.

    //0 = Simple,

    //1 = Exponential,

    //2 = Weighted,

    //3 = Wilder’s Smoothed,

    //4 = Triangular,

    //5 = End Point, and

    //6 = Time Series.

     

    fastma = average[8,1](close)

    slowma = average[38,6](close)

     

    longma = average[40,6](close)

     

    bbw = bollingerbandwidth[240](close)

     

    price = close

     

    notradetime = (dayofweek = 5 and time > 230000) or (dayofweek = 1 and time < 013000)

     

    once buyswitch = 0

    once sellswitch = 0

     

    if fastma crosses over slowma then

    tlevel = high

    buyswitch = 1

    sellswitch = 0

    endif

     

    if fastma crosses under slowma then

    tlevel = low

    sellswitch = 1

    buyswitch = 0

    endif

     

    // long entries and short exits

    if buyswitch = 1 and price > tlevel and fastma > slowma and bbw > 0.0359 and price > longma and not notradetime then

    buy possize contract at market

    exitshort at market

    endif

     

    // short entries and long exits

    if sellswitch = 1 and price < tlevel and fastma < slowma and bbw > 0.0359 and price < longma and not notradetime then

    sellshort possize contract at market

    sell at market

    endif

     

    // stops and targets

    set stop ploss 3400 // Org 3400

    set target pprofit 1340 //  Org 1340

     

    // exit strategy

    once tradeext = 0

    if countofposition < countofposition[1] then

    tradeext = 0

    endif

     

    if countoflongshares = possize and high > (positionprice + 910) then

    tradeext = 910

    endif

    if tradeext = 910 then

    sell at positionprice + 465 stop

    endif

     

    if countofshortshares = possize and low < (positionprice – 910) then

    tradeext = -910

    endif

    if tradeext = -910 then

    exitshort at positionprice – 465 stop

    endif

     

    #19568

    If this price is below the current price then this should be a limit order. Because the difference between positionprice – 910 and the low does not necessary have to be greater than 465 when the bar closes. Maybe you can switch to a lower timeframe?

Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login