sorentin

Soren test 222

Say we use strategy.risk.allow_entry_in() to only trade longs. When our script uses the strategy.entry() function to open a short trade, TradingView of course won’t allow our strategy to go short. But that doesn’t mean the trade is ignored. Instead the ‘enter short’ trade – which is actually a sell command – becomes an ‘exit long’ order.

Another way to think about this is the following. The strategy.entry() function can reverse positions: longs into shorts, and shorts into longs. That reverse behaviour gets stopped by strategy.risk.allow_entry_in(). What strategy.entry() instead ends doing is close positions: from long to flat, or from short to flat.

(The example strategies that we discuss later in this article show how strategy.risk.allow_entry_in() makes strategy.entry() close instead of open trades.)

# Can still trade both long or short
strategy.risk.allow_entry_in() can also allow our strategy to trade both long or short. That’s a bit silly, since this is already the default behaviour. But to cod
Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.

Хотите использовать этот скрипт на графике?