stoploss keeps changing per candle

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #163333 quote
    kevin12345kevin12345
    Participant
    Average

    hi,

    i am trying to set stoploss from the tradeprice (close) to the previous candle low but it keeps changing. how do i fix it?

    if not onmarket and longconditions and buyentry then
    buy 1 contracts at market 
    endif
    
    longstoploss = (close - low[1])*10000
    longtarget = longstoploss
    set stop ploss longstoploss
    set target pprofit longtarget

    thank you

    #163337 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Move line 5 to in between line 2 and 3, just after BUY.

    You should use PipSize, not 10000, to make your code portable. You can remove that multiplication if you also remove the leading “p” from PLOSS and PPROFIT.

    #163407 quote
    NicolasNicolas
    Keymaster
    Legend

    Each time your code is read, your lines 5 and 6 are recalculated, just place them where they are only read just one time when you launch your order.

Viewing 3 posts - 1 through 3 (of 3 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

stoploss keeps changing per candle


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kevin12345 @kevin12345 Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by NicolasNicolas
5 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/07/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...