stoploss keeps changing per candle

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #163333 quote
    kevin12345
    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
    robertogozzi
    Moderator
    Master

    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
    Nicolas
    Keymaster
    Master

    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.

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 Nicolas
4 years, 11 months ago.

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