Enoch_Bets
New member
I am trying to use EntryPrice() to let me know when to sell in my backtest strategy. Originally I just had a condition in my sell condition that read:
def exittrade = My other condition or close < EntryPrice()
This didn't work at all and had no effect. I was looking into solutions and came across one that said you should set the value of EntryPrice() as Double.NaN when not in a trade and only set a value for it while in a trade. This sounds good but I couldn't get the code to work.
def Entry = if isNaN(EntryPrice()) then Entry[1] else EntryPrice();
Although this doesn't throw an error it fails to change anything in my strategy so it is still not working.
Also Ideally I would like to be able to get the low from the day I bought. I figured that wasn't possible as was just trying to get the price I bought at, but if anyone knows how to get the low for the day bought that would be ideal.
def exittrade = My other condition or close < EntryPrice()
This didn't work at all and had no effect. I was looking into solutions and came across one that said you should set the value of EntryPrice() as Double.NaN when not in a trade and only set a value for it while in a trade. This sounds good but I couldn't get the code to work.
def Entry = if isNaN(EntryPrice()) then Entry[1] else EntryPrice();
Although this doesn't throw an error it fails to change anything in my strategy so it is still not working.
Also Ideally I would like to be able to get the low from the day I bought. I figured that wasn't possible as was just trying to get the price I bought at, but if anyone knows how to get the low for the day bought that would be ideal.
Last edited: