Indicator · Pine Script v5 · On the chart

Woverine - Buy Sell Indicators

by RyKaj

The Woverine - Buy Sell Indicators plots buy and sell labels on the price chart based on selected calculation sources like close, EMA, or SMA, combined with ADX for long or short strategies.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code491
Settings10inputs
LicenceMIT
Last update3 years ago11 Oct 2023

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

491 lines of Pine Script v5 from BuySellLables.pinescript, published under MIT. Keep the author's credit and licence lines when you reuse it.

BuySellLables.pinescript
//@version=5
//=============================================================================================  
//  Creator: Woverine
//    
//    Source Code: https://github.com/RyKaj/PineScript/tree/main
//
//    Purpose: 
//         Merge mutliple BuySell Indicators
//
//=============================================================================================  

indicator('Woverine - Buy Sell Indicators', overlay=true, shorttitle='BuySell')


// Plot colors
// https://chir.ag/projects/name-that-color/#6195ED
// https://kodify.net/tradingview/colours/basic-colours/
// color colorAquaIsland = #B2DFDB
// color colorAzureRadiance = #0094ff
    // color colorBlack = #363A45
// color colorBlazeOrange = #ff6a00
color colorBlue = #2196F3
// color colorBlueChill = #088A8D
// color colorBlushPink = #fd7fe6
// color colorBurntSienna = #EF5350
// color colorCandelLight = #FCD917
// color colorCoral = #FF7F50
// color colorCyan = #17FFFF
// color colorDeathCross = #e32636
// color colorFreshEggplant = #800080
// color colorFruitSalad = #4CAF50
color colorFuchsia = #E040FB
// color colorGoldenCross = #61ed77
// color colorGray = #787B86
// color colorJapaneseLaurel = #008000
color colorGreen = #4CAF50
// color colorJungleGreen = #39ff14
// color colorKeyLimePie = #BCBB26
// color colorLilacBush = #9575cd
    // color colorLime = #00E676
// color colorOrange = #FF9800
// color colorParsley = #0E4813
// color colorPastelPink = #FFCDD2
// color colorPurple = #9C27B0
color colorRed = #FF5252
// color colorRobinEggBlue = #00C9C9
// color colorRoseBudCherry = #880e4f
// color colorRusticRed = #4E0404
// color colorSaratoga = #505010
// color colorSpringGreen = #00E676
// color colorStarship = #F2F131
// color colorTamarillo = #991515
// color colorTeal = #00897B
// color colorTealBlue = #055355
// color colorTrendyGreen = #86851b
color colorWhite = #FFFFFF

