Hi All, Sorry if this has been covered, but I haven't seen a direct answer.
Is there a way to code my script so that I exit a position when price falls below a moving average, and (usually) before bar close?
From what I have read so far, the closest way to do this is to sell AtMarket (bar +1) when price hits trigger. However, I would like to sell as soon as price falls below SMA and not wait for close bar. On longer time scales, price can vary significantly between trigger price and bar close price, so I'd like to find a way to avoid that discrepancy.
Can I do a workaround such as something like taking:
SellAtClose(bar + 0, p, "Group3")
...and replacing it with:
SellAtClose(bar + 0, SMA , "Group3")?
Any ideas would be greatly appreciated!
Thanks, Ben.
Size:
Color:
Size:
Color: