Error code: stop or limit at a negative price level

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #19416 quote
    StephanStephan
    Participant
    New

    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 quote
    NicolasNicolas
    Keymaster
    Legend

    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 quote
    StephanStephan
    Participant
    New

     

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

    // 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 quote
    DerekDerek
    Participant
    Veteran
    if tradeext = -910 then
    
    exitshort at positionprice - 465 stop
    
    endif

    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)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Error code: stop or limit at a negative price level


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
Stephan @stephan Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by DerekDerek
9 years, 9 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 12/30/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...