// 
// 
// //Configured signal output
// slow = 8
// fast = 5
// 
// 
// //
// //====================channel======================
// int SMAlength = input.int(defval = 8 , title = "Trend Change SMA", minval = 1  , maxval =  1 , step = 1, tooltip = "", inline = "", group = "Channel" , confirm = false ) 
// float source = input.source(defval = close, title = "Source", tooltip = "", inline = "", group = "Channel" ) 
// bool bShowBarChannel = input.bool(defval = false , title = "Bar Channel On/Off", tooltip = "", inline =  "", group = "Channel" ,  confirm = false )  
// 
// float sma = ta.sma(source = source, length = SMAlength) 
// float last8h = ta.highest( source = source, length = 13)
// float lastl8 = ta.lowest( source = source, length = 13)
// bool bearish = ta.cross( source1 = source, source2 = sma) == 1 and source[1] > source
// bool bullish = ta.cross( source1 = source, source2 = sma) == 1 and source[1] < source
// 
// 
// plot( bShowBarChannel ? last8h : last8h == nz( last8h[1] ) ? last8h : na, color=color.new( colorBlack, 0), linewidth=1, style=plot.style_linebr, title='Candle body resistance level top', offset=0)
// plot( bShowBarChannel ? lastl8 : lastl8 == nz( lastl8[1] ) ? lastl8 : na, color=color.new( colorBlack, 0), linewidth=1, style=plot.style_linebr, title='Candle body resistance level bottom', offset=0)
// 
// //--------------------trend colour ema------------------------------------------------//    ema trend direction trigger For Singals 1 & 2
// EMAlength = input.int(defval = 13 , title = "Trend Change EMA", minval = 1  , maxval =  1 , step = 1, tooltip = "", inline = "", group = "" , confirm = false ) 
// ema = ta.ema(source = source, length = EMAlength) 
// plotColor = ema >= ema[2] ? colorLime : ema < ema[2] ? colorRed : na
// plot( ema, title='EMA', style=plot.style_line, linewidth=1, color=color.new( color= plotColor , transp = 0 ) )
// 
// 
// //--Modified vyacheslav.shindin-------------------------------------------------//           Signal 1
// vh1 = ta.ema( source = ta.highest( source=math.avg( low , source ) , length=fast ), length =fast )
// vl1 = ta.ema( source = ta.lowest( source=math.avg( high , source ) , length=slow ), length =slow )
// e_ema1 = ta.ema( source = source, length=1 )
// e_ema2 = ta.ema( source = e_ema1, length=1 )
// e_ema3 = ta.ema( source = e_ema2, length=1 )
// tema = 1 * ( e_ema1 - e_ema2 ) + e_ema3
// e_e1 = ta.ema( source=source, length=8 )
// e_e2 = ta.ema( source=e_e1, length=5 )
// 
// dema = 2 * e_e1 - e_e2
// signal = tema > dema ? math.max( vh1, vl1 ) : math.min( vh1, vl1 )
// is_call = tema > dema and signal > low and signal - signal[1] > signal[1] - signal[2]
// is_put = tema < dema and signal < high and signal[1] - signal > signal[2] - signal[1]
// 
// plotshape( is_call ? 1 : na, title='BUY ARROW', color=color.new( colorGreen, 0 ), text='*BUY*', style=shape.arrowup, location=location.belowbar )
// plotshape( is_put ? -1 : na, title='SELL ARROW', color=color.new( colorRed, 0 ), text='*SELL*', style=shape.arrowdown )
// 
// 
// //Modified - Rajandran R Supertrend----------------------------------------------------- //       Signal 2
// int iFactor = input.int(defval = 1 , title = "Trend Transition Signal", minval = 1  , maxval = 800 , step = 1, tooltip = "", inline = "", group = "" , confirm = false ) 
// Pd = input.int(defval = 1 , title = "Pd", minval = 1  , maxval = 800 , step = 1, tooltip = "", inline = "", group = "" , confirm = false ) 
// Up = hl2 - iFactor * ta.atr(Pd)
// Dn = hl2 + iFactor * ta.atr(Pd)
// 
// // trendUp := close[1] > trendUp[1] ? max( Up,trendUp[1] ) : Up
// // trendDown = close[1] < trendDown[1] ? min( Dn, trendDown[1] ) : Dn
// // trend = close > trendDown[1] ? 1: close< trendUp[1]? -1: nz(trend[1],0)
// // plotarrow(trend == 1 and trend[1] == -1 ? trend : na, title="Up Entry Arrow", colorup=lime, maxheight=1000, minheight=50, transp=85)
// // plotarrow(trend == -1 and trend[1] == 1 ? trend : na, title="Down Entry Arrow", colordown=red, maxheight=1000, minheight=50, transp=85)
// 
// // Moddified [RS]Support and Resistance V0
// RSLength = input.int(defval = 21 , title = "Support / Resistance length", minval = 1  , maxval = 800 , step = 1, tooltip = "", inline = "", group = "" , confirm = false ) 
// 
// float RSTT = ta.valuewhen( condition= high >= ta.highest( high, RSLength ), source=high, occurrence=0 )
// float RSTB = ta.valuewhen( condition= low <= ta.lowest( low, RSLength), source=low, occurrence=0 )
// 
// plot( series= RSTT, color=RSTT != RSTT[1] ? na : color.new( color=colorRed , transp = 0 ), linewidth=1, offset=0 )
// plot( series=RSTB, color=RSTB != RSTB[1] ? na : color.new( color=colorGreen , transp = 0 ), linewidth=1, offset=0 )
// 
// 
// //===============================Directional Projection=======================================//
// string sTrendProjTimeFame = input.string( defval='1', title='Tgrend Projection TF / Mins/D/W' )
// string sStyle = input.string( defval='ATR', title='Average True Range' )
// 
// int P2 = input.int( defval = 13 , title = "", minval = 1  , maxval =  20 , step = 1, tooltip = "", inline = "", group = "" , confirm = false ) 
// int W2 = input.int( defval = 1 , title = "", minval = 1  , maxval =  20 , step = 1, tooltip = "", inline = "", group = "" , confirm = false ) 
// 
// string pf2 = ticker.pointfigure( syminfo.tickerid, 'close', sStyle, P2, W2 )
// 
// spfc2 = request.security( symbol=pf2, timeframe=sTrendProjTimeFame, expression=source )
// bool bShowProjection = input.bool( defval = false , title = "Connect Projection High/Low", tooltip = "", inline =  "", group = "" ,  confirm = false )  
// 
// p22 = plot( bShowProjection ? spfc2 : spfc2 == nz( spfc2[1] ) ? spfc2 : na, color=color.new( colorBlue, 0), linewidth=2, style=plot.style_linebr, title='Directional Projection', offset=0)
// //----------------------------------------------------------------------//
// 


