SAR Trailing stop

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

    I would find useful to have a trailing stop that will stay below the SAR indicator when buying and vice versa when selling. The same coding I guess would apply if using a Moving average or other indicator.

    I used the below code that gives excellent result in back-testing but it appears is a sort of curve fitting as it does not work in real market.

     

    SAR1 = SAR[0.02,0.02,0.2][1]
    
    // Stops and targets
    
    SET STOP pTRAILING SAR1
    
    #4499 quote
    NicolasNicolas
    Keymaster
    Legend

    Hello Bob, pTRAILING is a pip/point distance between the STOP and the current price. So you have to find this distance by substracting the SAR value and the price one.

    #4546 quote
    BobBob
    Participant
    New

    Thanks Nicolas. Pity because it would have been nice to have a sort of dynamic trailing stop.

    Do you know why when trading through IG with your platform it is not possible to have a stop loss and a trailing stop at the same time?

    Example:

    SET STOP LOSS 20 pTRAILING 10

    Thanks

    #4548 quote
    NicolasNicolas
    Keymaster
    Legend

    The example i shown to you is a dynamic trailing stop. It’s actually the same to have a fixed price or a price difference between 2 points.

    Just to be clear :

    SAR1 = SAR[0.02,0.02,0.2][1]
    
    // Stops and targets
    
    mytrailing = ABS(Open-SAR1)
    
    SET STOP pTRAILING mytrailing 

     

    or you can also change dynamically your stoploss at each new bar :

    SAR1 = SAR[0.02,0.02,0.2][1]
    
    // Stops and targets
    
    mystop = ABS(Open-SAR1)
    
    SET STOP pLOSS mystop 

     

    Of course I made no conditional request to the server to test if the SAR is above or below your price, it will handle by itself if it can place the stoploss for a buy or a sell order.

    von thanked this post
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

SAR Trailing stop


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bob @bob Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/28/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...