karan barsiwal
karan barsiwal

Reputation: 71

How to use stop-limit in Strategy

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

Answers (2)

luizv
luizv

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.


No limit or stop parameters

A simple market order.

strategy.entry(id = "Long", long = true)

limit without stop parameter

A 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 parameter

A 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)

Both stop and limit parameters

A 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

karan barsiwal
karan barsiwal

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

Related Questions