//-------------------------------------------------------------------------------------------------------------------------
// Inputs
//-------------------------------------------------------------------------------------------------------------------------

// The HLC stands for High, Low, Close and the /3 divides the result by 3 to give you the average.
float inputSource = input.source( defval = close, title = "Calculation Source", tooltip = "", inline = "", group = "" ) 
string inputStrategy = input.string( defval = "EMA/SMA", title = "Strategy", options = ['EMA/SMA', 'EMA/SMA TF based', 'Fractal Regular', 'Fractal Bill Williams', 'Percentage Price Oscillator', 'Hull Trend', 'Kaufman Adaptive Moving Average'], tooltip = "", inline = "", group = "" , confirm = false ) 
string inputStrategyLongShort = input.string( defval='ADX', title='Strategy - Long/Short', options=['DISABLED', 'ADX', 'Ichimoku_9-26-52', 'Ichimoku_10-30-60', 'Ichimoku_20-60-120'] , tooltip = "", inline = "", group = "" , confirm = false )
string inputStyleLabelSize = input.string( defval='small',  title='Label - Size', options=['auto', 'huge', 'large', 'normal', 'small', 'tiny'], tooltip = "", inline = "", group = "" , confirm = false )
string inputStyleLabelType = input.string( defval='label', title='Label - Type', options=['label', 'triangle'], tooltip = "", inline = "", group = "" , confirm = false )
string inputStyleLabelPosition = input.string( defval='default', title='Label - Position',  options=['default', 'lowhigh'], tooltip = "", inline = "", group = "" , confirm = false )
bool inputShowPriceOnLabel = input.bool(defval = true , title = "Show Price on Labels", tooltip = "", inline = "", group =  "" ,  confirm = false ) 
bool inputShowBuyLabel = input.bool(defval = true , title = "Show BUY Signal", tooltip = "", inline = "", group =  "" ,  confirm = false ) 
bool inputShowSellLabel = input.bool(defval = true , title = "Show SELL Signal", tooltip = "", inline = "", group =  "" ,  confirm = false ) 
bool inputActivateAlerts = input.bool(defval = false , title = "Activate Alerts", tooltip = "", inline = "", group =  "" ,  confirm = false ) 



//-------------------------------------------------------------------------------------------------------------------------
// Variables
//-------------------------------------------------------------------------------------------------------------------------
int iPosTimeBased = time  //offset -1
string sCurrentTimeFramePeriod = timeframe.period
string sPrice = close <= 0.99999 ? str.tostring( close, '#.####' ) : close <= 99.99 ? str.tostring( close, '#.###' ) : close <= 999.99 ? str.tostring( close, '#.##' ) : str.tostring( close, '#' )
string sLabelTextBuy = 'BUY' + ( inputShowPriceOnLabel == true ? ': ' + sPrice : '' )
string sLabelTextSell = 'SELL' + ( inputShowPriceOnLabel == true ? ': ' + sPrice : '' )

// Average Directional Index (ADX)
int iADXLength = 13
int iADXDirectionalIndexLength = 14
int iADXAverageTrueRange = 20
int iADXHigherLowTrend = 40

//********** Set Signals - Long/Short
bool bSignalFinalLong = false
bool bSignalFinalShort = false

//-------------------------------------------------------------------------------------------------------------------------
// Functions
//-------------------------------------------------------------------------------------------------------------------------
funcDonchian( iLength ) =>
    math.avg( ta.lowest( iLength ), ta.highest( iLength ) )

