# How to draw a fixed take profit line above the initial buy price?

Hi. i use the following formula for creating a fixed horizontal line , 200% above my initial BUY signal, to be used as a visual sell signal. however, the line i get is not fixed but keeps changing with every new bar. i tried several other formulas to achieve this goal, but to no avail. can anyone help? Thanks in advance!

_SECTION_BEGIN("Formula 8");

Buy = Cross (EMA (C,15),EMA (C,30));
Sell =Cross (EMA (C,30),EMA (C,15));

ApplyStop( stopTypeprofit, stopModePercent, StopLevel, True );

Equity( 1, 0 ); // evaluate stops, all quotes

SetOption("EveryBarNullCheck", True );
stopline = IIf( InTrade, stoplevel, Null );

PlotShapes(Sell
shapeDownArrow,colorRed,0,High);

Plot( Close,"Price",colorBlack,styleBar);
Plot( stopline, "profit", colorRed,styleline );
_SECTION_END();

Try using the ValueWhen() function.

well, tried hard but failed. can you give me the formula? sounds like a very simple thing, and very
frustrating to having a nice working formula without this line drawn. thanks.

Try this:

``````SetTradeDelays(0,0,0,0);

Buy = Cross (EMA (C,15),EMA (C,30));
Sell =Cross (EMA (C,30),EMA (C,15));

//Equity( 1, 0 ); // evaluate stops, all quotes

ApplyStop( stopTypeprofit, StopModePoint, StopLevel, True );

//SetOption("EveryBarNullCheck", True );
stopline = IIf( InTrade, stoplevel, Null );

PlotShapes(Sell*shapeDownArrow,colorRed,0,High);

Plot( Close,"Price",colorBlack,styleBar);
Plot( stopline, "profit", colorRed,styleline );
``````

First of all, thanks for helping me. nice of you. the profit line indeed is there, however it changes in height as new buy condition is given by the formula. when i turn off the "exrem" i can see it clearly. Can you keep the line fixed after the first BUY order, disregarding other BUY orders until SELL?

I am not sure I am understanding exactly what you are trying to do here...

This code does exactly what you asked... when in long position plot the stop.

Also just FYI - I have a mistake in the first code I put... it changed the stop from Percent to Point.

well, this is what i get. you can see that after some time the profit line suddenly jumps up and remains there. if i delete the "exrem" order from my formula, i get the second graph, which makes it clear why the line jumped: it is because of new "buy" signals in the formula.

this is what i must prevent in order for the profit line to work. it must stay in place after the initial BUY order, no matter how many other BUY orders are issued, until SELL.
hope you can solve this one. Thanks.

This is not the chart of the code you posted above... I can't help if I don't have the correct code.

Just in case, you might want to check this also:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.