
Author Message:
The Golden Swap indicator, focuses on identifying reversal points around the key levels indicated by the indicator. This pattern works by analyzing the relationship between current and past price movements, considering factors like price symmetry, baseline boundaries, and precision pin bar formations. It can offer insights into potential market reversals, allowing for more precise entries and exits.
More Details: https://www.tradingview.com/v/bHD78pHs/
CODE:
CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 Internationa
#// ~~ © Zeiierman {
#Hint signalTimeframe: Select the timeframe for the Golden Swap signals.
#Hint PreGoldenSwapSignal: Pre Signals are preliminary signals that indicate a potential upcoming Golden Swap signal.
#Hint SymetryPrecision: This filter adds an additional layer of precision to the signals by considering the symmetry of price movements. \nSet the level of precision for Symmetry Signals. A higher value allows for greater variation in symmetry, while a lower value demands closer symmetry.
#Hint BaselineBoundThreshold: This setting acts as a filter for signals, where only those meeting the threshold criteria are considered valid. \nAdjust the range factor for the BaselineBound pattern. Increasing this value widens the threshold range, potentially allowing more signals to pass through the filter.
#Hint showTimeframe1: djusting this affects the visibility of these price levels on the chart. \nSelect the timeframe for displaying Open, High, and Low levels. Changing this setting will adjust the period over which these levels are calculated and shown.
#Indicator("Golden Swap (Zeiierman)",overlay=true,max_labels_count=500,max_lines_count=500)
# Converted by Sam4Cok@Samer800 - 01 / 2025
#// ~~ Input Golden Swap
input signalTimeframe = AggregationPeriod.MIN;
input Signal = yes;# e="Golden Swap", group="Golden Swap Signals",inline="s2", tooltip=t2)
input PreGoldenSwapSignal = no;#(false, title="Pre Golden Swap", gro
input filterCombination = { # "Golden Swap Filters", options=[
"None",
"Symmetry",
"BaselineBound",
"PrecisionPinBar",
default "Symmetry + BaselineBound",
"Symmetry + PrecisionPinBar",
"BaselineBound + PrecisionPinBar",
"BloomPattern + Symmetry + BaselineBound",
"Symmetry + BaselineBound + PrecisionPinBar"};
input SymetryPrecision = 7.0;#, step= 1, minval= 1, title="Symetry Precision",
input BaselineBoundThreshold = 0.2;#, title="BaselineBound Threshold" ,minval=0.01, maxval=1
def na = Double.NaN;
def cap = GetAggregationPeriod();
def tf = Max(cap, signalTimeframe);
#// ~~ Function to check for Symetry Signals
script SymmetrySignal {
input threshold = 7;
def precision = Max(threshold, 1);
def maxx = max(high,high[1]);
def minn = min(low,low[1]);
def high_ = (AbsValue(high - high[1]) / (maxx - minn)) * 100;
def low_ = (AbsValue(low - low[1]) / (maxx - minn)) * 100;
def SymmetryHigh = high_ <= precision;
def SymmetryLow = low_ <= precision;
plot SymHi = SymmetryHigh;
plot SymLo = SymmetryLow;
}
#// ~~ Function to check for BaselineBound
script BaselineBoundPattern {
input Factor = 0.2;
def rangeFactor = Max(factor, 0.01);
def absVal = AbsValue(high[1] - low[1]) * rangeFactor;
def bullish = close >= (high - absVal);
def bearish = close <= (low + absVal);
plot bull = bullish;
plot bear = bearish;
}
#// ~~ Function to check for PrecisionPinBar
script PrecisionPinBar {
def barRange = high - low;
def threshold = barRange / 3;
def bodyLen = AbsValue(close - open);
def tailLen = if open > close then close - low else open - low;
def longTail = tailLen > (3 * bodyLen);
def bullish = (open >= (high - threshold)) and (close >= (high - threshold))
and (longTail or close > open);
def bearish = (open <= (low + threshold)) and (close <= (low + threshold))
and (longTail or close < open);
plot bull = bullish;
plot bear = bearish;
}
def SymmetryHigh = SymmetrySignal(SymetryPrecision).SymHi;
def SymmetryLow = SymmetrySignal(SymetryPrecision).SymLo;
def bullishBaselineBound = BaselineBoundPattern(BaselineBoundThreshold).bull;
def bearishBaselineBound = BaselineBoundPattern(BaselineBoundThreshold).bear;
def BullishPrecisionPinBar = PrecisionPinBar().bull;
def BearishPrecisionPinBar = PrecisionPinBar().bear;
#Script BloomPattern {
def prevRed = open[1] > close[1];
def prevGreen = open[1] < close[1];
def currentGreen = close > open;
def currentRed = close < open;
def embody = (currentGreen and close > open[1] and open <= close[1])
or (currentRed and close < open[1] and open >= close[1]);
#def bullishCond = prevRed and currentGreen and bullishBaselineBound and SymmetryLow;
def bullishCond = prevRed and currentGreen and embody and bullishBaselineBound and SymmetryLow;
def bearishCond = prevGreen and currentRed and embody and bearishBaselineBound and SymmetryHigh;
#// ~~ Golden Swap Pattern
def longcondTf = close(Period = tf)[2] > open(Period = tf)[2] and
close(Period = tf)[1] > close(Period = tf)[2] and
close(Period = tf)[1] > open(Period = tf)[1] and
low(Period = tf) < Max(close(Period = tf)[2], open(Period = tf)[2]);
def shortcondTF = close(Period = tf)[2] < open(Period = tf)[2] and
close(Period = tf)[1] < close(Period = tf)[2] and
close(Period = tf)[1] < open(Period = tf)[1] and
high(Period = tf) > Min(close(Period = tf)[2], open(Period = tf)[2]);
#// ~~ Apply filters based on selected combination
def longcond;
def shortcond;
switch (filterCombination) {
case "None" :
longcond = longcondTf;
shortcond = shortcondTF;
case "Symmetry" :
longcond = longcondTf and SymmetryLow;
shortcond = shortcondTF and SymmetryHigh;
case "BaselineBound" :
longcond = longcondTf and bullishBaselineBound;
shortcond = shortcondTF and bearishBaselineBound;
case "PrecisionPinBar" :
longcond = longcondTf and BullishPrecisionPinBar;
shortcond = shortcondTF and BearishPrecisionPinBar;
case "Symmetry + PrecisionPinBar" :
longcond = longcondTf and SymmetryLow and BullishPrecisionPinBar;
shortcond = shortcondTF and SymmetryHigh and BearishPrecisionPinBar;
case "BaselineBound + PrecisionPinBar" :
longcond = longcondTf and bullishBaselineBound and BullishPrecisionPinBar;
shortcond = shortcondTF and bearishBaselineBound and BearishPrecisionPinBar;
case "BloomPattern + Symmetry + BaselineBound" :
longcond = bullishCond;
shortcond = bearishCond;
case "Symmetry + BaselineBound + PrecisionPinBar" :
longcond = longcondTf and SymmetryLow and bullishBaselineBound and BullishPrecisionPinBar;
shortcond = shortcondTF and SymmetryHigh and bearishBaselineBound and BearishPrecisionPinBar;
default :
longcond = longcondTf and SymmetryLow and bullishBaselineBound;
shortcond = shortcondTF and SymmetryHigh and bearishBaselineBound;
}
#// ~~ Plot Golden Swap Lines
def PreShort = shortcond and close >=close[1];
def PreLong = longcond and close <=close[1];
def Short = shortcond and close < close[1];
def Long = longcond and close > close[1];
#// ~~ Plot Golden Swap
plot preUp = if PreGoldenSwapSignal and PreLong then low else na;
plot preDn = if PreGoldenSwapSignal and PreShort then high else na;
preUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
preDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
preUp.SetDefaultColor(Color.CYAN);
preDn.SetDefaultColor(Color.MAGENTA);
AddChartBubble(Signal and Short, high, "S", Color.MAGENTA); # "Golden Swap Short"
AddChartBubble(Signal and Long, low, "B", Color.CYAN, no); #"Golden Swap Long"
# Lines
input showTimeframe1 = yes;
input Timeframe1 = AggregationPeriod.FOUR_HOURS;
input showTimeframe2 = yes;
input Timeframe2 = AggregationPeriod.DAY;
input showTimeframe3 = no;
input Timeframe3 = AggregationPeriod.FOUR_DAYS;
input showTimeframe4 = no;
input Timeframe4 = AggregationPeriod.WEEK;
def last = isNaN(close);
def tf1 = Max(cap, Timeframe1);
def tf2 = Max(cap, Timeframe2);
def tf3 = Max(cap, Timeframe3);
def tf4 = Max(cap, Timeframe4);
def lastTf1 = isNaN(close(Period = tf1));
def lastTf2 = isNaN(close(Period = tf2));
def lastTf3 = isNaN(close(Period = tf3));
def lastTf4 = isNaN(close(Period = tf4));
def o1 = if !lastTf1 then open(Period = tf1) else o1[1];
def h1 = if !lastTf1 then high(Period = tf1) else h1[1];
def l1 = if !lastTf1 then low(Period = tf1) else l1[1];
def o2 = if !lastTf2[-1] then open(Period = tf2) else o2[1];
def h2 = if !lastTf2[-1] then high(Period = tf2) else h2[1];
def l2 = if !lastTf2[-1] then low(Period = tf2) else l2[1];
def o3 = if !lastTf3[-1] then open(Period = tf3) else o3[1];
def h3 = if !lastTf3[-1] then high(Period = tf3) else h3[1];
def l3 = if !lastTf3[-1] then low(Period = tf3) else l3[1];
def o4 = if !lastTf4[-1] then open(Period = tf4) else o4[1];
def h4 = if !lastTf4[-1] then high(Period = tf4) else h4[1];
def l4 = if !lastTf4[-1] then low(Period = tf4) else l4[1];
def cnt1 = if o1!=o1[1] then cnt1[1] + 1 else cnt1[1];
def cnt2 = if o2!=o2[1] then cnt2[1] + 1 else cnt2[1];
def cnt3 = if o3!=o3[1] then cnt3[1] + 1 else cnt3[1];
def cnt4 = if o4!=o4[1] then cnt4[1] + 1 else cnt4[1];
def tf1Cond = showTimeframe1 and cnt1 == highestAll(cnt1) and !last;
def tf2Cond = showTimeframe2 and cnt2 == highestAll(cnt2) and !last;
def tf3Cond = showTimeframe3 and cnt3 == highestAll(cnt3) and !last;
def tf4Cond = showTimeframe4 and cnt4 == highestAll(cnt4) and !last;
plot oHT1 = if tf1Cond then o1 else na;
plot hHT1 = if tf1Cond then h1 else na;
plot lHT1 = if tf1Cond then l1 else na;
plot oHT2 = if tf2Cond then o2 else na;
plot hHT2 = if tf2Cond then h2 else na;
plot lHT2 = if tf2Cond then l2 else na;
plot oHT3 = if tf3Cond then o3 else na;
plot hHT3 = if tf3Cond then h3 else na;
plot lHT3 = if tf3Cond then l3 else na;
plot oHT4 = if tf4Cond then o4 else na;
plot hHT4 = if tf4Cond then h4 else na;
plot lHT4 = if tf4Cond then l4 else na;
oHT1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hHT1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lHT1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
oHT2.SetPaintingStrategy(PaintingStrategy.DASHES);
hHT2.SetPaintingStrategy(PaintingStrategy.DASHES);
lHT2.SetPaintingStrategy(PaintingStrategy.DASHES);
oHT3.SetPaintingStrategy(PaintingStrategy.DASHES);
hHT3.SetPaintingStrategy(PaintingStrategy.DASHES);
lHT3.SetPaintingStrategy(PaintingStrategy.DASHES);
oHT4.SetPaintingStrategy(PaintingStrategy.DASHES);
hHT4.SetPaintingStrategy(PaintingStrategy.DASHES);
lHT4.SetPaintingStrategy(PaintingStrategy.DASHES);
oHT1.SetDefaultColor(Color.CYAN);
hHT1.SetDefaultColor(Color.CYAN);
lHT1.SetDefaultColor(Color.CYAN);
oHT2.SetDefaultColor(Color.MAGENTA);
hHT2.SetDefaultColor(Color.MAGENTA);
lHT2.SetDefaultColor(Color.MAGENTA);
oHT3.SetDefaultColor(Color.YELLOW);
hHT3.SetDefaultColor(Color.YELLOW);
lHT3.SetDefaultColor(Color.YELLOW);
oHT4.SetDefaultColor(Color.LIME);
hHT4.SetDefaultColor(Color.LIME);
lHT4.SetDefaultColor(Color.LIME);
#-- END of CODE