funcEmaSma(fSource, sPeriod, sStrategy) =>
    tresholdPositive = 88
    tresholdNegative = -88

    // EMA/SMA
    maLengthBuy_1_Default = 14
    maLengthBuy_2_Default = 3
    maLengthSell_1_Default = 8
    maLengthSell_2_Default = 1

    // setting 1
    maLengthBuy_1 = sPeriod == '1' ? 6 : sPeriod == '3' ? 5 : sPeriod == '5' ? 5 : sPeriod == '15' ? 42 : sPeriod == '30' ? 42 : sPeriod == '45' ? 16 : sPeriod == '60' ? 20 : timeframe.isdaily ? 14 : timeframe.isweekly ? 14 : timeframe.ismonthly ? 5 : 14
    maLengthBuy_2 = sPeriod == '1' ? 1 : sPeriod == '3' ? 1 : sPeriod == '5' ? 1 : sPeriod == '15' ? 1 : sPeriod == '30' ? 1 : sPeriod == '45' ? 1 : sPeriod == '60' ? 2 : timeframe.isdaily ? 5 : timeframe.isweekly ? 3 : timeframe.ismonthly ? 1 : 3
    maLengthSell_1 = sPeriod == '1' ? 6 : sPeriod == '3' ? 3 : sPeriod == '5' ? 3 : sPeriod == '15' ? 6 : sPeriod == '30' ? 6 : sPeriod == '45' ? 8 : sPeriod == '60' ? 20 : timeframe.isdaily ? 12 : timeframe.isweekly ? 8 : timeframe.ismonthly ? 5 : 8
    maLengthSell_2 = sPeriod == '1' ? 3 : sPeriod == '3' ? 1 : sPeriod == '5' ? 2 : sPeriod == '15' ? 2 : sPeriod == '30' ? 1 : sPeriod == '45' ? 1 : sPeriod == '60' ? 1 : timeframe.isdaily ? 1 : timeframe.isweekly ? 1 : timeframe.ismonthly ? 1 : 1

    // setting 2
    isTimeframeBased = sStrategy == 'EMA/SMA TF based'
    maLengthBuyFinal_1 = isTimeframeBased ? maLengthBuy_1 : maLengthBuy_1_Default
    maLengthBuyFinal_2 = isTimeframeBased ? maLengthBuy_2 : maLengthBuy_2_Default
    maLengthSellFinal_1 = isTimeframeBased ? maLengthSell_1 : maLengthSell_1_Default
    maLengthSellFinal_2 = isTimeframeBased ? maLengthSell_2 : maLengthSell_2_Default

    // BUY
    esaBuy = ta.ema(fSource, maLengthBuyFinal_1)
    sourceEmaBuy = ta.ema(math.abs(fSource - esaBuy), maLengthBuyFinal_1)
    ciBuy = (fSource - esaBuy) / (0.015 * sourceEmaBuy)
    trendEmaBuy = ta.ema(ciBuy, maLengthBuyFinal_2)
    trendSmaBuy = ta.sma(trendEmaBuy, 4)

    // SELL
    esaSell = ta.ema(fSource, maLengthSellFinal_1)
    sourceEmaSell = ta.ema(math.abs(fSource - esaSell), maLengthSellFinal_1)
    ciSell = (fSource - esaSell) / (0.015 * sourceEmaSell)
    trendEmaSell = ta.ema(ciSell, maLengthSellFinal_2)
    trendSmaSell = ta.sma(trendEmaSell, 4)

    // prepare signals
    buyEmaSma = ta.crossover(trendEmaBuy, trendSmaBuy) and trendEmaBuy <= tresholdNegative
    sellEmaSma = ta.crossunder(trendEmaSell, trendSmaSell) and trendEmaSell >= tresholdPositive

    [buyEmaSma, sellEmaSma]

// Percentage Price Oscillator
PercentagePriceOscillator( fSource ) =>
    int iPPOfast = 12
    int iPPOslow = 26
    int iPPOsmooth = 2
    float fPPOfastMA = ta.ema( fSource, iPPOfast )
    float fPPOslowMA = ta.ema( fSource, iPPOslow )
    float fPPOmacd = fPPOfastMA - fPPOslowMA
    float fPPOmacd2 = fPPOmacd / fPPOslowMA * 100
    float fPPOresult = ta.sma( fPPOmacd2, iPPOsmooth )
    bool bPPOoscMin = fPPOresult > fPPOresult[1] and fPPOresult[1] < fPPOresult[2]
    bool bPPOoscMax = fPPOresult < fPPOresult[1] and fPPOresult[1] > fPPOresult[2]
    valPPOdivergenceBull = bPPOoscMin ? fPPOresult[1] : na
    valPPOdivergenceBear = bPPOoscMax ? fPPOresult[1] : na

    // prepare signals
    bool buyPPO = valPPOdivergenceBull != 0
    bool sellPPO = valPPOdivergenceBear != 0

    [buyPPO, sellPPO]
    

