Lipi Reference
Lipi

Functions

strategy.entry()

Opens a position, or adds to one, in `direction` (`strategy.long` or `strategy.short`). An entry in the opposite direction to the current position first closes that position, then reverses it. `id` names the entry so that `strategy.close` and `strategy.exit` can refer to it. Without `limit` or `stop` it is a market order; with `limit` or `stop` it waits for that price. `qty` overrides the default quantity set in `strategy()`.

Syntax

                strategy.entry(series string id, series string direction, series float qty, series float limit, series float stop, series string oca_name, series string oca_type, series string comment) → void
              

Arguments

id required series string
direction required series string
qty series float
limit series float
stop series float
oca_name series string
oca_type series string
comment series string

Return Type

void

Example


          //@lipi=2
strategy("strategy.entry Example", overlay=true, initial_capital=10000, default_qty_type=strategy.fixed, default_qty_value=1)
if talib.crossover(close, talib.sma(close, 20)) {
    strategy.entry("Long", strategy.long)
}
if talib.crossunder(close, talib.sma(close, 20)) {
    strategy.entry("Short", strategy.short)
}