Code query Trailing stop

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #71034 quote
    ChrisNYE
    Participant
    Senior

    Hello,

    I need help in the coding of a trailing stop strategy.

    As a hypothetical example I am risking 200 (1xATR) pips stop loss to take profit at 800 (4xATR) pips limit order. Q: What is the code to trail my stop to break even after the price has moved 400 (2xATR) pips in my favour?

    Thank you

    #71119 quote
    Nicolas
    Keymaster
    Master

    You can test this simple code example, for a long order: (I assume “400” is in points, not money).

    if not onmarket then 
     breakeven=0
    endif
    
    if longonmarket then 
     if close-tradeprice(1)>=400 then 
      breakeven = 1
     endif
     if breakeven then 
      sell at tradeprice(1) stop
     endif
    endif
    
    #71130 quote
    Vonasi
    Moderator
    Master

    This may have been better posted in the ProOrder Forum as it is auto trading related rather here which is for indicator related topics.

    Just pointing it out as I spotted that this is only your third topic started and you might not have worked out where the best place to go for help is yet! 🙂

    #71141 quote
    Nicolas
    Keymaster
    Master

    Good spot @Vonasi ! You are a moderator who does not know himself! Interested?

    #71161 quote
    Vonasi
    Moderator
    Master

    Good spot @vonasi ! You are a moderator who does not know himself! Interested?

    I’m flattered but not sure what it would really involve. Do you have my email address on record to email me to chat about it?

    If you are serious that is!

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

Code query Trailing stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ChrisNYE @chrisnye Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Vonasi
7 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/21/2018
Status: Active
Attachments: No files
Logo Logo
Loading...