// Kaufman's Adaptive Moving Average (KAMA)
KaufmanAdaptiveMovingAverage( fSource ) =>
    // settings
    int iKamaFastLength = 12
    int iKamaFastLengthKAMA = 2
    int iKamaSlowLength = 26
    int iKamaSlowLengthKAMA = 30
    int iKamaSignalLength = 9

    // fast
    float fKamaFastLag = (iKamaFastLength - 1) / 2
    float fKamaFastData = fSource + fSource - fSource[ fKamaFastLag ]
    float fKamaFastZeroLagEMA = ta.ema( fKamaFastData, iKamaFastLength )
    float fKamaFastEma = ta.ema( fSource, iKamaFastLength )
    float fKamaFastVolatility = math.sum( math.abs( fSource - fSource[1] ), iKamaFastLength )
    float fKamaFastEfficiencyRatio = fKamaFastVolatility != 0 ? math.abs( fSource - fSource[ iKamaFastLength ] ) / fKamaFastVolatility : 0
    float fKamaFast = 0.0
    fKamaFast := nz( fKamaFast[1] ) + math.pow( fKamaFastEfficiencyRatio * ( 2 / ( iKamaFastLengthKAMA + 1 ) - 2 / ( iKamaSlowLengthKAMA + 1 )) + 2 / ( iKamaSlowLengthKAMA + 1 ), 2) * ( fSource - nz( fKamaFast[1] ) )

    // slow
    float fKamaSlowLag = ( iKamaSlowLength - 1 ) / 2
    float fKamaSlowData = fSource + fSource - fSource[ fKamaSlowLag ]
    float fKamaSlowZeroLagEMA = ta.ema( fKamaSlowData, iKamaSlowLength )
    fKamaSlowVolatility = math.sum( math.abs( fSource - fSource[1] ), iKamaSlowLength )
    fKamaSlowEfficiencyRatio = fKamaSlowVolatility != 0 ? math.abs( fSource - fSource[ iKamaSlowLength ]) / fKamaSlowVolatility : 0
    float fKamaSlow = 0.0
    fKamaSlow := nz( fKamaSlow[1] ) + math.pow( fKamaSlowEfficiencyRatio * ( 2 / ( iKamaFastLengthKAMA + 1 ) - 2 / ( iKamaSlowLengthKAMA + 1 ) ) + 2 / ( iKamaSlowLengthKAMA + 1 ), 2 ) * ( fSource - nz( fKamaSlow[1] ) )

    // Moving Average Convergence Divergence (MACD)
    float fKamaMacdAverage = ( ( fKamaFastZeroLagEMA - fKamaSlowZeroLagEMA ) + ( fKamaFastEma - ta.ema( fSource, iKamaSlowLength ) ) + ( fKamaFast - fKamaSlow) ) / 3

    // prepare signals
    fKamaSignal = ta.ema(fKamaMacdAverage, iKamaSignalLength)

    // prepare signals
    bool buyKama = ta.crossover(fKamaMacdAverage, fKamaSignal)
    bool sellKama = ta.crossunder(fKamaMacdAverage, fKamaSignal)

    [buyKama, sellKama]



funcIchimoku(sPeriod, fSource) =>
    int iConversionLinePeriod = sPeriod == 'Ichimoku_9-26-52' ? 9 : sPeriod == 'Ichimoku_10-30-60' ? 10 : sPeriod == 'Ichimoku_20-60-120' ? 20 : 9
    int iBaseLinePeriod = sPeriod == 'Ichimoku_9-26-52' ? 26 : sPeriod == 'Ichimoku_10-30-60' ? 30 : sPeriod == 'Ichimoku_20-60-120' ? 60 : 26
    int iLaggingSpanPeriod = sPeriod == 'Ichimoku_9-26-52' ? 52 : sPeriod == 'Ichimoku_10-30-60' ? 60 : sPeriod == 'Ichimoku_20-60-120' ? 120 : 52

    // calc
    float fTenkanSenConversionLine = funcDonchian(iConversionLinePeriod)
    float fKijunSenBaseLine = funcDonchian(iBaseLinePeriod)
    float fLeadingSpanA = math.avg( fTenkanSenConversionLine, fKijunSenBaseLine )
    float fLeadingSpanB = funcDonchian(iLaggingSpanPeriod)

    // RSI Settings
    int iChiRsiLength = 14
    int iChiRsiOverBought = 50
    int iChiRsiOverSold = 100
    float fChiRsiDefault = ta.rsi( fSource, iChiRsiLength )

    // lines, span
    float tenkanSenLine = fTenkanSenConversionLine[ iBaseLinePeriod ]
    float kijunSenLine = fKijunSenBaseLine[ iBaseLinePeriod ]
    float senkouSpanA = fLeadingSpanA[ iBaseLinePeriod * 2 ]
    float senkouSpanB = fLeadingSpanB[ iBaseLinePeriod * 2 ]
    float chikuSpan = fSource[0]

    
    // up/down
    // smallest/greatest of multiple given values
    bool upTrend = chikuSpan > math.max( senkouSpanA, senkouSpanB )
    bool downTrend = chikuSpan < math.min( senkouSpanA, senkouSpanB )

    // bull/bear
    bool bBull = ta.crossover(tenkanSenLine, kijunSenLine)
    bool bBear = ta.crossunder(tenkanSenLine, kijunSenLine)

    // prepare signals
    bool bLongIchi = bBull and upTrend and fChiRsiDefault <= iChiRsiOverSold
    bool bShortIchi = bBear and downTrend and fChiRsiDefault >= iChiRsiOverBought

    [bLongIchi, bShortIchi]

