Indicator Components
Chaikin Money Flow (CMF):
- The CMF is a volume-weighted average based accumulation and distribution over a specified period.
- It helps to find out the market of buying pressure and selling pressure.
- A positive CMF value indicates buying pressure or that the security is under accumulation in the market, while a negative CMF value implies selling pressure or that the security is under distribution.
Relative Strength Index (RSI):
- The RSI is a momentum oscillator, which measures both the speed and change of price movements.
- It oscillates between 0 to 100 and is often used to identify overbought or oversold conditions.
- Levels above 70 are considered as overbought while levels below 30 are considered oversold.
Martingale Signal:
- This component was based on the Martingale strategy which is increasing bet size after lost bets.
- This indicator creates a “super buy” or “super sell” signal after two false signals in a row.
How the Indicator Works, Parameters
Buy Signal
- Triggered when the CMF is positive (buy pressure) and RSI is less than 30 (oversold condition).
- May indicate possible reversal or strengthening of an upwards trend.
Sell Signal:
- When CMF is in negative (indicating selling pressure) and RSI is above 70 (in overbought condition).
- May indicate possible reversal or strengthening of a downwards trend.
Martingale Signal Emphasis, Super Buy/Super Sell signal:
- If two consecutive signals either bullish or bearish fail (the price moves in contrary direction), then more emphasis is placed on the following signal.
- This is based on the fact that once more trial and error movements have occurred, the market may be ripe for a stronger move in the indicated direction consistent with a martingale betting strategy.
//@version=5
indicator("CMF, RSI, and Martingale Success/Failure Indicator", shorttitle="Lucky Strike", overlay=true)
// Inputs
cmfLength = input.int(20, title="CMF Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
cooldownPeriod = input.int(5, title="Cooldown Period")
// CMF calculation
cmfValue() =>
prRange = high - low
moneyFlowMultiplier = prRange != 0 ? ((close - low) - (high - close)) / prRange : 0
moneyFlowVolume = moneyFlowMultiplier * volume
na(moneyFlowMultiplier) ? na : moneyFlowVolume
sumVol = ta.sma(volume, cmfLength)
sumMfv = ta.sma(cmfValue(), cmfLength)
cmf = sumMfv / sumVol
// RSI calculation
rsi = ta.rsi(close, rsiLength)
// Signal logic with cooldown
var int lastBullishSignalBar = na
var int lastBearishSignalBar = na
var int failureBullishCount = 0
var int failureBearishCount = 0
bullishSignal = cmf > 0 and rsi < rsiOversold and (na(lastBullishSignalBar) or bar_index - lastBullishSignalBar > cooldownPeriod)
bearishSignal = cmf < 0 and rsi > rsiOverbought and (na(lastBearishSignalBar) or bar_index - lastBearishSignalBar > cooldownPeriod)
if bullishSignal
lastBullishSignalBar := bar_index
if bearishSignal
lastBearishSignalBar := bar_index
// Success/Failure logic
isSuccess(lastSignalBar, isBullish) =>
if bar_index - lastSignalBar == 3
if isBullish
close > close[3]
else
close < close[3]
else
na
successOrFailureBullish = isSuccess(lastBullishSignalBar, true)
failureBullish = not successOrFailureBullish and bar_index - lastBullishSignalBar == 3
failureBearish = not isSuccess(lastBearishSignalBar, false) and bar_index - lastBearishSignalBar == 3
if failureBullish
failureBullishCount := failureBullishCount + 1
if successOrFailureBullish
failureBullishCount := 0 // Reset count on successful bullish signal
if failureBearish
failureBearishCount := failureBearishCount + 1
if isSuccess(lastBearishSignalBar, false)
failureBearishCount := 0 // Reset count on successful bearish signal
// Super Signal Logic
superBullishSignal = failureBullishCount >= 2 and bullishSignal
superBearishSignal = failureBearishCount >= 2 and bearishSignal
// Plotting
plotshape(series=bullishSignal and not superBullishSignal, title="Bullish Signal", location=location.belowbar, color=color.rgb(93, 243, 33), style=shape.triangleup, text="B", textcolor=color.green)
plotshape(series=bearishSignal and not superBearishSignal, title="Bearish Signal", location=location.abovebar, color=color.rgb(226, 4, 4), style=shape.triangledown, text="S", textcolor=color.rgb(220, 5, 1))
plotshape(series=superBullishSignal, title="Super Bullish Signal", location=location.belowbar, color=color.rgb(78, 172, 81), style=shape.labelup, text="SB")
plotshape(series=superBearishSignal, title="Super Bearish Signal", location=location.abovebar, color=color.rgb(250, 26, 26), style=shape.labeldown, text="SS")
plotshape(series=successOrFailureBullish, title="Success Bullish", location=location.abovebar, color=color.blue, style=shape.circle)
plotshape(series=failureBullish, title="Failure Bullish", location=location.belowbar, color=color.red, style=shape.xcross)
plotshape(series=isSuccess(lastBearishSignalBar, false), title="Success Bearish", location=location.belowbar, color=color.green, style=shape.circle)
plotshape(series=failureBearish, title="Failure Bearish", location=location.abovebar, color=color.orange, style=shape.xcross)
Leave a Reply