10% offset from previous high.

Optuma Forums Optuma Scripting 10% offset from previous high.

This topic contains 3 replies, has 2 voices, and was last updated by Darren Darren 2 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #44919

    Terry
    • Topics: 1
    • Replies: 1
    • Posts: 2

    Hi, I have been looking for a script that will place a horizontal line at an entry price with a parallel line offset at 10% lower. If price rises, I want the lines to move to the new high with a new 10% offset.
    I would be using this in the training mode so that as a new high is reached, the 10% offset will move up and give me a new stop loss that is no lower than 10% of the highest high in the trade.

    I hope this is not too confusing.

    Cheers

    Terry

    #44923
    Darren
    Darren
    • Topics: 22
    • Replies: 87
    • Posts: 109

    Thanks Terry. We can do that using the RATCHET() function. As the entry price will be different for each chart then that needs to be hardcoded in to the formula. In this example, the entry price is defined by the Entry1 variable at $25, with the initial stop 10% away (25 * 0.9 = 22.5)

    Then the ratchet function is used to draw the line as the value increases, but it will stay horizontal if it then drops. The IF functions tells the tool to draw whatever is highest: the entry price or the current closing price (P1).

    Copy this formula in to a Show Plot tool, making sure to change the Entry1 value as required:

    Entry1 = 25;
    Stop1 = Entry1 * 0.9;
    P1 = CLOSE();
    P2 = CLOSE()*0.9;
    Plot1 = Ratchet(If(P1 > Entry1, P1, Entry1), START=2017-05-30);
    Plot2 = Ratchet(If(P2 > Stop1, P2, Stop1), START=2017-05-30);
    Plot2.Colour = Red;

    Click on the Ratchet function in the script editor window to select the start date (excuse my backwards American format!):

    Capture

    Plot1 will draw the entry/close price, and Plot2 will draw the same line offset 10%.

    When applied to a chart is should look like this showing the 10% channel, which can also be used in Training Mode. Is this what you had in mind?

    Capture

     

    #44927

    Terry
    • Topics: 1
    • Replies: 1
    • Posts: 2

    Hi Darren,

                       thanks for the rapid reply. I changed the CLOSE commands to HIGH to pick up the highest price for the bar and it seemed to work fine.

    However, if I click on the bottom plot line, it shows me the price of the top line.

    Cheers,

     

    Terry

    #44943
    Darren
    Darren
    • Topics: 22
    • Replies: 87
    • Posts: 109

    Thanks Terry. As it’s a scripting tool it will display the Plot1 value in the label when either line is moused over. The only solution would be to create two separate Show Plot tools:

    Entry:

    Entry1 = 25;
    Stop1 = Entry1 * 0.9;
    P1 = HIGH();
    Plot1 = Ratchet(If(P1 > Entry1, P1, Entry1), START=2017-05-30);

    and for the 10% offset:

    Entry1 = 25;
    Stop1 = Entry1 * 0.9;
    P2 = HIGH()*0.9;
    Plot1 = Ratchet(If(P2 > Stop1, P2, Stop1), START=2017-05-30);
    Plot1.Colour = Red;

     

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close