funcDirectionalMovement( iLength ) =>
    float fUp = ta.change( high )
    float fDown = -ta.change( low )
    plusDM = na( fUp ) ? na : fUp > fDown and fUp > 0 ? fUp : 0
    minusDM = na( fDown ) ? na : fDown > fUp and fDown > 0 ? fDown : 0
    float fTueRange = ta.rma( ta.tr, iLength )
    plus = fixnan( 100 * ta.rma( plusDM, iLength ) / fTueRange )
    minus = fixnan( 100 * ta.rma( minusDM, iLength ) / fTueRange )
    [ plus, minus ]


funcAdx( iADXDirectionalIndexLength, iLength ) =>
    [ plus,  minus ] = funcDirectionalMovement( iADXDirectionalIndexLength )
    sum = plus + minus
    funcAdx = 100 * ta.rma( math.abs( plus - minus ) / ( sum == 0 ? 1 : sum ), iLength )
    funcAdx

funcADXLowHigh( iLength, sType) =>
    [ plus, minus] = funcDirectionalMovement( iLength )
    return_1 = sType == 'high' ? plus : minus
    return_1

funcHullMovingAverage(fSource, iLength) =>
    tmpVal = math.max( 2, iLength )
    return_2 = ta.wma( 2 * ta.wma( fSource, tmpVal / 2 ) - ta.wma( fSource, tmpVal ), math.round( math.sqrt( tmpVal ) ) )
    return_2

funcHullMovingAverage3(fSource, iLength) =>
    tmpVal = iLength / 2
    ta.wma( ta.wma( fSource, tmpVal / 3 ) * 3 - ta.wma( fSource, tmpVal / 2 ) - ta.wma( fSource, tmpVal ), tmpVal )

funcHullTrend(fSource, sPeriod) =>
    int iHullTrendLength = sPeriod == '1' ? 30 : sPeriod == '3' ? 29 : sPeriod == '5' ? 28 : sPeriod == '15' ? 27 : sPeriod == '30' ? 26 : sPeriod == '45' ? 24 : sPeriod == '60' ? 24 : timeframe.isdaily ? 24 : timeframe.isweekly ? 24 : timeframe.ismonthly ? 24 : 24
    bHullTrendA = funcHullMovingAverage( fSource, iHullTrendLength )
    bHullTrendB = funcHullMovingAverage3( fSource, iHullTrendLength )
    bBuyHullTrend = bHullTrendB > bHullTrendA and bHullTrendB[1] < bHullTrendA[1]
    bSellHullTrend = bHullTrendA > bHullTrendB and bHullTrendA[1] < bHullTrendB[1]
    [bBuyHullTrend, bSellHullTrend]

funcFractalCalculated(sType, iVariant) =>
    bRegular = iVariant == 1 ? high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] : iVariant == -1 ? low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] : false
    bBillWilliams = iVariant == 1 ? high[4] < high[2] and high[3] < high[2] and high[2] > high[1] and high[2] > high[0] : iVariant == -1 ? low[4] > low[2] and low[3] > low[2] and low[2] < low[1] and low[2] < low[0] : false
    return_3 = sType == 'Fractal Regular' ? bRegular : bBillWilliams
    return_3



float fADXDirectionalIndexHigh = funcADXLowHigh( iADXDirectionalIndexLength, 'high' )
float fADXDirectionalIndexLow = funcADXLowHigh( iADXDirectionalIndexLength, 'low' )
bool bAdxDirectionalIndexCross = ta.cross( fADXDirectionalIndexHigh, fADXDirectionalIndexLow )

funcADXUp() =>
    funcAdx(iADXDirectionalIndexLength, iADXLength) >= iADXAverageTrueRange

