Hi.
I would like to enter the market with a position.
And leave an order placed if the price falls 1.5% enter with another position.
I have seen that BarHunter places an order.
Thanks!
With a position from which side? If you want to buy lower than a previous buy order (averaging down), you can do that:
if longonmarket then
buy at tradeprice*0.985 limit
endif
You can set the maximum number of positions to buy easily.
Also in this code it places a limit order at the same time that you enter the market 1.5% below the close price otherwise you don’t have an order on the market for the first candle. If there is a big gap down then you might end up with two trades opening at the start of the candle though because we can only use the closing price of the decision candle at this point.
if not longonmarket and (your entry conditions) then
buy 1 contract at market
buy 1 contract at close*0.985 limit
endif
if countofposition < 3 and longonmarket then
buy 1 contract at tradeprice*0.985 limit
endif