Strategy Trade Excursion Report - Demo by Ku_Hero

By Ku_Hero

Performance Metrics

Description

Strategy Trade Excursion Report - DemoThis strategy is a usage example for the ExcursionReport library, which adds a MAE / MFE report (distribution of adverse and favorable moves per trade, plus stop / target what-if tables) to a strategy. The trading rule below only exists to produce trades for the report. It is not a recommended trading method and it is not presented as a profitable system.EXAMPLE RULE- Long when the 20-period SMA crosses above the 50-period SMA, short on the opposite cross (the position is reversed).- Stop distance = ATR(14) x 1.5 on the signal bar, rounded to the tick (at least 1 tick). Target = stop distance x 2.- Both exits are sent to strategy.exit() as tick distances (loss / profit), so TradingView measures them from the actual fill price.- No time-of-day or session conditions.DEFAULT PROPERTIES AND WHY- Initial capital 10,000, account currency USD: a modest account size, the same amount on every symbol.- 10% of equity per trade, margin 100% (no leverage): position size stays small relative to the account.- Commission 0.02% per order and slippage 2 ticks: rough costs so that the backtest is not cost-free. Adjust them to your market and broker.- Pyramiding 0: one position at a time.HOW THE LIBRARY IS USED HERE import Ku_Hero/ExcursionReport/1 as xr ... xr.run(stopDistance = stopDist, stopTiming = stopTim, includeCommission = inclCom, slLevels = slLevels, tpLevels = tpLevels, levelUnit = lvUnit, tablePosition = tPos, textSize = tSize, showTable = showTbl)stopDist is fixed on the signal bar and is the same distance used in strategy.exit(), so the demo uses stopTiming = "Signal bar" and this distance becomes 1R. In your own strategy, use the version number shown in the library's import line.INPUTS- Example rule: fast / slow MA length, ATR length, stop = ATR x, target = stop distance x.- Report: stop levels and target levels (1 to 5 each, comma separated), stop recorded from (Signal bar / Fill bar), include entry commission (off by default = pure price moves), level unit (R / Price), table position (top left can overlap the chart legend), text size, show table.READING THE TABLE- MAE / MFE rows: mean and percentiles of the adverse and favorable moves, in price and in R.- "If stop were X": share of winners whose MAE reached X. A high share at a small X means many winners went through a drawdown of that size before closing in profit.- "If target were Y": share of all trades whose MFE reached Y. In this demo, trades that hit the 2R target show about 2.0R, so the "Y = 2R" row matches the share of trades closed at the target. A stopped trade can show slightly more than 1R MAE because of stop slippage.- "Not in R" appears only when some trades had a stop on the wrong side of the fill.LIMITATIONSSame as the library: hindsight only (the strategy is not re-run with other stops or targets), bar-based backtest assumptions, R measured from the fill price. The numbers depend on the symbol, timeframe, period and the example parameters.This is a measurement example. It does not give trading signals and does not predict future results. Past backtest results do not guarantee future results.---【日本語】Strategy Trade Excursion Report - Demoライブラリ ExcursionReport(ストラテジーに MAE/MFE の分布表と、損切り・利確の「もしも」の集計を加えるもの)の使い方の見本です。- 売買ルールは、レポートを出すためにトレードを発生させる例にすぎません。売買手法として勧めるものではなく、利益が出るルールとして示すものでもありません。- 例のルール:SMA20 と SMA50 のクロスで売買(反対のクロスでドテン)。損切り幅=シグナル足の ATR(14)×1.5(ティック単位に丸め)、利確=損切り幅×2。どちらも約定価格からのティック数で strategy.exit() に渡すため、表の「Y = 2R」の行は利確で決済したトレードの割合とそろいます。時間帯の条件は使っていません。- 既定の設定:初期資金 10,000(口座通貨 USD)、1回の取引は資金の 10%、証拠金 100%(レバレッジなし)、手数料は1注文 0.02%、スリッページ 2 ティック、同時に持つポジションは1つ。手数料とスリッページはお使いの市場に合わせて変えてください。- 損切り幅はシグナル足で決めて strategy.exit() と同じ値を渡すので、stopTiming は "Signal bar"、この幅が 1R です。- 限界:あと知恵の集計で、損切りや利確を変えた場合の損益を計算し直すものではありません。結果は銘柄・時間足・期間・パラメーターで変わります。表を左上に置くと凡例と重なることがあります。使い方の見本です。売買シグナルや将来の成績を示すものではありません。過去のバックテストの結果は将来の成績を保証しません。

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView