Page 1 of 1

How to add limit buy/sell in strategy

Posted: Wed Sep 30, 2020 5:11 pm
by dandy
Hi there!

Happy to be a new member of the forum. I've followed the course and I am quite new to this.

I understand how an entry signal works when the signal to enter is buying/selling when one indicator crosses the other for example..

But what if I want to trail a limit order that is triggered when the price is hit? For example how would I trail a limit sell that is x ticks above a 50sma? The entry is not based on what an indicator does, rather it is triggered when price hits a parameter in relation to the price of the indicator.

Thanks in advance!

Brad

Re: How to add limit buy/sell in strategy

Posted: Fri Jan 15, 2021 7:37 am
by Matthew
Hi Dandy!

This is not something I have time to try to help you write, but what you need to do is get your SMA price and add X ticks to that price and then input that value into your strategy.exit()'s "stop" parameter.

Here's what the documentation says:
stop (float) An optional parameter. Stop loss (requires a specific price). If it is specified, a stop order is placed to exit market position at the specified price (or worse). Priority of the parameter 'stop' is higher than priority of the parameter 'loss' ('stop' is used instead of 'loss', if its value is not 'NaN'). The default value is 'NaN'.