funcADXDirectionalIndexUp() =>
    fADXDirectionalIndexHigh >= fADXDirectionalIndexLow

funcADXDirectionalIndexUps() =>
    fADXDirectionalIndexHigh >= iADXHigherLowTrend

funcADXDirectionalIndexDown() =>
    fADXDirectionalIndexLow > fADXDirectionalIndexHigh

funcADXDirectionalIndexDowns() =>
    fADXDirectionalIndexLow > iADXHigherLowTrend

funcAdxFinal() =>
    // bool
    bool bADXBuyCondition = funcADXUp() and funcADXDirectionalIndexUp() and funcADXDirectionalIndexUps()
    bool bADXBuyCloseCondition = bAdxDirectionalIndexCross and funcADXDirectionalIndexUp()[1]
    boolAdxSellCondition = funcADXUp() and funcADXDirectionalIndexDown() and funcADXDirectionalIndexDowns()
    boolAdxSellCloseCondition = bAdxDirectionalIndexCross and funcADXDirectionalIndexDown()[1]
    // counter
    adxCounter = 0
    adxCounter := bADXBuyCloseCondition ? 0 : boolAdxSellCloseCondition ? 0 : bADXBuyCondition ? 1 : boolAdxSellCondition ? -1 : nz(adxCounter[1])
    // prepare signals
    longAdx = adxCounter == 1 and adxCounter[1] == 0
    shortAdx = adxCounter == -1 and adxCounter[1] == 0
    [longAdx, shortAdx]



//********** Styling Labels
string valFinalLabelSize = inputStyleLabelSize == 'auto' ? size.auto : inputStyleLabelSize == 'huge' ? size.huge : inputStyleLabelSize == 'large' ? size.large : inputStyleLabelSize == 'normal' ? size.normal : inputStyleLabelSize == 'small' ? size.small : inputStyleLabelSize == 'tiny' ? size.tiny : size.normal
string valFinalLabelStyleUp = inputStyleLabelType == 'label' ? label.style_label_up : inputStyleLabelType == 'triangle' ? label.style_triangleup : label.style_label_up
string valFinalLabelStyleDown = inputStyleLabelType == 'label' ? label.style_label_down : inputStyleLabelType == 'triangle' ? label.style_triangledown : label.style_label_down


//********** Set Signals - Buy/Sell
[ signalFinalBuy, signalFinalSell ] = funcEmaSma( inputSource, sCurrentTimeFramePeriod, inputStrategy )

if inputStrategy == 'Kaufman Adaptive Moving Average'
    [buyKama, sellKama] = KaufmanAdaptiveMovingAverage(inputSource)
    signalFinalBuy := buyKama
    signalFinalSell := sellKama
    signalFinalSell
else if inputStrategy == 'Percentage Price Oscillator'
    [buyPPO, sellPPO] = PercentagePriceOscillator(inputSource)
    signalFinalBuy := buyPPO
    signalFinalSell := sellPPO
    signalFinalSell
else if inputStrategy == 'Hull Trend'
    [buyHullTrend, sellHullTrend] = funcHullTrend(inputSource, sCurrentTimeFramePeriod)
    signalFinalBuy := buyHullTrend
    signalFinalSell := sellHullTrend
    signalFinalSell
else if inputStrategy == 'Fractal Regular' or inputStrategy == 'Fractal Bill Williams'
    signalBuyFractal = funcFractalCalculated(inputStrategy, -1)
    signalSellFractal = funcFractalCalculated(inputStrategy, 1)
    signalFinalBuy := signalBuyFractal
    signalFinalSell := signalSellFractal
    signalFinalSell



if inputStrategyLongShort == 'Ichimoku_9-26-52' or inputStrategyLongShort == 'Ichimoku_10-30-60' or inputStrategyLongShort == 'Ichimoku_20-60-120'
    [signalLongIchi, signalShortIchi] = funcIchimoku(inputStrategyLongShort, inputSource)
    bSignalFinalLong := signalLongIchi
    bSignalFinalShort := signalShortIchi
    bSignalFinalShort
else if inputStrategyLongShort == 'ADX'
    [longAdx, shortAdx] = funcAdxFinal()
    bSignalFinalLong := longAdx
    bSignalFinalShort := shortAdx
    bSignalFinalShort



//************  Plotting

