Why are these stoplosses not removed?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #94103 quote
    deletedaccount06012021
    Participant
    New

    Hi everyone:

    Am new to ProRealTime, and trying to get my head around the automated programming.

    I’ve hit this stumbling block, which is completely baffling me, so am hoping someone can help me understand why the system is doing what it’s doing.

    See attached screen capture.

    I have code which is supposed to completely remove all stoplosses (point 1 on attachment)

    When graphing the value of the variable “sl”, it says the value is “1” (point 2 on attachment)

    That means, the stoploss should be set to the SuperTrend line, which it appears to be (point 3 on attachment)

    Yet, it still has a stoploss associated with the line the PSAR is on, and all new orders are cancelled out immediately by it (point 4 on attachment)

    Why is this? The 4 lines of code I purposely put in (directly from the pdf manual) should cancel out all the previously set stoplosses, correct? If so, why are the orders between the two stoploss lines being cancelled out by a stoploss? (the yellow square indicator above the bars says so 🙂 )

    Thank you

    PS: there is no trailing stoploss set anywhere in the code. Even if there was, it should be cancelled out too by the 4 lines of code highlighted in point 1, correct?

    Capture2-2.jpg Capture2-2.jpg
    #94121 quote
    Vonasi
    Moderator
    Master

    There is a similar discussion here:

    SET value at zero weird results.

    It seems from your findings that SET STOP pLOSS 0 is still not working. I would use SET STOP %LOSS 100 instead as this should work and only ever get hit if price = zero which should never happen.

    #94122 quote
    Vonasi
    Moderator
    Master

    I’ve just read your code more closely and I think you mis-understand how SET STOP LOSS/pLOSS/%LOSS/$LOSS works. The code will only set the order for the last SET STOP instruction that is read. Usually people have it at the end of the code for this reason. Calculate the distance the stop needs to be in the code and then give one instruction at the end of the code. I assume your supertendindicator and psarindicator values are calculated as a distance in pips rather than as a price?

    #94124 quote
    deletedaccount06012021
    Participant
    New

    The code will only set the order for the last SET STOP instruction that is read. Usually people have it at the end of the code for this reason.

    If that’s the case, I have changed my code to the following:

    sl = 0
    SET STOP pLOSS 0
    IF (c20) THEN
    SET STOP pLOSS SuperTrendIndicator
    sl = 1
    GRAPHONPRICE SuperTrendIndicator as "StopLoss set to ST"
    ENDIF
    IF ((NOT c20) AND (c1 AND (PSARIndicator > SuperTrendIndicator))) THEN
    SET STOP pLOSS PSARIndicator
    sl = 2
    GRAPHONPRICE PSARIndicator as "StopLoss set to PSAR"
    ENDIF
    GRAPH sl as "Stop Loss"

    and it still doesn’t make a difference.

    The last line ‘read’ could be one of the stoploss lines in the “IF” statements. By their very construct, only 1 can be true. If neither are true, then the last line read should be the one before the “IF” statements, correct?

    If not, then how is it possible to set dynamic STOP LOSS values based on various calculations?

     

    I assume your supertendindicator and psarindicator values are calculated as a distance in pips rather than as a price?

    Those values are the actual value of the PSAR or SuperTrend. For example:

    PSARIndicator = SAR[0.02,0.02,0.2]

    Is that the correct way to go about it?

    Thank you.

    #94126 quote
    Nicolas
    Keymaster
    Master

    SET STOP PLOSS is a distance in full points/pips

    SET STOP LOSS is a distance in price

    Don’t use these instructions to set a stoploss with an indicator with a price level, but only with a distance.

    thanked this post
    #94127 quote
    Vonasi
    Moderator
    Master

    Those values are the actual value of the PSAR or SuperTrend. For example: 1 PSARIndicator = SAR[0.02,0.02,0.2] Is that the correct way to go about it?

    No. The value must be a distance in pips, $ or % of the opening price. So SET STOP PLOSS 20 would set a stop loss 20 pips below or above the position price. Any time a new SET STOP PLOSS instruction is read with a different value the stop loss is moved to the new distance from the position price.

    thanked this post
    #94128 quote
    Vonasi
    Moderator
    Master

    Use SELL AT x STOP and EXITSHORT at x STOP if you want to sell at an exact price. You will have to place these orders at every bar open as they last one bar only and are cancelled at bar close.

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

Why are these stoplosses not removed?


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by Vonasi
6 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/20/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...