Trailing stops with previous highs and lows

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #81720 quote
    chrischris
    Participant
    Junior

    hello

    I’m looking to code a trailing stop based on previous lows for long positions and previous highs for short positions.

    I tested the following code for long positions which used price as the number of bps from the open;

    if longonmarket then
    SET STOP trailing lowest[5](low)
    endif

    I then tried the following, which didn’t seem to work either;

    if longonmarket then
    SET STOP trailing (close - lowest[a](low))
    endif

    I’d greatly appreciate any tips or suggestions on how to solve this.

    Best

    Chris

    #81736 quote
    NicolasNicolas
    Keymaster
    Legend

    You should avoid using the trailing stop internal function and prefer a coded one with STOP/LIMIT orders. An example in this blog article: Create stoploss with indicator informations in ProOrder

    For a long order, your moving stoploss could be set like this:

    if longonmarket then 
     sell at lowest[5](low) stop
    endif
    chris thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

Trailing stops with previous highs and lows


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
chris @oceanchris Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
8 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/01/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...