Static value at the time of Entry Price



How would i set a static price at the time of order entry when creating a strategy. I'm looking to take the EntryPrice() - previous swing low value at the time of entry to help me create a profit target. What i'm noticing is that if there is an uptrend, it will constantly take the most recent swing low and it'll take me out of the trade early before the initial profit target is met.

I've tried:
def ExitpriceProfit_Long = high > (EntryPrice() + (EntryPrice() - pll)); #pll is equal to previous lower low.
I've tried to use rec pll thinking it would hold it as a constant at the time but doesn't seem to.

Any ideas?
Last edited:


Active member
You can maintain a constant by doing something along the lines of:

1. set ExitPriceProfit_Long to Double.NaN if there is no EntryPrice()
2. set ExitPriceProfit_Long to ExitPriceProfit_Long[1] if it is not a double.nan

I put together something that does that sort of thing here:
You may be able to mod it to plot your exit price instead of the entry price.

There are LOADS of caveats with this, some of which are explained in the referenced thread.

Perhaps this is a start, maybe it gets you thinking in a productive direction. Perhaps not. :)

Happy Trading,

Similar threads