strategy.risk.allow_entry_in() - Pine Script Function
strategy.risk.allow_entry_in()
Section titled “strategy.risk.allow_entry_in()”Overview
Section titled “Overview”This function can be used to specify in which market direction the strategy.entry function is allowed to open positions.
Syntax
Section titled “Syntax”strategy.risk.allow_entry_in(value) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| value | simple string | The allowed direction. Possible values: strategy.direction.all |
| strategy.direction.long | — | — |
| strategy.direction.short | — | — |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("strategy.risk.allow_entry_in")strategy.risk.allow_entry_in(strategy.direction.long)if open > closestrategy.entry("Long", strategy.long)// Instead of opening a short position with 10 contracts, this command will close long entries.if open < closestrategy.entry("Short", strategy.short, qty = 10)