//version=5 indicator("4th Day Performance After 3 Down Days", overlay=true)
// Define the starting date for 5 years ago fromDate = timestamp(year=year - 5, month=1, day=1, hour=0, minute=0)
// Variables to track market performance isDown = close < open threeDaysDown = isDown[1] and isDown[2] and isDown[3] and (time >= fromDate)
// Variables to store entry and exit points var float entryPrice = na var float exitPrice = na var float totalPnL = 0.0 var int tradeCount = 0 var int positiveDays = 0 var int negativeDays = 0
if threeDaysDown entryPrice := close[1] // 3rd day close exitPrice := close // 4th day close pnl = exitPrice - entryPrice totalPnL += pnl tradeCount += 1 if pnl > 0 positiveDays += 1 else if pnl < 0 negativeDays += 1
// Display total PnL, trade count, positive and negative day counts defineTable() => var table myTable = table.new(position.top_right, 5, 2, bgcolor=color.new(color.white, 90)) table.cell(myTable, 0, 0, "Metric", text_color=color.black, bgcolor=color.new(color.gray, 70)) table.cell(myTable, 0, 1, "Value", text_color=color.black, bgcolor=color.new(color.gray, 70)) myTable