Custom Take Profit Exit


New member
Goodmorning Family,

Could someone please look at this script and tell me What I am doing wrong. I am trying to create a Take Profit Condition based on a 4hr ATR. Though the strategy will plot an exit, The strategy is taking me out of trades far too early. This is just one example of the many ways ive tried to configure it. I think I've started to over think it at this point.

"Base" is the def for the MA on the chart.

def HitTP1 = (EntryPrice() - Base) + ATR < Open[-1];


Active member
I am no where near adept at coding but it seems to me like your syntax may be off a bit. Like you need another or different modifier in there with the <. At first blush it looks like X = A + B < C. X equals A plus B which is less than C.
Last edited:


The ATR < Open[-1] is a logical expression while the EntryPrice() - Base is numeric.

what are you trying to do with the logic.

Also, be cautious when using future data [-1] in indicators and strategies. We can not look beyond the right edge of charts.

Similar threads