//@version=5
strategy("Lesson 12 - Reading the report", overlay=true,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=10,
commission_type=strategy.commission.cash_per_contract,
commission_value=0,
slippage=2) // 2 ticks — realistic, not optimistic
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
strategy.entry("Long", strategy.long, when=ta.crossover(fast, slow))
strategy.exit("Long TP/SL", "Long",
stop = strategy.position_avg_price * 0.98,
limit = strategy.position_avg_price * 1.04)
strategy.close("Long", when=ta.crossunder(fast, slow))
plot(fast, "Fast EMA", color=color.blue, linewidth=2)
plot(slow, "Slow EMA", color=color.orange, linewidth=2)
// Live metrics — the four numbers that actually matter.
if barstate.islast
var table t = table.new(position.top_right, 2, 5, border_width=1)
table.cell(t, 0, 0, "Net profit", text_color=color.white)
table.cell(t, 1, 0, str.tostring(strategy.netprofit, "#.##"))
table.cell(t, 0, 1, "Max drawdown", text_color=color.white)
table.cell(t, 1, 1, str.tostring(strategy.max_drawdown, "#.##"))
table.cell(t, 0, 2, "Win rate %", text_color=color.white)
table.cell(t, 1, 2, str.tostring(strategy.wintrades / math.max(strategy.closedtrades, 1) * 100, "#.#"))
table.cell(t, 0, 3, "Profit factor", text_color=color.white)
table.cell(t, 1, 3, str.tostring(strategy.grossprofit / math.max(strategy.grossloss, 1), "#.##"))
table.cell(t, 0, 4, "Closed trades", text_color=color.white)
table.cell(t, 1, 4, str.tostring(strategy.closedtrades))