|Strategy Concept|Best Way to Learn 5 Strategy Command

Yaonology Algorithmic Trading
Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on reddit

August 7, 2020

|Strategy Concept|Best Way to Learn 5 Strategy Command

Many wonder what is the different command of strategy on the TradingView and how to use them for trading. Below is the basic concept of 5 strategy command!

strategy.entry

This command only places entry orders. The function strategy.entry is affected by pyramiding and it can reverse market position correctly. If both ‘limit’ and ‘stop’ parameters are ‘NaN’, the order type is market order.

|Strategy Concept|Best Way to Learn 5 Strategy Command

If an order with the same ID is already pending, it is possible to modify the order. If there is no order with the specified ID, a new order is placed. To deactivate an entry order, the command strategy.cancel or strategy.cancel_all should be used.

strategy.order

It is a command to place order. In comparison to the function strategy.entry, the function strategy.order is not affected by pyramiding. If both ‘limit’ and ‘stop’ parameters are ‘NaN’, the order type is market order.

strategy close

strategy.close

It is a command to exit from the entry with the specified ID. If there were multiple entry orders with the same ID, all of them are exited at once. If there are no open entries with the specified ID by the moment the command is triggered, the command will not come into effect. The command uses market order. Every entry is closed by a separate market order.

|Strategy Concept|Best Way to Learn 5 Strategy Command

strategy.exit

This command allows you to exit a market position or form multiple exit order strategies using a stop loss, profit target or trailing stop. If the function strategy.exit is called once, it exits a position only once. If you want to exit multiple times, the command strategy.exit should be called multiple times. If you use a stop loss and a trailing stop, their order type is ‘stop’, so only one of them is placed (the one that is supposed to be filled first). If all the following parameters ‘profit’, ‘limit’, ‘loss’, ‘stop’, ‘trail_points’, ‘trail_offset’ are ‘NaN’, the command will fail. 

It is not possible to exit a position with a market order using the command strategy.exit. For this, the strategy.close or strategy.close_all commands should be used.

|Strategy Concept|Best Way to Learn 5 Strategy Command
|Strategy Concept|Best Way to Learn 5 Strategy Command

strategy.cancel

It is a command to cancel/deactivate pending orders by referencing their names, which were generated by the functions: strategy.order, strategy.entry and strategy.exit. The function strategy.close or strategy.close_all do not close unfilled orders, thus, you should use the strategy.cancel() and strategy.cancel_all() functions if you want to cancel pending orders.

The formatting of the command is strategy.cancel(id, when), the argument ‘id’ is required while ‘when’ is optional.

Example:

strategy(title = “Yaonology SMA Strategy”)

conditionForBuy = close > sma(close,20)

strategy.entry(“sma_long”, true, 1, when = conditionForBuy)

strategy.cancel(“sma_long”, when = not conditionForBuy) // cancel the entry order with name “long” if conditionForBuy is false

Leave a comment and tell us what you think!

Yaonology

SPY Strategy

Bitcoin Strategy

#algorithmictrading #algotrading #trading #tradingstrategy #bitcoin #sp500 #stock #traderslife #signal #tradingplan #tradingview #setalert  #alert #beginner #easyinvestment #strategy #sellsignal #buysignal #command #strategyorder #strategyentry #strategyclose #strategyexit #strategycancel

My Rewards

This website uses cookies to ensure you get the best experience on our website.

Read Privacy Policy