Strategy
97 entries. What each one takes, what it returns, and a working example.
The value is constant ("USD"); multi-currency/FX conversion is not modeled yet.
label(close, accountCurrency())
Attaches the currency label (USD) to price.
Does not return a value; it produces an alert event when the condition turns from false to true on the last bar.
v0.1: run output only; the alert center will be connected in a later phase.
alertcondition(condition, title?, message?)
Returns nothing; registers an alert on the rising edge (false→true) of the condition.
Distinct from `alert()`: `alertcondition` is condition-based and edge-triggered (the first bar the condition turns true). Takes a compile-time constant title/message.
alertcondition(crossover(close, sma(close, 50)), "Kesişim", "Fiyat SMA50'yi yukarı kesti")
Alerts on the bar where price crosses above SMA50.
Returns nothing. Prevents opening a new position in the disallowed direction.
When a signal arrives in the disallowed direction, no new position opens; an open opposite position is CLOSED (not reversed). strategy.direction.all (default) applies no restriction.
allowEntryIn(strategy.direction.long) enterLong(rsi(close,14) < 30) enterShort(rsi(close,14) > 70)
When the short signal arrives, the open long closes; no new short opens.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Average absolute-currency loss of closed losing trades (running, positive).
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Returns the average profit/loss per trade ((gross profit − gross loss) / closed trades) as a running series.
Returns 0 when there are no closed trades yet (no division by zero).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(avgTrade(), "Ort. İşlem")
Plots the average per-trade result.
The absolute-currency version of avgTrade (pnlPct/100 x notional). The percent name (avgTrade) is unchanged and backward-compatible.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Returns nothing; it cancels the pending order with the given id.
The same id is cleared from both a pending entry (limit/stop) order and a pending exit order. If no such order exists, it does nothing.
enterLong(barIndex==0, id='A', limit=close*0.98) cancel('A', when=barIndex==3) exit(barIndex==40)
The 'A' limit order placed on bar 0 is cancelled on bar 3 if it has not filled.
enterLong(barIndex==0, id='A', limit=close*0.97) cancel('A', when=close < lowest(low,20)) exit(barIndex==40)
If price breaks below the 20-bar low, the 'A' limit order is canceled and no trade opens.
Returns nothing; it cancels all pending orders.
All pending entry and pending exit orders are cleared together.
enterLong(barIndex==0, id='A', limit=close*0.98) enterLong(barIndex==0, id='B', stop=close*1.02) cancelAll(when=barIndex==2) exit(barIndex==40)
On bar 2 both the A and B pending orders are cancelled; if unfilled, no trade opens.
enterLong(barIndex==0, id='A', limit=close*0.98) enterShort(barIndex==0, id='B', stop=close*1.02) cancelAll(when=rsi(close,14) > 60) exit(barIndex==40)
When RSI rises above 60, both the A and B pending orders are cleared.
Alias of `equity()`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(cash(), "Nakit")
Plots the equity curve.
Returns nothing. On a bar where the condition is true, closes the ENTIRE open position (all legs) at market — at the open of the NEXT bar after the signal.
Uses the same exit path and timing as exit() (a market exit fills at the next bar's open) but without the fromEntry/qtyPct filter — it always closes all. Closes every remaining leg in a pyramided or partially-closed position. Calling it with no open position does nothing.
enterLong(crossover(close, sma(close,20))) closeAll(crossunder(close, sma(close,20))) plot(close)
Buys when price crosses above the 20-period average, closes the whole position when it crosses below.
Returns nothing; calls `exit(condition)` on the true bar (full exit).
NOTE: the `oran` (ratio) parameter exists in the signature but currently has no effect — a FULL close is performed, not partial. For partial exits use `exit(condition, qtyPct=...)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) closePart(crossunder(close, sma(close, 30)))
Fully closes the position on the down-cross.
The closed trade's round-trip (entry+exit) commission cost — in currency.
The sum of entry and exit commission (commission rate only; slippage NOT included). Leverage/margin and position size are accounted for.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeCommission(-1), "Komisyon")
Returns the last closed trade's round-trip commission cost.
Returns the entry bar index of the n-th closed trade (resolved from entry time).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeEntryBar(-1), "Giriş Barı")
Plots the last trade's entry bar index.
Entry comment — NOT tracked; returns empty string.
This field is not tracked yet; always returns an empty string (present for syntax compatibility).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) label(close, closedTradeEntryComment(-1))
Returns empty string (no comment tracking).
Entry order id — NOT tracked; returns empty string.
This field is not tracked yet; always returns an empty string (present for syntax compatibility).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) label(close, closedTradeEntryId(-1))
Returns empty string (no id tracking).
Entry price of the n-th closed trade — alias of `tradeEntryPrice(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeEntryPrice(0), "Giriş")
Plots the closed trade's entry price.
Entry time of the n-th closed trade — alias of `tradeEntryTime(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeEntryTime(0), "Giriş Zamanı")
Plots the closed trade's entry time.
Returns the exit bar index of the n-th closed trade (resolved from exit time).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeExitBar(-1), "Çıkış Barı")
Plots the last trade's exit bar index.
Returns the exit reason/comment (text) of the n-th closed trade; empty string if none.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) label(close, closedTradeExitComment(-1))
Labels the last trade's exit reason.
Exit order id — NOT tracked; returns empty string.
This field is not tracked yet; always returns an empty string (present for syntax compatibility).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) label(close, closedTradeExitId(-1))
Returns empty string.
Exit price of the n-th closed trade — alias of `tradeExitPrice(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeExitPrice(0), "Çıkış")
Plots the closed trade's exit price.
The automatic exit reason code (signal/stop/target/trail/partial1/partial2/eod/liq/manual/risk/exit).
This value used to be returned by closedTradeExitComment() by mistake; they are now separate: comment = user note, reason = automatic reason code.
Exit time of the n-th closed trade — alias of `tradeExitTime(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeExitTime(0), "Çıkış Zamanı")
Plots the closed trade's exit time.
The worst drawdown (MAE) the closed trade suffered during its life — in currency.
Pure price movement: commission and carry EXCLUDED — 'how far price went against you', not the account-balance swing. Uses the lowest low for longs, the highest high for shorts; entry and exit bars are included.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeMaxDrawdown(-1), "MAE")
Returns the last closed trade's worst drawdown in currency.
closedTradeMaxDrawdownPercent(n)
The closed trade's worst drawdown (MAE) — percent.
Pure price movement: commission/carry EXCLUDED. Lowest low for longs, highest high for shorts; entry and exit bars included. The percent is on the same scale as P&L percent (leverage included).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeMaxDrawdownPercent(-1), "MAE %")
Returns the last closed trade's worst drawdown percent.
The best run-up (MFE) the closed trade reached during its life — in currency.
Pure price movement: commission and carry EXCLUDED — 'how far price went in your favor'. Uses the highest high for longs, the lowest low for shorts; entry and exit bars are included.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeMaxRunup(-1), "MFE")
Returns the last closed trade's best run-up in currency.
The closed trade's best run-up (MFE) — percent.
Pure price movement: commission/carry EXCLUDED. Highest high for longs, lowest low for shorts; entry and exit bars included. The percent is on the same scale as P&L percent (leverage included).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeMaxRunupPercent(-1), "MFE %")
Returns the last closed trade's best run-up percent.
Returns the n-th closed trade's profit/loss in CURRENCY (pnl% × initial capital / 100).
In currency units. For percent use `closedTradeProfitPercent(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeProfit(-1), "Son İşlem K/Z")
Plots the last closed trade's currency P/L.
Returns the n-th closed trade's profit/loss as a PERCENT (pnl%).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeProfitPercent(-1), "Son İşlem %")
Plots the last closed trade's percent P/L.
Direction/size of the n-th closed trade — alias of `tradeSize(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradeSize(0), "Yön")
Plots the closed trade's direction.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTrades(), "Kapanan İşlem")
Plots cumulative closed-trade count.
Alias of `tradeCount()`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(closedTradesCount(), "Kapanan")
Plots the closed-trade count.
First index of the closed trade list. Trade history is never trimmed here (no cap), so it always returns 0. Provided so that `for i = closedTradesFirstIndex() to...` loops ported from referans dil keep working.
Returns the value UNCHANGED (identity). Since the account and symbol currency are assumed equal, no FX conversion is applied.
Exists for syntax compatibility; real FX conversion is not modeled (accountCurrency is the constant "USD").
plot(convertToAccount(close), "Değer")
Plots the value unchanged.
Returns the value UNCHANGED (identity). No FX conversion is applied.
Same as `convertToAccount` — passthrough placeholder; no FX model.
plot(convertToSymbol(close), "Değer")
Plots the value unchanged.
Returns nothing. When called, sizing switches from the default %equity to a fixed quantity; P&L = quantity × price change.
If never called, the default %equity sizing is kept (existing strategies are unaffected). In quantity mode leverage does not enter P&L; it only sets required margin and the liquidation threshold. If margin is insufficient the trade is skipped (quantity is not trimmed).
defaultEntryQty(2) enterLong(crossover(close, sma(close, 20))) exit(crossunder(close, sma(close, 20))) plot(close)
Takes a fixed 2 units per trade; P&L is computed as 2 × price change.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(drawdownPct(), "Geri-çekilme %")
Plots the running drawdown percentage.
enterLong(condition, stopLoss?, takeProfit?, trailingStop?, id?, limit?, stop?, ocaGroup?, qty?, comment?, stopLossTicks?, takeProfitTicks?, trailTicks?, trailOffsetTicks?, trailFar?, trailNear?, trailThresh1?, trailThresh2?, stopLossAtr?, partial1Pct?, partial1Size?, partial2Pct?, partial2Size?)
Returns nothing; it reports an entry order to the strategy test.
Risk values are percentages (stopLoss=2 means 2%). A market order (no limit/stop) fills at the open of the NEXT bar after the signal — an order can't fill before its own bar closes (realistic timing). If limit or stop is given, a pending order is set up instead (the two are not used together); pending orders fill within the bar when price reaches the level. id + limit/stop gives a pending order list: the same id updates it, different ids wait together. When one of the pending entries sharing an ocaGroup fills, its siblings are auto-cancelled (competing setup: arm a breakout and a pullback order together — the first fill drops the other). With pyramiding(n), up to n entry legs can be added in the same direction.
The rule is passed straight in as a condition; there is no separate order function. Pending orders and scaled entries are all handled by the same call.
enterLong(crossover(close, sma(close,20))) exit(crossunder(close, sma(close,20)))
BUY when price crosses above SMA20, close when it crosses below.
enterLong(barIndex==0, limit=sma(close,20)*0.98) exit(barIndex==40)
A pending limit 2% below SMA20; fills when price drops to that level.
enterShort(condition, stopLoss?, takeProfit?, trailingStop?, id?, limit?, stop?, ocaGroup?, qty?, comment?, stopLossTicks?, takeProfitTicks?, trailTicks?, trailOffsetTicks?, trailFar?, trailNear?, trailThresh1?, trailThresh2?, stopLossAtr?, partial1Pct?, partial1Size?, partial2Pct?, partial2Size?)
Returns nothing; it reports a short entry order to the strategy test.
The short counterpart of enterLong; the same id/limit/stop/pyramiding/ocaGroup rules and fill timing apply (a market order fills at the next bar's open after the signal), and risk values are percentages.
enterShort(crossunder(close, sma(close,20))) exit(crossover(close, sma(close,20)))
SELL when price crosses below SMA20, close when it crosses above.
enterShort(barIndex==0, id='S', stop=sma(close,20)*1.02) exit(barIndex==40)
A pending stop 2% above SMA20; the short fills when price rises to that level.
Reads the plain-text note set via enterLong/Short(comment=...). Separate from id (no tracking/cancel). With pyramiding, the last-added leg's comment is active.
Returns nothing; routes a market order on the true bar. A thin wrapper over enterLong/enterShort.
`order` is an alias for this (identical behavior). The direction argument picks long/short in one call; for stop/take-profit risk arguments use enterLong/enterShort.
yon = close > open ? "long" : "short" entryMarket(crossover(close, sma(close, 20)), yon)
On the crossover bar, a long or short market order depending on the candle direction.
If initial capital is unset, 10000 is assumed. `cash()` is an alias of this.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(equity(), "Sermaye")
Plots the equity curve on a sub-panel.
exit(condition, fromEntry?, qtyPct?, id?, limit?, stop?, comment?, commentProfit?, commentLoss?)
Returns nothing; it triggers a market exit (at the next bar's open) or sets up an id-tagged resting exit order.
If limit/stop is not given, a market exit occurs: it fills at the open of the NEXT bar after the signal (realistic timing, like entries). Only limit or only stop gives an identified pending exit (fills within the bar when price reaches the level). limit and stop together give a bracket (take-profit + stop-loss pair): when one fills, the other is automatically canceled (OCO). qtyPct closes partially; the bracket is one-shot (once filled it is removed, and the remaining entry part is left unprotected).
A single call handles both a market exit and a resting take-profit / stop-loss; when limit and stop are given together, filling one cancels the other.
enterLong(crossover(close, sma(close,10))) exit(crossunder(close, sma(close,10)))
Rule-based immediate exit: close when SMA10 is crossed downward.
enterLong(barIndex==0, id='L') exit(barIndex==5, fromEntry='L', qtyPct=50) exit(barIndex==40)
On bar 5 only 50% of the L entry part is closed; the remainder on bar 40.
Returns the total loss of losing closed trades (gross loss, positive magnitude) as a running series.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(grossLoss(), "Brüt Zarar")
Plots cumulative gross loss.
The absolute-currency version of grossLoss (pnlPct/100 x notional). The percent name (grossLoss) is unchanged and backward-compatible.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(grossProfit(), "Brüt Kâr")
Plots cumulative gross profit.
The absolute-currency version of grossProfit (pnlPct/100 x notional). The percent name (grossProfit) is unchanged and backward-compatible.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
Percent-primary; *Currency suffix gives absolute currency (pnlPct/100 x notional). Losing metrics are positive-abs, consistent with grossLoss.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(lossTrades(), "Kaybeden")
Plots cumulative losing-trade count.
Margin liquidation price for a leveraged position: long -> entry x (1 - 1/leverage), short -> entry x (1 + 1/leverage). Empty when unleveraged (1x) or flat.
Derived from the recorded per-bar position size (running max) / same formula used for liquidation.
Returns nothing. After n consecutive losing days, the open position closes and the strategy halts permanently.
A day counts as losing if its closing equity is lower than its starting equity. Once the limit is breached, the effect is permanent — the strategy will not open another position for the rest of that run.
maxConsecLossDays(2) enterLong(true)
After 2 consecutive losing days, the position closes and the strategy stops entering again.
Derived from the recorded per-bar position size (running max) / same formula used for liquidation.
Derived from the recorded per-bar position size (running max) / same formula used for liquidation.
Derived from the recorded per-bar position size (running max) / same formula used for liquidation.
Returns nothing. When the drawdown exceeds this limit, the open position closes and the strategy halts permanently.
Once the limit is breached, the effect is permanent — the strategy will not open another position for the rest of that run. The drawdown is measured from the strategy's own PEAK equity, not from the entry price — it can trigger even while the position is still profitable relative to entry, if equity has pulled back this much from its own high.
maxDrawdownRisk(10, strategy.percent_of_equity) enterLong(true)
Even if the position is still profitable relative to entry, when equity falls 10% from its own peak the position closes and the strategy stops entering again.
Returns nothing. After n orders fill within the day, the open position closes and no new entry is allowed for the rest of that day.
Intended to limit excessive trading frequency. The limit resets at the next UTC day boundary.
maxIntradayFilledOrders(3) enterLong(barIndex % 2 == 0) enterShort(barIndex % 2 == 1)
When the 3rd order fills that day, the position closes; no new entry opens for the rest of that day.
Returns nothing. When the intraday loss exceeds this limit, the open position closes and no new entry is allowed for the rest of that day.
The restriction applies only for that day; it resets at the next UTC day boundary and the strategy resumes normal operation.
maxIntradayLoss(5, strategy.percent_of_equity) enterLong(true)
When 5% of equity is lost within the day, the position closes; the limit resets the next day.
Returns nothing. In fixed/cash mode (defaultEntryQty or sizeByCash) it caps the maximum reachable size; an order exceeding it is reduced to the cap.
Meaningful only alongside quantity-based sizing (defaultEntryQty/sizeByCash). In the default %equity mode there is no contract notion, so it has no effect and emits a warning when called.
defaultEntryQty(5) maxPositionSize(2) enterLong(crossover(close, sma(close, 20))) exit(crossunder(close, sma(close, 20))) plot(close)
Although 5 units are requested, the position opens up to at most 2 units (reduced to the cap).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(netPnl(), "Net K/Z")
Plots cumulative net profit/loss.
Capital the open position locks up in the account: notional / leverage. Equals the notional without leverage; one tenth of it at 10x. The notional base matches openTradeProfit. Empty value when flat.
The commission the open trade has paid so far (entry only) — in currency. na if no position is open.
Entry commission only (the exit has not happened yet); the sum across all open legs, on remaining size. Slippage excluded.
enterLong(crossover(close, sma(close, 10))) plot(openTradeCommission(), "Açık komisyon")
Returns the entry commission the open position has paid so far (na if flat).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradeEntryBar(), "Açık Giriş Barı")
Plots the open position's entry bar index.
No comment tracking; empty string.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) label(close, openTradeEntryComment())
Returns empty string.
No id tracking; empty string.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) label(close, openTradeEntryId())
Returns empty string.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradeEntryPrice(), "Açık Giriş")
Plots the open position's entry price.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradeEntryTime(), "Açık Giriş Zamanı")
Plots the open position's entry time.
The open trade's worst drawdown so far (MAE) — in currency. na if no position is open.
Pure price movement: commission/carry EXCLUDED. A running 'worst so far' value over the open position; the current bar's low/high is included. Leverage/margin included. NOT 100% identical to TradingView.
enterLong(crossover(close, sma(close, 10))) plot(openTradeMaxDrawdown(), "Açık MAE")
Returns the open position's worst drawdown so far, in currency (na if flat).
The open trade's worst drawdown so far (MAE) — percent. na if no position is open.
Pure price movement: commission/carry EXCLUDED. A running 'worst' percent over the open position; the current bar's low/high is included. Leverage included (same scale as P&L percent). NOT 100% identical to TradingView.
enterLong(crossover(close, sma(close, 10))) plot(openTradeMaxDrawdownPercent(), "Açık MAE %")
Returns the open position's worst drawdown percent so far (na if flat).
The open trade's best run-up so far (MFE) — in currency. na if no position is open.
Pure price movement: commission/carry EXCLUDED. A running 'best so far' value over the open position; the current bar's high/low is included. Leverage/margin included. NOT 100% identical to TradingView.
enterLong(crossover(close, sma(close, 10))) plot(openTradeMaxRunup(), "Açık MFE")
Returns the open position's best run-up so far, in currency (na if flat).
The open trade's best run-up so far (MFE) — percent. na if no position is open.
Pure price movement: commission/carry EXCLUDED. A running 'best' percent over the open position; the current bar's high/low is included. Leverage included (same scale as P&L percent). NOT 100% identical to TradingView.
enterLong(crossover(close, sma(close, 10))) plot(openTradeMaxRunupPercent(), "Açık MFE %")
Returns the open position's best run-up percent so far (na if flat).
Returns the open position's unrealized profit/loss in CURRENCY (unrealized% × initial / 100); na if flat.
For percent use `openTradeProfitPercent()`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradeProfit(), "Açık K/Z")
Plots the open position's currency unrealized P/L.
Returns the open position's unrealized profit/loss as a PERCENT; na if flat.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradeProfitPercent(), "Açık %")
Plots the open position's percent unrealized P/L.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradeSize(), "Açık Yön")
Plots the open position's direction.
At most one open trade is modeled (not broken out by pyramiding levels).
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(openTradesCount(), "Açık İşlem")
Plots whether a position is open (1/0).
First index of the open trade list. Trade history is never trimmed here (no cap), so it always returns 0. Provided so that `for i = openTradesFirstIndex() to...` loops ported from referans dil keep working.
Returns nothing; identical to `entryMarket` — routes a market order on the true bar.
Alias of `entryMarket`. Both call the same core (enterLong/enterShort).
order(crossover(close, sma(close, 20)))
A long market order on the crossover bar.
Gives only the DIRECTION (not the size). For size/entry portions, use positionSize.
enterLong(crossover(close,sma(close,20))) exit(crossunder(close,sma(close,20))) barcolor(iff(position() > 0, "#26a69a", na))
Candles are green on bars where a long is held; flat bars are not colored.
enterLong(crossover(close,sma(close,20))) plot(position(), "yön", "#ff9800")
A stepped direction line ranging between 0 and +1 in the lower pane.
Returns na when flat — guard with `position() != 0` before use.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(positionAvg(), "Giriş Fiyatı")
Plots the open position's entry price.
While position() gives only direction, positionSize reflects the number of open entry portions and partial closes: 3 entry portions → +3, +2.5 after a 50% close.
pyramiding(3) enterLong(rsi(close,14)<40, id='L') exit(rsi(close,14)>60) plot(positionSize(), "boyut", "#2962ff")
Steps in the lower pane: +1→+2→+3, 0 on exit.
enterLong(barIndex==0, id='L') exit(barIndex==10, fromEntry='L', qtyPct=50) plot(positionSize(), "kalan", "#2962ff") exit(barIndex==40)
50% partial exit on bar 10 → size drops from +1 to +0.5.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(runupPct(), "Yükseliş %")
Plots the running run-up percentage.
scan(condition, title?, score?, note?)
Does not return a value; if the condition is met on the last bar, it produces a scan row.
v0.1: run output only; the scanner/persistent record will be connected in a later phase.
Returns how many bars the n-th closed trade lasted.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeBars(0), "Bar Süresi")
Plots the first trade's bar duration.
`closedTradesCount()` is an alias. Not a series — the running total count.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeCount(), "İşlem Sayısı")
Plots the number of trades closed so far.
Returns the entry price of the n-th closed trade.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeEntryPrice(0), "İlk Giriş")
Plots the first closed trade's entry price.
Returns the entry time (epoch ms) of the n-th closed trade.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeEntryTime(0), "Giriş Zamanı")
Plots the first trade's entry time.
Returns the exit price of the n-th closed trade.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeExitPrice(0), "İlk Çıkış")
Plots the first closed trade's exit price.
Returns the exit time (epoch ms) of the n-th closed trade.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeExitTime(0), "Çıkış Zamanı")
Plots the first trade's exit time.
Returns the n-th closed trade's profit/loss as a PERCENT (pnl%).
The unit is PERCENT (not currency). For currency use `closedTradeProfit(n)`.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeProfit(0), "İlk K/Z %")
Plots the first trade's percent P/L.
Returns the direction/size of the n-th closed trade.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(tradeSize(0), "Yön")
Plots the first trade's direction.
enterLong(crossover(close, sma(close, 10))) exit(crossunder(close, sma(close, 10))) plot(winTrades(), "Kazanan")
Plots cumulative winning-trade count.