OPEN-SOURCE SCRIPT
Railway Track Pattern - Nifty 50

//version=5
indicator("Railway Track Pattern - Nifty 50", overlay=true)
// Settings
bodyThreshold = input.float(0.8, title="Minimum Body Overlap (%)", minval=0.5, maxval=1.0)
// Candle Body Sizes
bodySize1 = math.abs(close[1] - open[1])
bodySize2 = math.abs(close - open)
// Candle Directions
isBullishRail = close[1] < open[1] and close > open // Red followed by Green
isBearishRail = close[1] > open[1] and close < open // Green followed by Red
// Overlap Check (at least 80% body overlap)
overlapLow = math.max(open[1], close[1])
overlapHigh = math.min(open[1], close[1])
overlapLow2 = math.max(open, close)
overlapHigh2 = math.min(open, close)
bodyOverlap = math.min(overlapHigh, overlapHigh2) - math.max(overlapLow, overlapLow2)
minBodySize = math.min(bodySize1, bodySize2)
overlapRatio = bodyOverlap / minBodySize
railwayBullish = isBullishRail and overlapRatio >= bodyThreshold
railwayBearish = isBearishRail and overlapRatio >= bodyThreshold
// Plotting
plotshape(railwayBullish, title="Bullish Railway", style=shape.labelup, location=location.belowbar, color=color.green, text="🚆 Buy")
plotshape(railwayBearish, title="Bearish Railway", style=shape.labeldown, location=location.abovebar, color=color.red, text="🚆 Sell")
indicator("Railway Track Pattern - Nifty 50", overlay=true)
// Settings
bodyThreshold = input.float(0.8, title="Minimum Body Overlap (%)", minval=0.5, maxval=1.0)
// Candle Body Sizes
bodySize1 = math.abs(close[1] - open[1])
bodySize2 = math.abs(close - open)
// Candle Directions
isBullishRail = close[1] < open[1] and close > open // Red followed by Green
isBearishRail = close[1] > open[1] and close < open // Green followed by Red
// Overlap Check (at least 80% body overlap)
overlapLow = math.max(open[1], close[1])
overlapHigh = math.min(open[1], close[1])
overlapLow2 = math.max(open, close)
overlapHigh2 = math.min(open, close)
bodyOverlap = math.min(overlapHigh, overlapHigh2) - math.max(overlapLow, overlapLow2)
minBodySize = math.min(bodySize1, bodySize2)
overlapRatio = bodyOverlap / minBodySize
railwayBullish = isBullishRail and overlapRatio >= bodyThreshold
railwayBearish = isBearishRail and overlapRatio >= bodyThreshold
// Plotting
plotshape(railwayBullish, title="Bullish Railway", style=shape.labelup, location=location.belowbar, color=color.green, text="🚆 Buy")
plotshape(railwayBearish, title="Bearish Railway", style=shape.labeldown, location=location.abovebar, color=color.red, text="🚆 Sell")
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.