Dynamic Stop Loss Code Help!

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #115064 quote
    VN
    Participant
    Average

    Hi, I am having difficulty implementing a stop loss strategy, which is as follows:

    EXAMPLE on DAX

    I open a SHORT at 13,300 with an initial STOP LOSS = 10, so I will get stopped if price rises to 13,010.

    But then I want to say, IF price moves down to 12,990, then move the stop level from 13,010 down to 13,000.

    I then want to introduce a tiered approach such that, if

    1. Price reaches 12,950 (X), set stop loss at 12,970 (Y)
    2. Price reaches 12,930 (X), set stop loss at 12,960 (Y)

    I will use X and Y as variables to denote the Current Price and StopLoss levels which I can set based on certain conditions, but I am using fixed prices here to illustrate my point.

    I am using the SET STOP pLOSS X pTRAILING Y instruction to do the above, but this doesn’t work.

    Would be grateful if anyone can help with how I can code this simple example.

    Thanks!

    #115114 quote
    Vonasi
    Moderator
    Master

    You will have better luck finding help with a strategy question if you post in the correct forum. ProBuilder is for indicators and ProOrder is for strategies. I will move your topic to the correct forum – please try to post in the correct forum with future topics.

    I have also tidied up the HTML mess that was in your post.

    #115118 quote
    VN
    Participant
    Average

    ok thanks for moving the post. Was not sure where is best to post it, hopefully now it will now be visible to people :).

    #120743 quote
    robertogozzi
    Moderator
    Master

    Sorry for being so late, I hope you have found a solution.

    In case you haven’t… you’ll find the code you need, ready-made, from line 17 through line 56 at https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/.

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

Dynamic Stop Loss Code Help!


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
VN @vn Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/17/2019
Status: Active
Attachments: No files
Logo Logo
Loading...