Reputation: 71
I'm trying to place a stop-limit order in my strategy-script but failed to do so.
strategy.entry(id = "Long", long = true, limit=high[1]+10)
I want a market buy order to be placed when the price is above 10 points previous candle.
previous candle high - 200
order to be placed if price crosses 210
Upvotes: 4
Views: 2068
Reputation: 638
At PineScript V5, Strategy.entry
has some quirks. Setting limit
, stop
, or both parameters will give you different results.
At least for V5, your answer in fact didn't give you a stop-limit. You get a market order with a simple stop loss at market. If you really want a stop-limit, probably you want to set stop
and limit
parameters.
Below, some explained examples for each case.
limit
or stop
parametersA simple market order.
strategy.entry(id = "Long", long = true)
limit
without stop
parameterA simple Limit order. Placed to be executed when a advantageous price is reached.
strategy.entry(id = "Long", long = true, limit=high[1]+10)
stop
without limit
parameterA Stop order. Which is kind of a limit order, but placed in a disadvantageous price.
strategy.entry(id = "Long", long = true, stop=high[1]+10)
stop
and limit
parametersA market order with stop-limit stop loss.
strategy.entry(id = "Long", long = true, limit=high[1]+10, stop=high[1]+20)
This last one will result in a market order with a trigger for a Stop-Limit order. In other words, it placed and when stop
price is reached, a limit order at limit
price will be placed. It's possible the order could not be fulfilled.
Upvotes: 2
Reputation: 71
i just figured it out
strategy.entry(id = "Long", long = true, stop=high[1]+10)
you have to use stop instead of limit for placing a stop-limit order
Upvotes: 3