// Define variables
CountPoints = 0 // Counter for consecutive candles where open < close
TotalPips = 0 // Total pips counted
StartPrice = 0 // Price of the first candle that meets the condition
FirstCandleIndex = -1 // Index of the first candle where counting starts
CurrentBar = 0 // Variable to track current bar index
// Initialize variables
CountPoints = 0
TotalPips = 0
StartPrice = 0
FirstCandleIndex = -1
CurrentBar = 0
// Main loop to iterate through bars
while CurrentBar < BarIndex do
// Check condition: open < close for the current bar
if Open < Close then
// If this is the first candle that meets the condition, record its price and index
if CountPoints = 0 then
StartPrice = Open
FirstCandleIndex = CurrentBar
endif
// Increment counter
CountPoints = CountPoints + 1
// Calculate pips from the start price to current bar close
if CountPoints > 1 then
TotalPips = TotalPips + (Close - Open) / PointSize
endif
else
// Check if we've counted more than 3 consecutive candles
if CountPoints > 3 then
// Plot arrow on the first candle where counting started
DrawArrowUp(FirstCandleIndex, Low[FirstCandleIndex] - 10*TickSize)
endif
// Exit loop if condition is not met
endif
wend
// Move to the next bar
CurrentBar = CurrentBar + 1
// Output the total pips counted
PRINT(TotalPips)
return