# 10% offset from previous high.

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

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!):

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?

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

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;