// BUY
label.new( x=signalFinalBuy and inputShowBuyLabel == true ? iPosTimeBased : na, y=inputStyleLabelPosition == 'default' ? na : low, xloc=xloc.bar_time, yloc=inputStyleLabelPosition == 'default' ? yloc.belowbar : yloc.price, text=sLabelTextBuy, color=colorGreen, textcolor=colorWhite, style=valFinalLabelStyleUp, size=valFinalLabelSize )

// SELL
label.new( x=signalFinalSell and inputShowSellLabel == true ? iPosTimeBased : na, y=inputStyleLabelPosition == 'default' ? na : high, xloc=xloc.bar_time, yloc=inputStyleLabelPosition == 'default' ? yloc.abovebar : yloc.price, text=sLabelTextSell, color=colorRed, textcolor=colorWhite, style=valFinalLabelStyleDown, size=valFinalLabelSize )

// LONG
label.new( x=bSignalFinalLong ? iPosTimeBased : na, y=low, xloc=xloc.bar_time, yloc=yloc.price, text='LONG', color=colorBlue, textcolor=colorWhite, style=valFinalLabelStyleUp, size=size.tiny )

// SHORT
label.new( x=bSignalFinalShort ? iPosTimeBased : na, y=high, xloc=xloc.bar_time, yloc=yloc.price, text='SHORT', color=colorFuchsia, textcolor=colorWhite, style=valFinalLabelStyleDown, size=size.tiny )


//************  Alerting

// BUY
alertcondition( inputActivateAlerts and signalFinalBuy, title='BUY', message='BUY' )

// SELL
alertcondition( inputActivateAlerts and signalFinalSell, title='SELL', message='SELL' )

// LONG
alertcondition( inputActivateAlerts and bSignalFinalLong, title='LONG', message='LONG' )

// SHORT
alertcondition( inputActivateAlerts and bSignalFinalShort, title='SHORT', message='SHORT' )

Overview

Users can customize the strategy type, signal colors, label sizes, positions, and whether to show prices on labels. Signals are generated using crossovers and trend indicators, with options for alerts. The indicator draws signals directly on the chart for easy identification of potential entry and exit points. Main settings allow changing ranges, colors, and styles to fit different trading preferences. It supports multiple configuration options for flexibility but does not include stop loss or take profit rules by default.

Details

Published by

RyKaj on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Calculation SourcesourcecloseinputSource
StrategystringEMA/SMAinputStrategy
Strategy - Long/ShortstringADXinputStrategyLongShort
Label - SizestringsmallinputStyleLabelSize
Label - TypestringlabelinputStyleLabelType
Label - PositionstringdefaultinputStyleLabelPosition
Show Price on LabelsbooltrueinputShowPriceOnLabel
Show BUY SignalbooltrueinputShowBuyLabel
Show SELL SignalbooltrueinputShowSellLabel
Activate AlertsboolfalseinputActivateAlerts
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

114 stars

This indicator calculates key support and resistance levels by analyzing the first and second momentum derivatives of a Double Exponential Moving Average (DEMA). When the second derivative (momentum of momentum) crosses zero, it identifies local turning points

Indicator v4 Support & resistanceOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Support and Resistance Levels

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
14 stars

Self-Aware Trend System calculates volatility-adaptive ATR trailing bands using a Trend Quality Index engine that evaluates market efficiency, momentum persistence, and structural pivots. It plots adaptive trend bands and character-flip trend signals directly

Indicator v6 TrendVolatility & bands
Updated 2 weeks ago · MIT GitHub repository of Self-Aware Trend System [WillyAlgoTrader]

SPY 0DTE Scalper - 15min

by chris-c-thomas
14 stars

This intraday overlay establishes directional bias and high-conviction swing setups for SPY on the 15-minute timeframe. It computes a weighted confluence score combining an EMA ribbon, a 50 EMA anchor, session VWAP bands, RSI divergence, ADX, TTM Squeeze, cand

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · MIT GitHub repository of SPY 0DTE Scalper - 15min

Market Trend

by azamiftikhar1000
12 stars

Market Trend is an overlay indicator that identifies market direction and key price levels. It calculates a Relative Strength Index with Bollinger Bands to construct a 20-step color gradient reflecting momentum shifts. The script incorporates exponential movin

Indicator v4 TrendOscillators & momentum
Updated 3 years ago · None stated GitHub repository of Market Trend

BTE Acc AO SMIO

by f-cksociety
11 stars

This script provides an indicator-based backtesting engine framework that simulates trade entries, exits, and filtering directly on the price chart. It evaluates selected entry rules and multi-layered filters, including moving average trends, volume increases,

Indicator v5 TrendOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of BTE Acc AO SMIO

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers