Strategy · Pine Script v5 · On the chart

TLC 0TO100 Five Indicators Strategy

by hbelloma· code credited to ayaxhector666 for Two Level Capital

This strategy generates trade entries by combining up to five normalized 0-100 technical indicators: Relative Strength Index (RSI with divergence detection), Stochastic RSI, Money Flow Index (MFI), Relative Volatility Index (RVI), and Average Directional Index (ADX).

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code491
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago12 Oct 2025

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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

491 lines of Pine Script v5 from TLC_0TO100FIVEINDICATORS_STRATEGY/TLC_0TO100FIVEINDICATORS_STRATEGY.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

TLC_0TO100FIVEINDICATORS_STRATEGY.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ayaxhector666 for Two Level Capital 
// Any question please contact Héctor Bello at ayaxhector666@gmail.com
//
// Here we describe a estrategy based on TLC_0TO100FIVEINDICATORS_VOLMOM which are five indicators that runs from 0-100
//. We have momentum indicators: Relative Strenght Index RSI (with divergence searching), Stochastic RSI (STOCHRSI)
//. we also have volume-momentum indicator: Money Flow Index (MFI)
//. We also have volatility indicators: Relative Volatility Index (RVI) and Average Directional Index (ADX)
//. All this indicators can be configured and turned on/off from settings menu
//
//. The strategy take into acount which indicators you have selected from configuration setup:
//. 1.-If Stochastic RSI (STOCH) is selected it will trigger a buy/sell signal if STOCH K and D crosses over or under for OverBought and OverSold values
//. 2.-If Relative Strenght Index (RSI) is selected it will trigger a buy/sell signal if RSI Value crosses over or under for OverBought and OverSold values
//. 3.-If Money Flow Index (MFI) is selected it will trigger a buy/sell signal if RSI Value crosses over or under for Extreme OverBought and Extreme OverSold values
//. 4.-If Relative Volatility Index (RVI) filter is selected it will trigger a buy/sell signal if volatility is below or above OverBought and OverSold values
//. 5.-If Average Directional Index (ADX) filter is selected it will trigger a buy/sell signal if volatility is below or above the threshold value
//. 6.-Any possible on/off combination of this indicators (2^5=32 posibles) are taken into account and will trigger a buy/sell signal   
//. We also add two extra filters:
//. A.- XMA(100) as a guide to be displayed and used as filter if required: Long for values below and Short for values above xma(EMA GUIDE lenght), xma is defined by maTypeInput parameter, by default xma(EMA GUIDE lenght)=ema(100), but can be adjusted as needed)
//. B.- Volume Filter to be used if required, the positions are open when standar deviation values of volume  are above thresholdMedium. Here the standar deviation is calculated in terms of the mean volume in volumeLength time interval.
//.
///////////////////////////////////

//@version=5
strategy("TLC_0TO100FIVEINDICATORS_STRATEGY", overlay=true, pyramiding=2, default_qty_type=strategy.percent_of_equity, initial_capital = 10000, currency=currency.USD)
//strategy("TLC_0TO100FIVEINDICATORS_STRATEGY", overlay=true, pyramiding=1,   default_qty_type=strategy.percent_of_equity, initial_capital = 100, currency=currency.USD)
//if no qty is used then default_qty_type=strategy.percent_of_equity //initial_capital = 100,


fromDate = input.time(timestamp('17 Jul 2010 00:00 UTC'), 'From Date', tooltip="Start date-time for Strategy",group="Strategy Action setup")
toDate = input.time(timestamp('31 Dec 2025 23:59 UTC'), 'To Date', tooltip="End date-time for Strategy")


//Maximun Risk taken
Plan=input.string("ALLIN", title="Plan for risk management in Two Level Capital", options=["COOK", "WALK", "HAWK", "ALLIN"], tooltip = "COOK: maximun risk of 10% no leverage only x1, WALK: maximun risk of 30% moderate leverage x2-x5, HAWK: maximun risk of 50% high leverage x10-x100, ALLIN: maximun risk of 100% (No Drawdown limit)")
int drawdmaxperc=0
if(Plan=="COOK") 
    drawdmaxperc:=10
else if(Plan=="WALK")
    drawdmaxperc:=30
else if(Plan=="HAWK")
    drawdmaxperc:=50
else if(Plan=="ALLIN")
    drawdmaxperc:=100    
strategy.risk.max_drawdown(drawdmaxperc, strategy.percent_of_equity)
  
riskCapital = input.float(title="Risk % of capital", defval=100, minval=1, maxval = 100, tooltip ="Percentage of Capital in Equity for quantity buying in each position entry, as described in: qty = (strategy.equity*riskCapital/100)/(close*stopLoss/100))" )

SLTPMethod =input.string("NONE", title="Method for setting SL and TP", options=["NONE", "PERCENTAGE", "ATR"], tooltip="This is the method used for setting the Stop Loss and Take Profit limits, NONE: SL/TP is not considered (Signal closes the position), PERCENTAGE: SL/TP given is in Percentage, ATR:  SL/TP is given by ATR Multiplier")
SLTPistaken= SLTPMethod=="NONE" ? false : true
SLTPviaPerc= SLTPMethod=="PERCENTAGE" ? true : false
SLTPviaATR = SLTPMethod=="ATR" ? true : false

stopLoss=input.float(2.0,title="Stop Loss Percentage",minval=0.05, tooltip="Percentage of the action price where Stop Loss is taken") 
takeProfit=input.float(10.0,title="Take Profit Percentage",minval=0.05, tooltip="Percentage of the action price where Take Profit is taken") 
slMultiplier = input.float(1.0, title="SL Multiplier")
tpMultiplier = input.float(5.0, title="TP Multiplier")
SLTPviaTRAILING= input.bool(defval=false, title="Want trailing SL?", tooltip="Check if you want to use SL taked as trailing via a trailPercent")
trailPercent = input.float(1.0, title="Trail Percentage",minval=0.05)

// QUANTITY OF CONTRACTS Q=Inv/Price
// Check how many units can be purchased based on risk management and stop loss

qty1 = (strategy.equity * riskCapital / 100 )/(close*stopLoss/100)
////check if cash is sufficient  to buy qty1  , if capital not available use the available capital only
qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity/close) : qty1
qty1:= (strategy.equity <0.0) ? 0 : qty1
//partialExit=input(false,title="Allow Partial exit / take profits", tooltip="Allowance for partial take profits in strategy")

//////////////////////////////////////
// INDICATORS PARAMETERS SETUP
//////////////////////////////////////
//RSI PARAM
isRSI= input.bool(defval=true, title="Want RSI?", tooltip="Check if you want to be displayed and used as filter", group="Indicators group")
lengthRSI = input.int(14, "RSI Length", minval=1)
isRSIM= input.bool(defval=false, title="Want RSI MA?", tooltip="Check if you want to be displayed")
//For STOCH
lengthStoch = input.int(14, "Stochastic Length", minval=1)
isSTOCHK=input.bool(defval=true, title="Want STOCH K?", tooltip="Check if you want to be displayed and used as filter")
smoothK = input.int(3, title="K", minval=1)
isSTOCHD=input.bool(defval=true, title="Want STOCH D?", tooltip="Check if you want to be displayed and used as filter")
smoothD = input.int(3, title="D", minval=1)
// For RVI
isRVI=input.bool(defval=true, title="Want RVI?", tooltip="Check if you want to be displayed and used as filter")
lengthRVI = input.int(14, "RVI Length", minval=1)
isRVIM=input.bool(defval=false, title="Want RVI MA?", tooltip="Check if you want to be displayed")
// For ADX
isADX=input.bool(defval=true, title="Want ADX?", tooltip="Check if you want to be displayed and used as filter")
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
// For MFI
isMFI=input.bool(defval=true, title="Want MFI?", tooltip="Check if you want to be displayed and used as filter")
lengthMFI = input.int(title="MFI Length", defval=14)

// DIVERGENCE INPUT
isRSIDiv=input.bool(defval=true, title="Want RSI Divergence?", tooltip="Check if you want to be displayed",group="Toggle Divergence Plotting")
plotBull = input(title='Plot Bullish', defval=true)
plotBear = input(title='Plot Bearish', defval=true)
plotHiddenBull = input(title='Plot Hidden Bullish', defval=true) 
plotHiddenBear = input(title='Plot Hidden Bearish', defval=true) 
//For RSI Divergence search
lbR = input(5, title="Right bars", tooltip= "limit of bars to the right from pivot")
lbL = input(5, title="Left bars", tooltip= "limit of bars to the left from pivot")
rangeUpper = input(60, title="Max bars in rage", tooltip= "limit of maximum bars in range to consider for for divergence")
rangeLower = input(5, title="Min bars in range", tooltip= "limit of minimum bars in range to consider for for divergence")
 

ma(source, length, type) =>
    switch type
        "EMA" => ta.ema(source, length)
        "SMA" => ta.sma(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
maTypeInput = input.string("EMA", title="MA Type", options=["EMA", "SMA", "SMMA (RMA)", "WMA", "VWMA", "Bollinger Bands"], group="MA Settings")


length = input.int( 14, "MA lenght" )
isemaguide= input.bool(defval=false, title="Want XMA GUIDE?", tooltip="Check if you want xma guide to be displayed and used as filter (xma is selected from MA Type parameter), long for values below and short for values above", group="TENDENCY GUIDE group")
emaLength = input.int(200, "XMA GUIDE lenght")
sslen = input.int(5, title="SSL Channel Length", minval=1)

isVolumefilter= input.bool(defval=false, title="Want Volume Filter?", tooltip="Check if you want volume filter to be used, the positions are open when standar deviation values are above thresholdMedium",  group="VOLUME settings")
volumeLength = input(400, title="Volume MA Length")         
thresholdExtraHigh  = input.float(4.0, title="Extra High Volume Threshold") 
thresholdHigh = input.float(2.5, title="High Volume Threshold")
thresholdMedium = input.float(1.0, title="Medium Volume Threshold")




//Limits Overbought, Oversold and threshold
overSold = input( 30, title = "Over Sold region", group = "Limits" )
overBought = input( 70, title = "Over Bougth region" )
overSoldExt = input( 20, title = "Extreme Over Sold region" )
overBoughtExt = input( 80, title = "Extreme Over Bougth region" )
adxthreshold =input( 50, title= "ADX Threshold" )

price = close

//INDICATORS CALCULATION
///// vWAP ////
myVwap= ta.vwap(price,length)
vwapRsi=ta.rsi(myVwap,length)
covwaprsi = ta.crossover(vwapRsi, overSold)
cuvwaprsi = ta.crossunder(vwapRsi, overBought)

////////.  MOMENTUM.    ////
//. RSI
//. MFI
//. STOCH RSI
//.
///////////////// RELATIVE STRENGHT INDEX RSI
up = ta.rma(math.max(ta.change(price), 0), length)
down = ta.rma(-math.min(ta.change(price), 0), length)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
vrsi = ta.rsi(price, length)
rsiMA = ma(vrsi, length, maTypeInput)
co = ta.crossover(vrsi, overSold)
cu = ta.crossunder(vrsi, overBought)
co50 = ta.crossover(vrsi, 50)
cu50 = ta.crossunder(vrsi, 50)

//// DIVERGENCE CALCULATION
oscrsi =vrsi
plFound = na(ta.pivotlow(oscrsi, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(oscrsi, lbL, lbR)) ? false : true
// {RSI TREND IDENTIFICATION 
_inRange(cond) =>
    bars = ta.barssince(cond == true)
    rangeLower <= bars and bars <= rangeUpper

oscHL = oscrsi > ta.valuewhen(plFound, oscrsi, 1) and _inRange(plFound[1]) and oscrsi <= 50
oscLL = oscrsi < ta.valuewhen(plFound, oscrsi, 1) and _inRange(plFound[1]) and oscrsi <= 50
oscHH = oscrsi > ta.valuewhen(phFound, oscrsi, 1) and _inRange(phFound[1]) and oscrsi >= 50
oscLH = oscrsi < ta.valuewhen(phFound, oscrsi, 1) and _inRange(phFound[1]) and oscrsi >= 50
// }
// {PRICE TREND IDENTIFICATION
priceLL = low < ta.valuewhen(plFound, low, 1) 
priceHL = low > ta.valuewhen(plFound, low, 1)
priceHH = high > ta.valuewhen(phFound, high, 1)
priceLH = high < ta.valuewhen(phFound, high, 1)
//}
//{DIVERGENCE IDENTIFICATION
bullCond = plotBull and priceLL and oscHL and plFound
hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
bearCond = plotBear and priceHH and oscLH and phFound
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound
// } 
// { COLOR ASSIGNMENT 
bearColor = color.red 
bullColor = color.green 
hiddenBullColor = color.new(color.yellow,50) 
hiddenBearColor = color.new(color.purple,50) 
textColor = color.white
noneColor = color.new(color.white, 100)
//}

///////////////////// Money Flow Index (MFI)

// MFI similar to common RSI function
_money_flow_index(uppermfi, lowermfi) =>
    if lowermfi == 0
        100
    if uppermfi == 0
        0
    100.0 - (100.0 / (1.0 + uppermfi / lowermfi))
float mfiUp  = math.sum(volume * (ta.change(hlc3) <= 0.0 ? 0.0 : hlc3), lengthMFI)
float mfiDown = math.sum(volume * (ta.change(hlc3) >= 0.0 ? 0.0 : hlc3), lengthMFI)

mfi = _money_flow_index(mfiUp, mfiDown)
vmfi =ta.mfi(hlc3,lengthMFI)
comfi = ta.crossover(mfi, overSoldExt)
cumfi = ta.crossunder(mfi, overBoughtExt)

/////////////////////// STOCHASTIC RSI 


rsi1 = ta.rsi(price, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
cokd = ta.crossover(k, d)
cukd = ta.crossunder(k, d)

///. VOLATILITY. 
//. RVI
//. ADX
/////////////////// RELATIVE VOLATILITY INDEX
stddev = ta.stdev(price, lengthRVI)
upper = ta.ema(ta.change(price) <= 0 ? 0 : stddev, lengthRVI)
lower = ta.ema(ta.change(price) > 0 ? 0 : stddev, lengthRVI)
rvi = upper / (upper + lower) * 100
corvi = ta.crossover(rvi, overSold)
curvi = ta.crossunder(rvi, overBought)
rviMA = ma(rvi, length, maTypeInput)

//////////////// AVERAGE DIRECTIONAL INDEX ADX (volat) //////////
dirmov(len) =>
    upadx = ta.change(high)
    downadx = -ta.change(low)
    plusDM = na(upadx) ? na : (upadx > downadx and upadx > 0 ? upadx : 0)
    minusDM = na(downadx) ? na : (downadx > upadx and downadx > 0 ? downadx : 0)
    truerange = ta.rma(ta.tr, len)
    plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
    minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
    [plus, minus]
adx(dilen, adxlen) =>
    [plus, minus] = dirmov(dilen)
    sum = plus + minus
    adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)

coadx = ta.crossover(sig, adxthreshold)
cuadx = ta.crossunder(sig, adxthreshold)

////////////// Calculate ATR
//useATRFilter=input.bool(false)
minATRLength=input.int(1,title="minATRlength",tooltip="Minimum lenght for ATR filter consideration")
maxATRLength=input.int(10,title="maxATRlength",tooltip="Maximum lenght for ATR filter consideration")
atr = ta.atr(length)
recentAtr = ta.atr(minATRLength)
historicalAtr = ta.atr(maxATRLength)
//seATRFilter ? recentAtr > historicalAtr : true

///. VOLUME
//. Volume heatmap
//. 
//////////// Calculate Heatmap Volume
volumeMean = ta.sma(volume, volumeLength)
volumeStd = ta.stdev(volume, volumeLength)
stdBar = (volume - volumeMean) / volumeStd
// Define Volume Filter
volumeFilter = stdBar > thresholdMedium 

//////////  TENDENCY  ////   
//. MOVING AVERAGE
//. SSL CHANNEL
/////////////////////////

emaguide=ma(price,emaLength,maTypeInput)
ema100=ta.ema(price,100)
ema200=ma(price,200,maTypeInput)
///// SSL CHANNEL ////
smaHigh=ta.sma(high, sslen)
smaLow=ta.sma(low, sslen)
var float Hlv = na
Hlv := price > smaHigh ? 1 : price < smaLow ? -1 : nz(Hlv[1])
sslDown = Hlv < 0 ? smaHigh: smaLow
sslUp   = Hlv < 0 ? smaLow : smaHigh

cossl= ta.crossover(sslUp, sslDown)
cussl= ta.crossunder(sslUp, sslDown)

// Plot SSL Channel and 200 EMA
plot(sslDown, linewidth=2, color=color.red)
plot(sslUp, linewidth=2, color=color.lime)
plot(ema200, title="200 XMA", color=color.white, linewidth=2)
plot(ema100, title="100 EMA", color=color.yellow, linewidth=2)
plot(emaguide, title="XMA guide", color=color.rgb(11, 253, 19), linewidth=2)


///////// Define Filters depending on the election of indicator combination

filterbuy=false 
filtersell=false 

if(isADX==false)
    if(isRVI==false) 
        if(isMFI==false) 
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false) 
                    filterbuy:=false
                    filtersell:=false
                else    
                    filterbuy:= isSTOCHD and isSTOCHK and cokd//k<overSold and cokd   
                    filtersell:=isSTOCHD and isSTOCHK and cukd //k>overBought and cukd 
            else
                if(isSTOCHD==false or isSTOCHK==false) 
                    filterbuy:=co
                    filtersell:=cu
                else    
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and vrsi<overSold  //k<overSold and cokd and vrsi<overSold  
                    filtersell:=isSTOCHD and isSTOCHK and cukd and vrsi>overBought //k>overBought and cukd and vrsi>overBought
        else
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false) 
                    filterbuy:=comfi
                    filtersell:=cumfi
                else 
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and mfi<overSoldExt //k<overSold and cokd and mfi<overSoldExt  
                    filtersell:=isSTOCHD and isSTOCHK and cukd and mfi>overBoughtExt //k>overBought and cukd and mfi>overBoughtExt
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= vrsi<overSold and mfi<overSoldExt  
                    filtersell:= vrsi>overBought and mfi>overBoughtExt
                else
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and vrsi<overSold and mfi<overSoldExt //k<overSold and cokd and vrsi<overSold and mfi<overSoldExt  
                    filtersell:=isSTOCHD and isSTOCHK and cukd and vrsi>overBought and mfi>overBoughtExt //k>overBought and cukd and vrsi>overBought and mfi>overBoughtExt
    else
        if(isMFI==false) 
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= corvi
                    filtersell:= curvi
                else 
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and rvi<overBought //k<overSold and cokd and rvi<overBought
                    filtersell:=isSTOCHD and isSTOCHK and cukd and  rvi>overSold //k>overBought and cukd and  rvi>overSold
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= vrsi<overSold  and rvi<overBought
                    filtersell:=vrsi>overBought and  rvi>overSold
                else
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and vrsi<overSold and rvi<overBought //k<overSold and cokd and vrsi<overSold and rvi<overBought
                    filtersell:=isSTOCHD and isSTOCHK and cukd and vrsi>overBought and  rvi>overSold //k>overBought and cukd and vrsi>overBought and  rvi>overSold            
        else
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= mfi<overSoldExt and rvi<overBought
                    filtersell:= mfi>overBoughtExt and  rvi>overSold
                else
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and mfi<overSoldExt and rvi<overBought //k<overSold and cokd and mfi<overSoldExt and  rvi<overBought
                    filtersell:=isSTOCHD and isSTOCHK and cukd and mfi>overBoughtExt and  rvi>overSold  //k>overBought and cukd and mfi>overBoughtExt and  rvi>overSold
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= vrsi<overSold and mfi<overSoldExt and rvi<overBought
                    filtersell:= vrsi>overBought and mfi>overBoughtExt and  rvi>overSold
                else
                    filterbuy:= isSTOCHD and isSTOCHK and cokd and vrsi<overSold and mfi<overSoldExt and rvi<overBought //k<overSold and cokd and vrsi<overSold and mfi<overSoldExt and rvi<overBought
                    filtersell:=isSTOCHD and isSTOCHK and cukd and vrsi>overBought and mfi>overBoughtExt and  rvi>overSold //k>overBought and cukd and vrsi>overBought and mfi>overBoughtExt and  rvi>overSold
else 
    if(isRVI==false)
        if(isMFI==false) 
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:=coadx
                    filtersell:=cuadx
                else    
                    filterbuy:= cokd and sig>adxthreshold //k<overSold and cokd and sig>adxthreshold
                    filtersell:= cukd and sig>adxthreshold //k>overBought and cukd and sig>adxthreshold //sig<adxthreshold
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:=vrsi<overSold and sig>adxthreshold
                    filtersell:= vrsi>overBought and sig>adxthreshold //sig<adxthreshold 
                else            
                    filterbuy:= cokd and vrsi<overSold and sig>adxthreshold //k<overSold and cokd and vrsi<overSold and sig>adxthreshold
                    filtersell:= cukd and vrsi>overBought and sig>adxthreshold //k>overBought and cukd and vrsi>overBought and sig>adxthreshold //sig<adxthreshold
        else
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= mfi<overSoldExt and sig>adxthreshold
                    filtersell:=mfi>overBoughtExt  and sig>adxthreshold //sig<adxthreshold
                else 
                    filterbuy:= cokd and mfi<overSoldExt and sig>adxthreshold //k<overSold and cokd and mfi<overSoldExt and sig>adxthreshold
                    filtersell:= cukd and mfi>overBoughtExt  and sig>adxthreshold //k>overBought and cukd and mfi>overBoughtExt  and sig>adxthreshold //sig<adxthreshold
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= vrsi<overSold and mfi<overSoldExt and sig>adxthreshold
                    filtersell:= vrsi>overBought and mfi>overBoughtExt  and sig>adxthreshold // sig<adxthreshold
                else           
                    filterbuy:= cokd and vrsi<overSold and mfi<overSoldExt and sig>adxthreshold //k<overSold and cokd and vrsi<overSold and mfi<overSoldExt and sig>adxthreshold
                    filtersell:= cukd and vrsi>overBought and mfi>overBoughtExt  and sig>adxthreshold //k>overBought and cukd and vrsi>overBought and mfi>overBoughtExt  and sig>adxthreshold // sig<adxthreshold
    else
        if(isMFI==false) 
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= rvi<overBought and sig>adxthreshold
                    filtersell:= rvi>overSold and sig>adxthreshold // //sig<adxthreshold
                else
                    filterbuy:= cokd and rvi<overBought and sig>adxthreshold //k<overSold and cokd and rvi<overBought and sig>adxthreshold
                    filtersell:= cukd and  rvi>overSold and sig>adxthreshold// k>overBought and cukd and  rvi>overSold and sig>adxthreshold // sig<adxthreshold
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= vrsi<overSold and rvi<overBought and sig>adxthreshold
                    filtersell:= vrsi>overBought and  rvi>overSold and sig>adxthreshold// sig<adxthreshold
                else 
                    filterbuy:= cokd and vrsi<overSold and rvi<overBought and sig>adxthreshold //k<overSold and cokd and vrsi<overSold and rvi<overBought and sig>adxthreshold
                    filtersell:= cukd and vrsi>overBought and  rvi>overSold and sig>adxthreshold //k>overBought and cukd and vrsi>overBought and  rvi>overSold and sig>adxthreshold //sig<adxthreshold
        else
            if(isRSI==false)
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:=  mfi<overSoldExt and rvi<overBought and sig>adxthreshold
                    filtersell:= mfi>overBoughtExt and  rvi>overSold and sig>adxthreshold //sig<adxthreshold
                else
                    filterbuy:= cokd and mfi<overSoldExt and rvi<overBought and sig>adxthreshold //k<overSold and cokd and mfi<overSoldExt and rvi<overBought and sig>adxthreshold
                    filtersell:= cukd and mfi>overBoughtExt and  rvi>overSold and sig>adxthreshold //k>overBought and cukd and mfi>overBoughtExt and  rvi>overSold and sig>adxthreshold //sig<adxthreshold
            else
                if(isSTOCHD==false or isSTOCHK==false)
                    filterbuy:= vrsi<overSold and mfi<overSoldExt and rvi<overBought and sig>adxthreshold
                    filtersell:= vrsi>overBought and mfi>overBoughtExt and  rvi>overSold and sig>adxthreshold //sig<adxthreshold
                else
                    filterbuy:= cokd and vrsi<overSold and mfi<overSoldExt and rvi<overBought and sig>adxthreshold //k<overSold and cokd and vrsi<overSold and mfi<overSoldExt and rvi<overBought and sig>adxthreshold
                    filtersell:= cukd and vrsi>overBought and mfi>overBoughtExt and  rvi>overSold and sig>adxthreshold //k>overBought and cukd and vrsi>overBought and mfi>overBoughtExt and  rvi>overSold and sig>adxthreshold //sig<adxthreshold

///////// Define BUY AND SELL conditions

buyCondition = false
sellCondition= false

//isSSL and cossl
// EMA GUIDE AND VOLUME FILTER CONDITIONS

if(isVolumefilter==true)
    if(isemaguide==true)
        buyCondition:= filterbuy and price<emaguide and volumeFilter
        sellCondition:= filtersell and price>emaguide and volumeFilter
    else
        buyCondition:= filterbuy and volumeFilter
        sellCondition:= filtersell and volumeFilter
else
    if(isemaguide==true)
        buyCondition:= filterbuy and price<emaguide 
        sellCondition:= filtersell and price>emaguide
    else 
        buyCondition := filterbuy
        sellCondition := filtersell

// %%%%%%%%%%%%%%%%%%%%%%%
// Set SL and TP levels
// %%%%%%%%%%%%%%%%%%%%%%%

//stoploss and takeprofit by percentage
var float longStopLoss= na
var float longTakeProfit= na
var float shortStopLoss= na
var float shortTakeProfit= na
// FOR TRAILING SL
longstopLossPrice = price * (1 - (trailPercent / 100))
shortstopLossPrice = price * (1 + (trailPercent / 100))
var float longstopLossLevel = na
var float shortstopLossLevel = na

if(SLTPviaPerc==true)
    longStopLoss := strategy.position_avg_price*(1-(stopLoss*0.01)) // price*(1-(stopLoss*0.01))
    longTakeProfit := strategy.position_avg_price*(1+(takeProfit*0.01))   //price*(1+(takeProfit*0.01)) 
    shortStopLoss := strategy.position_avg_price*(1+(stopLoss*0.01))   //price*(1+(stopLoss*0.01))
    shortTakeProfit := strategy.position_avg_price*(1-(takeProfit*0.01)) //  price*(1-(takeProfit*0.01))
if(SLTPviaTRAILING==true)
    longstopLossLevel := price > longstopLossPrice ? longstopLossPrice : longstopLossLevel[1]
    shortstopLossLevel := price < shortstopLossPrice ? shortstopLossPrice : shortstopLossLevel[1]


if time>= fromDate and time<= toDate 
    if (buyCondition)
        strategy.entry("BuySTR", strategy.long, qty=qty1, alert_message="Long order opened") //qty=qty1,alert_message="Long order opened"
        if (strategy.position_size > 0 and SLTPistaken)
            strategy.exit('BuySTR', from_entry='BuySTR', limit=longTakeProfit, stop=longStopLoss, trail_price=longstopLossLevel, comment='Buy: TP/SL with trail')
    if (sellCondition)
        strategy.entry("SellSTR", strategy.short, qty=qty1, alert_message="Short order opened") ////qty=qty1,alert_message="Short order opened" 
        if (strategy.position_size < 0 and SLTPistaken) 
            strategy.exit('SellSTR', from_entry='SellSTR', limit=shortTakeProfit, stop=shortStopLoss, trail_price=shortstopLossLevel, comment='Sell: TP/SL with trail')

Overview

Users can toggle each indicator individually, yielding up to 32 potential entry setups alongside optional moving average and volume filters. Risk management includes predefined capital drawdown tiers (COOK, WALK, HAWK, ALLIN) and configurable stop loss, take profit, or trailing stop mechanics (set to NONE by default). Pyramiding allows up to two entries directly on the price chart.

Details

Published by

hbelloma on GitHub

Code credit

ayaxhector666 for Two Level Capital, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Volatility & bands, Volume, Trend

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy can add several entries in the same direction
  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
From Datetimetimestamp('17 Jul 2010 00:00 UTC')fromDate
To Datetimetimestamp('31 Dec 2025 23:59 UTC')toDate
Plan for risk management in Two Level CapitalstringALLINPlan
Risk % of capitalfloat100riskCapital
Method for setting SL and TPstringNONESLTPMethod
Stop Loss Percentagefloat2.0stopLoss
Take Profit Percentagefloat10.0takeProfit
SL Multiplierfloat1.0slMultiplier
TP Multiplierfloat5.0tpMultiplier
Want trailing SL?boolfalseSLTPviaTRAILING
Trail Percentagefloat1.0trailPercent
Want RSI?booltrueisRSI
Show all 40 settings
SettingTypeDefaultVariable
RSI Lengthint14lengthRSI
Want RSI MA?boolfalseisRSIM
Stochastic Lengthint14lengthStoch
Want STOCH K?booltrueisSTOCHK
Kint3smoothK
Want STOCH D?booltrueisSTOCHD
Dint3smoothD
Want RVI?booltrueisRVI
RVI Lengthint14lengthRVI
Want RVI MA?boolfalseisRVIM
Want ADX?booltrueisADX
ADX Smoothingint14adxlen
DI Lengthint14dilen
Want MFI?booltrueisMFI
MFI Lengthint14lengthMFI
Want RSI Divergence?booltrueisRSIDiv
Plot BullishbooltrueplotBull
Plot BearishbooltrueplotBear
Plot Hidden BullishbooltrueplotHiddenBull
Plot Hidden BearishbooltrueplotHiddenBear
Right barsint5lbR
Left barsint5lbL
Max bars in rageint60rangeUpper
Min bars in rangeint5rangeLower
MA TypestringEMAmaTypeInput
MA lenghtint14length
Want XMA GUIDE?boolfalseisemaguide
XMA GUIDE lenghtint200emaLength
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

6 stars

Capital41 Fusion Core Strategy is an overlay trading strategy that combines an exponential moving average trend filter, RSI, Williams %R, and volume/ATR expansion into a composite momentum oscillator. It executes long trades when the smoothed oscillator crosse

Strategy v6 TrendOscillators & momentum
Updated 8 weeks ago · MIT GitHub repository of Capital41 Fusion Core Strategy

This strategy executes trades on gold based on a confluence of Supertrend, RSI, MACD, Bollinger Bands, and volume spikes. It enters long or short positions when trend direction aligns with momentum and price positioning relative to volatility bands, filtered b

Strategy v6 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of XAUUSD High Probability Strategy

Parabolic SAR

by g-moe
3 stars

This strategy overlays a smoothed moving average on price and combines it with Aroon, Chaikin Money Flow and a Chaikin oscillator to define long and short conditions. Relative Vigor Index and Parabolic SAR values are calculated for exits. Entries can be limite

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of Parabolic SAR
2 stars

This strategy calculates MACD, ADX trend strength, ATR, and a rolling VWAP resetting at fixed bar intervals. It plots the VWAP line, stop loss levels, and profit targets directly on the price chart. Long positions enter when MACD crosses above its signal line

Strategy v5 TrendOscillators & momentum Repaints
Updated 8 months ago · MIT GitHub repository of MACD & VWAP Strategy with ATR SL/Targets

12-BB

by sam30606
1 stars

This overlay strategy combines a Bollinger-style band with separate ATR upper and lower envelopes and optional ADX, Volume Flow Indicator, and RSI filters. It sizes positions as a percentage of equity. Settings change band length and multiplier, ATR periods an

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · None stated GitHub repository of 12-BB

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers