Set StopLoss to Indicator value at Entry

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

    Hi there! Perhaps someone can help me.

    I try to set a StopLoss when price break the SAR Indicator (with the value of one bar after entering the trade).

    I know I can define the number of bars to look back, but how can I set it to the value from entering the trade?

    I hope it is clear what I mean.

    #204867 quote
    JS
    Participant
    Senior

    Hi @debux

    If I understand correctly, you want to place the “StopLoss” after entering a position…

    For example, you can use:

    If OnMarket and NOT OnMarket[1] then
    Set Stop Loss …
    EndIf

    #204868 quote
    debux
    Participant
    New

    Thank You! I will try it…

    #204873 quote
    debux
    Participant
    New

    Hi @JS

    unfortunatly it doesn‘t work. I will try to explain the problem in more detail:

    Lets say I enter a long position when overcrossing the parabolic SAR indicator.

    At this moment, the value of the Indicator switches the sides, now the value of the Indicator is lower.

    I would like to set the StopLoss to this new value.

    If i just say, set StopLoss when undercrossing SAR it is not correct,  because the SAR is changing its value after each candle and is moving closer to the price of the underlying.

    Regards, debux

    #204874 quote
    JS
    Participant
    Senior

    Hi @debux

    You can try this…

     

     

    mySAR = SAR[0.02,0.02,0.2]
    
    IF LOW < mySAR and Close < Open THEN
    SellShort 1 contract at Market
    Set Stop Loss mySAR
    ENDIF
    
    IF HIGH > mySAR and Close >= Open THEN
    Buy 1 contract at Market
    Set Stop Loss mySAR
    ENDIF
    #204875 quote
    JS
    Participant
    Senior

    Sorry, “Stop Loss” must be of course “Stop Price” …

     

    DefParam CumulateOrders = False
    
    mySAR = SAR[0.02,0.02,0.2]
    
    IF LOW < mySAR and Close < Open THEN
    SellShort 1 contract at Market
    Set Stop Price mySAR
    ENDIF
    
    IF HIGH > mySAR and Close >= Open THEN
    Buy 1 contract at Market
    Set Stop Price mySAR
    ENDIF
    Nicolas and debux thanked this post
    #205019 quote
    debux
    Participant
    New

    Hi @JS

    Thank you very much for your help. It works now…

    Cheers, debux

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

Set StopLoss to Indicator value at Entry


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
debux @debux Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/25/2022
Status: Active
Attachments: No files
Logo Logo
Loading...