Indicators Combination Framework v3 IND  [DTU]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dturkuler
//@version=5

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ HISTORY{
//v3.02
//UPD:  Indicator factor inputs displays with factor descriptions 
//UPD:  Indicator Parameter inputs displays with parameter descriptions 

//v3.01
//ADD:  23 new indicators added to indicators list from the library. Current Total number of Indicators are 93. (to be continued to adding)
//ADD:  2 more Parameters (P1,P2) for indicator calculation added. Par:(Use Defaults) uses only indicator(Source,Length) with library's default parameters. Par:(Use Extra Parameters P1,P2) use indicator(Source,Length,p1,p2) with additional parameters if indicator needs.
//ADD:  log calculation (simple, log10) option added on indicator function entries  
//ADD:  New Output Signals added for compatibility on exporting condition signals to different Strategy templates.
//ADD:  Alerts Added according to conditions results
//UPD:  Indicator source inputs now display with indicators descriptions 
//UPD:  Most off the source code rearranged and some functions moved to the new library. Now system work like a little bit frontend/backend
//UPD:  Performance improvement made on factorization and other source code
//UPD:  Input GUI rearranged
//UPD:  Tooltips corrected
//REM:  Extended indicators removed 
//UPD:  IND1-IND4 added to indicator data source. Now it is possible to create new indicators with the previously defined indicators value. ex: IND1=ema(close,14) and IND2=rsi(IND1,20) means IND2=rsi(ema(close,14),20) 
//UPD:  Custom Indicator (CUST) added to indicator data source and Combination Indicator source. 
//UPD:  Volume added to indicator data source and Combination Indicator source. 
//REM:  Custom indicators removed and only one custom indicator left
//REM:  Plot Type "Org. Range (-1,1)" removed
//UPD:  angle, rising, falling type operators moved to indicator library

//v2.01
//UPD:  angle, rising, falling functions moved from conditions to extended indicator data source parameters
//ADD:  tooltips added Extended indicator tooltip constants
//UPD:  Source Code remodified for extended indicators usage
//ADD:  fn_get_xsource function added
//ADD:  math.round_to_mintick added to fn_security function calculation

//v1.07
//IMPORTANT NOTE: !!! double, triple factored indicators like DEMA, TEMA.. and indictor factorization is limited to 5000 bars due to TV limitation.. Make Attention on long term calculations
//ADD:  angle(IND,VALUE) added to combinations, added fn_angle(src1_,src2_) 
//      USAGE: in combination=>  1st Indicator: (select any option), Operator:(Select any operator except rising, falling), 2nd Indicator: ("angle(1st IND,1st IND[1])"), Value: (angle value)  
//      ex: c1:IND1 c2:>  c3:"angle(1st IND,1st IND[1])", c4:12  means that => isAngle(IND1[0],IND1[1])>12
//UPD:  1st indicator options updated on inputs
//UPD:  2nd indicators constants updated on constants
//UPD:  functions fn_get_Condition_Indicator(...), fn_get_Condition_Result(...) updated

//v1.06
//ADD:  Custom CRONEX T DEMARKER indicator added to custom indicator 4
//ADD:  Plotting Type constants added, fn_plotFunction and Inputs options updated
//UPD:  Increased number of spare operators to be used in future
//UPD:  Condition tooltip updated

//v1.05
//ADD:  Number of custom indicators increased from 3 to 5 (see the cutom indicator inputs and functions)
//ADD:  Added double triple, Quatr factorizer for all indicators (like convert EMA to DEMA, TEMA, QEMA...)
//ADD:  fn_factor function added 
//UPD:  fn_get_indicator updated
//UPD:  Some tooltips updated

//v1.04
//ADD:  Number condition increased from 3 to 4 for aech combination (longentry, shortentry, longclose, shortclose)
//ADD:  Stochastic, Percent value added for each indicator
//ADD:  Source data added for each indicator
//UPD:  Calculation bug on src_data removed
//UPD:  Indicators default values updated (Arranged to  BTCUSDT for testing purpose)

//v1.03
//UPD:  Longlose and shortclose codes updated. Now works as expected

//v1.02
//ADD:  Tooltips addec to the settings screen. (Tooltip constants added)
//ADD:  Falling and rising operators added to combinations. USAGE:(1st Indicator---Falling---IS(1st Indicator,VALUE)----int VALUE)
//      Calculates: ta.falling(1st indicator, VALUE)... VALUE Should be integer (1,2...n) 
//      Desc: if the 1st indicator is falling since the previous # of bars (VALUE). 
//ADD:  use Simple Log addded for testing purpose but not available for usage (to be corrected)
//UPD:  Strategy part improved. Long close and short close now works as expected (without opposite close) 
//UPD:  Constants Updated: CONDITION INDICATOR SOURCE CONSTANTS, CONDITION OPERATOR CONSTANTS
//UPD:  functions updated: fn_get_source() , fn_plotFunction(), fn_get_indicator(), fn_get_Condition_Indicator(), fn_get_Condition_Result()

//v1.01
//UPD:  Document violations removed

//v1.00
//UPD:  Condition indicator value input will be previous value of the selected indicator if "VALUE" is not selected
//ADD:  Added Profit gfx (should be improved!!!) 
//UPD:  Updated condition result & join conditions functions  with constants variables
//ADD:  Added area for Custom indicators on input panel
//ADD:  Added External indicator import on settings panel
//ADD:  Prepared documentation

//v_x.xx
//TODO: Add factorized Fibo avg range indicator (good for trend definition and entry exit points)
//TODO: Add bands to the indicator and conditions
//TODO: Add debug window for exporting indicator's parameters
//TODO: Add Alerts, Condiional alerts for indicator (study) part
//TODO: Create export function v3 for @Pinecoders Strategy Template 
//************ HISTORY}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ STRATEGY VARIABLES{
SystemVersion=          'v3' 
ScriptType=             'IND'
stage=                  ''
SystemName =            'Indicators Combination Framework '+SystemVersion+' '+ScriptType+' ' + stage + ' [DTU]'
TradeId =               'IND COMB FRMWRK '+SystemVersion + ' '+ ScriptType+' ' +stage
InitCapital =           1000
InitPosition =          100.0       // %10 of capital with x10 leverage
InitCommission =        0.04
InitPyramidMax =        5           // Arrange it regarding to no margin call in strategy/performance tab 
CalcOnorderFills =      false
ProcessOrdersOnClose =  false
CalcOnEveryTick =       false
marginlong=             1./10*50    // (1/10x leverage) * 50 (Margin ratio in general)  
marginshort=            1./10*50    // (1/10x leverage) * 50 (Margin ratio in general)
precision_=             4           // Keep it >=4 (I use it for data export )
//************ END STRATEGY VARIABLES}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
indicator(title=SystemName,shorttitle=TradeId,overlay=true, precision=precision_)
//strategy( title=SystemName, shorttitle=TradeId, overlay=true,
//          margin_short=marginshort, margin_long=marginlong,
//          pyramiding=InitPyramidMax, initial_capital=InitCapital, 
//          default_qty_type=strategy.percent_of_equity, default_qty_value=InitPosition, 
//          commission_type=strategy.commission.percent, commission_value=InitCommission, 
//          calc_on_order_fills=CalcOnorderFills, precision=precision_, 
//          process_orders_on_close=ProcessOrdersOnClose, calc_on_every_tick=CalcOnEveryTick, 
//          scale=scale.left,  currency=currency.USD)                 

import dturkuler/lib_Indicators_v2_DTU/2 as dtu


//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ CONSTANTS{
//_______________GROUP NAME CONSTANTS
s_grp_settings=     "A) ═════════════ SETTINGS ══════════"
s_grp_plottype=     "B)══════════ PLOT TYPE OPS ═════════"
s_grp_indicators=   "C)════════════ INDICATORS ══════════"
s_grp_indicator1=   "C1)══════════ INDICATOR 1 ══════════"
s_grp_indicator2=   "C2)══════════ INDICATOR 2 ══════════"
s_grp_indicator3=   "C3)══════════ INDICATOR 3 ══════════"
s_grp_indicator4=   "C4)══════════ INDICATOR 4 ══════════"
s_grp_indicator5=   "C5)══════════ INDICATOR 5 ══════════"
s_grp_LEC=          "D1)══════ LONG ENTRY CONDITION ═════"
s_grp_SEC=          "D2)══════ SHORT ENTRY CONDITION ════"
s_grp_LCC=          "D3)══════ LONG CLOSE CONDITION ═════"
s_grp_SCC=          "D4)══════ SHORT CLOSE CONDITION ════"
s_grp_custom_ind=   "E) ════ CUSTOM INDICATOR (CRONEX) ══"
s_grp_signal=       "F) ═════════ SIGNAL EXPORT ═════════"
s_grp_strategy=     "G) ════════════ STRATEGY ═══════════"

//_______________INDICATORS CONSTANTS 
// Indicator constants are defined with descriptions to better display in inputs dropdowns
// To use them to call library function, It should be splitted with ".-" separator by using fn_split(indicator_constant,".-"). splitted first part will be used on library function part
// ex: "cma(src,len)"
ovrly      = '▼▼▼ OVERLAY ▼▼▼.-------------------------(Not used as indicator, info Only)Just used to separate input options of overlayable indicators ',
org        = 'Original Value.--------------------------Return input source value as output',
hide       = 'DONT DISPLAY.----------------------------Dont display/calculate the indicator. (For my framework usage)',
alma       = 'alma(src,len,offset=0.85,sigma=6).-------Arnaud Legoux Moving Average ',
ama        = 'ama(src,len,fast=14,slow=100).-----------Adjusted Moving Average',
acdst      = 'accdist().-------------------------------Accumulation/distribution index. ',
cma        = 'cma(src,len).----------------------------Corrective Moving average    ',
dema       = 'dema(src,len).---------------------------Double EMA  (Same as EMA with 2 factor)',
ema        = 'ema(src,len).----------------------------Exponential Moving Average ',
gmma       = 'gmma(src,len).---------------------------Geometric Mean Moving Average',
hghst      = 'highest(src,len).------------------------Highest value for a given number of bars back.   ',
hl2ma      = 'hl2ma(src,len).--------------------------higest lowest moving average',
hma        = 'hma(src,len).----------------------------Hull Moving Average.',
lgAdt      = 'lagAdapt(src,len,perclen=5,fperc=50).----Ehlers Adaptive Laguerre filter',
lgAdV      = 'lagAdaptV(src,len,perclen=5,fperc=50).---Ehlers Adaptive Laguerre filter variation',
lguer      = 'laguerre(src,len).-----------------------Ehlers Laguerre filter',
lsrcp      = 'lesrcp(src,len).-------------------------lowest exponential esrcpanding moving line',
lexp       = 'lexp(src,len).---------------------------lowest exponential expanding moving line ',
linrg      = 'linreg(src,len,loffset=1).---------------Linear regression',
lowst      = 'lowest(src,len).-------------------------Lovest value for a given number of bars back.',
mgi        = 'mcginley(src, len).----------------------McGinley Dynamic adjusts for market speed shifts, which sets it apart from other moving averages, in addition to providing clear moving average lines',
pcnl       = 'percntl(src,len).------------------------percentile nearest rank. Calculates percentile using method of Nearest Rank.',
pcnli      = 'percntli(src,len).-----------------------percentile linear interpolation. Calculates percentile using method of linear interpolation between the two nearest ranks.',
prev       = 'previous(src,len).-----------------------Previous n (len) value of the source   ',
pvth       = 'pivothigh(src,BarsLeft=len,BarsRight=2).-Previous pivot high. src=src, BarsLeft=len, BarsRight=p1=2',
pvtl       = 'pivotlow(src,BarsLeft=len,BarsRight=2).--Previous pivot low. src=src, BarsLeft=len, BarsRight=p1=2',
rema       = 'rema(src,len).---------------------------Range EMA (REMA)   ',
rma        = 'rma(src,len).----------------------------Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.',
sar        = 'sar(start=len, inc=0.02, max=0.02).------Parabolic SAR (parabolic stop and reverse) is a method to find potential reversals in the market price direction of traded goods.start=len, inc=p1, max=p2. ex: sar(0.02, 0.02, 0.02)    ',
sma        = 'sma(src,len).----------------------------Smoothed Moving Average',
smma       = 'smma(src,len).---------------------------Smoothed Moving Average',
supr2      = 'super2(src,len).-------------------------Ehlers super smoother, 2 pole ',
supr3      = 'super3(src,len).-------------------------Ehlers super smoother, 3 pole',
strnd      = 'supertrend(src,len,period=3).------------Supertrend indicator',
swma       = 'swma(src,len).---------------------------Sine-Weighted Moving Average',
tema       = 'tema(src,len).---------------------------Triple EMA  (Same as EMA with 3 factor)',
tma        = 'tma(src,len).----------------------------Triangular Moving Average',
vida       = 'vida(src,len).---------------------------Variable Index Dynamic Average   ',
vwma       = 'vwma(src,len).---------------------------Volume Weigted Moving Average',
vstop      = 'volstop(src,len,atrfactor=2).------------Volatility Stop is a technical indicator that is used by traders to help place effective stop-losses. atrfactor=p1',
wma        = 'wma(src,len).----------------------------Weigted Moving Average ',
vwap       = 'vwap(src_).------------------------------Volume Weighted Average Price (VWAP) is  used to measure the average price weighted by volume     ',
nvrly      = '▼▼▼ NON OVERLAY ▼▼.----------------------(Not used as indicator, info Only)Just used to separate input options of non overlayable indicators ',
adx        = 'adx(dilen=len, adxlen=14, adxtype=0).----adx. The Average Directional Index (ADX) is a used to determine the strength of a trend. len=>dilen, p1=adxlen (default=14), p2=adxtype 0:ADX, 1:+DI, 2:-DI (def:0)',
angle      = 'angle(src,len).--------------------------angle of the series   (Use its Input as another indicator output)',
aroon      = 'aroon(len,dir=0).------------------------aroon indicator. Aroons major function is to identify new trends as they happen.p1 = dir: 0=mid (default), 1=upper, 2=lower',
atr        = 'atr(src,len).----------------------------average true range. RMA of true range.                ',
awsom      = 'awesome(fast=len=5,slow=34,type=0).------Awesome Oscilator is an indicator used to measure market momentum. defaults : fast=len= 5, p1=slow=34, p2=type: 0=Awesome, 1=difference',
bbr        = 'bbr(src,len,mult=1).---------------------bollinger %%',
bbw        = 'bbw(src,len,mult=2).---------------------Bollinger Bands Width. The Bollinger Band Width is the difference between the upper and the lower Bollinger Bands divided by the middle band.',
cci        = 'cci(src,len).----------------------------commodity channel index',
cctbb      = 'cctbbo(src,len).-------------------------CCT Bollinger Band Oscilator',
chng       = 'change(src,len).-------------------------A.K.A. Momentum. Difference between current value and previous, source - source[length]. is most commonly referred to as a rate and measures the acceleration of the price and/or volume of a security',
cmf        = 'cmf(len=20).-----------------------------Chaikin Money Flow Indicator used to measure Money Flow Volume over a set period of time. Default use is len=20',
cmo        = 'cmo(src,len).----------------------------Chande Momentum Oscillator. Calculates the difference between the sum of recent gains and the sum of recent losses and then divides the result by the sum of all price movement over the same period.',
cog        = 'cog(src,len).----------------------------The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.',
cpcrv      = 'copcurve(src,len).-----------------------Coppock Curve.  was originally developed by Edwin Sedge Coppock (Barrons Magazine, October 1962).',
corrl      = 'correl(src,len).-------------------------Correlation coefficient. Describes the degree to which two series tend to deviate from their ta.sma values.',
count      = 'count(src,len).--------------------------green avg - red avg',
cti        = 'cti(src,len).----------------------------Ehler s Correlation Trend Indicator by ',
dev        = 'dev(src,len).----------------------------ta.dev()  Measure of difference between the series and its ta.sma',
dpo        = 'dpo(len).--------------------------------Detrended Price OScilator is used to remove trend from price.   ',
efi        = 'efi(len).--------------------------------Elders Force Index (EFI) measures the power behind a price movement using price and volume.',
eom        = 'eom(len=14,div=10000).-------------------Ease of Movement.It is designed to measure the relationship between price and volume.p1 = div: 10000= (default)',
fall       = 'falling(src,len).------------------------ta.falling() Test if the `source` series is now falling for `length` bars long. (Use its Input as another indicator output)',
fit        = 'fisher(len).-----------------------------Fisher Transform is a technical indicator that converts price to Gaussian normal distribution and signals when prices move significantly by referencing recent price data',
hvo        = 'histvol(len).----------------------------Historical volatility is a statistical measure used to analyze the general dispersion of security or market index returns for a specified period of time.',
kcr        = 'kcr(src,len,mult=2).---------------------Keltner Channels Range  ',
kcw        = 'kcw(src,len,mult=2).---------------------ta.kcw(). Keltner Channels Width. The Keltner Channels Width is the difference between the upper and the lower Keltner Channels divided by the middle channel.',
kli        = 'klinger(type=len).-----------------------Klinger oscillator aims to identify money flow’s long-term trend. type=len: 0:Oscilator 1:signal',
macd       = 'macd(src,len).---------------------------MACD (Moving Average Convergence/Divergence)',
mfi        = 'mfi(src,len).----------------------------Money Flow Index s a tool used for measuring buying and selling pressure',
msi        = 'msi(len=10).-----------------------------Mass Index (def=10) is used to examine the differences between high and low stock prices over a specific period of time',
nvi        = 'nvi().-----------------------------------Negative Volume Index',
obv        = 'obv().-----------------------------------On Balance Volume',
pvi        = 'pvi().-----------------------------------Positive Volume Index ',
pvt        = 'pvt().-----------------------------------Price Volume Trend',
rangs      = 'ranges(src,upper=len, lower=-5).---------ranges of the source. src=src, upper=len, v1:lower=upper .  returns: -1 source<lower,  1 source>=upper otherwise 0',
rise       = 'rising(src,len).-------------------------ta.rising() Test if the `source` series is now rising for `length` bars long. (Use its Input as another indicator output)',
roc        = 'roc(src,len).----------------------------Rate of Change',
rsi        = 'rsi(src,len).----------------------------Relative strength Index',
rvi        = 'rvi(src,len).----------------------------The Relative Volatility Index (RVI) is calculated much like the RSI, although it uses high and low price standard deviation instead of the RSI’s method of absolute change in price.',
smosc      = 'smi_osc(src,len,fast=5, slow=34).--------smi Oscillator',
smsig      = 'smi_sig(src,len,fast=5, slow=34).--------smi Signal',
stc        = 'stc(src,len,fast=23,slow=50).------------Schaff Trend Cycle (STC) detects up and down trends long before the MACD. Code imported from ',
stdev      = 'stdev(src,len).--------------------------Standart deviation',
trix       = 'trix(src,len) .--------------------------the rate of change of a triple exponentially smoothed moving average.',
tsi        = 'tsi(src,len).----------------------------The True Strength Index indicator is a momentum oscillator designed to detect, confirm or visualize the strength of a trend.',
ulos       = 'ultimateOsc(len.-------------------------Ultimate Oscillator indicator (UO) indicator is a technical analysis tool used to measure momentum across three varying timeframes',
vari       = 'variance(src,len).-----------------------ta.variance(). Variance is the expectation of the squared deviation of a series from its mean (ta.sma), and it informally measures how far a set of numbers are spread out from their mean.',
wilpc      = 'willprc(src,len).------------------------Williams %R',
wad        = 'wad().-----------------------------------Williams Accumulation/Distribution.',
wvad       = 'wvad().----------------------------------Williams Variable Accumulation/Distribution.',





//_______________INDICATOR PLOTTING TYPE CONSTANTS
//Currently there are 4 plotting type exist in the system
p01='Original' , p02='Stochastic' , p03='PercentRank' //, p04='Org. Range (-1,1)'

//_______________CONDITION INDICATOR SOURCE CONSTANTS
s00= "NONE", s01="IND1", s02="IND2", s03="IND3", s04="IND4", s05="IND5", s06="VALUE", s07="close", s08="open", s09="high", s10="low", s11="hl2", s12="hlc3", s13="ohlc4", s14="volume", s15="EXT",s16="CUST"

//_______________CONDITION OPERATOR CONSTANTS
op01="crossover", op02="crossunder", op03="cross", op04=">", op05="<", op06=">=", op07="<=", op08="=", op09="!="

//_______________PARAMETER VERSION CONSTANTS
v01="Use Defaults", v02="Use Extra Parameters P1, P2"

//_______________FACTOR VERSION CONSTANTS
f01="None", f02 = "Double", f03 = "Triple", f04 = "Quadruple"


//_______________TOOLTIPS CONSTANTS{
s_tt_settings=      "GENERAL SETTINGS:\n" +
                     "Select the Source, timeframe and Secure type that your indicators will use.\n" +
                     "TIMEFRAME: indicators timeframe \n" +
                     "SECURE: option is defined as reducing repaint in tradingview calculations as much as possible. The following function is used.\n" +
                     "Here, the Secure entry consists of 3 parts and the f_security function is used to determine it.\n" +
                     "a) SECURE: This option is defined as reducing repaint in tradingview calculations as much as possible\n" +
                     "b) SEMI SECURE : While this option can reduce repaint in tradingview calculations as much as possible, it is less secure. \n" +
                     "c) REPAINT: This option turns on the repaint feature."

s_tt_data_ext=      "EXT SOURCE: You can import external Indicator sources from here . It appears on condition/combination/Indicator area as EXT.\n" +
                     "To import it  as EXT, you should add your indicator to the chart and export your indicator value as PLOT  with any defined title.\n" + 
                     "Then It will be visible in Ext data source dropdown input "
                     
s_tt_testPeriod=    "TEST PERIOD: Determine your strategy testing period range by selecting start and end date/time"

s_tt_settings1=     "PLOT ALERTS: Plot condition result as alerts arrows on the chart's bottom for LONG and the top for SHORT entries, exits\n" + 
                     "CLOSE ON OPPOSITE: When selected, a long entry gets closed when a short entry opens and vice versa"

s_tt_PlotType=      "PLOTTING TYPE:\n"+
                     "This will be used to display non overlay indicators in the chart by using stochastic, percentrank selection in indicator setting  \n"+
                     "1) MULT:Sets the multiplier for the selected Plot Type EXAMPLE: When 1000 is selected, the indicator in the range of (-1,1) will appear in the range of (-1000, 1000) on the screen other than Original\n"+
                     "2) SHIFT:It determines the shift that will appear on the screen for the selected Plot Type ( stochastic , Percentrank) in the range (-1,1) other than Original.\n"+
                     "3) SMOOTH:This option (only for Stochastic & PercentRank) allows to smooth the indicator to be displayed.\n"+
                     "4) HLINE:Diplay the horizontal lines to appear on the screen according to the mult factor for the range (-1,1). The lines represent the values (-1, -05, 0, 05 , 1)"

s_tt_ind1=          "INDICATOR INPUTS:\n"+ 
                     "1) LIBRARY INDICATOR (INDx):\n" +  
                     " a) MOVING AVERAGES :  These are indicators such as EMA , SMA that you can overlay on the chart via plotting type='original'. \n " +
                     " b) OTHER INDICATORS : These are other indicators that you can overlay on the chart due to their small value such as RSI , COG. (you can use plotting type stoch, %.. to overlay on the chart) \n" +
                     "2) INDICATOR SOURCE: \n" +
                     " indicator source such as close, open.. and you can also use custom (CUST), External (EXT) and Previous (IND1-IND4) Indicators as data source for current indicator calculation\n" +
                     "3) INDICATOR LENGTH (Len): \n" +
                     " indicator length value . (Not: it does not work for custom indicators since they have their parameter on cust. Ind. input screen ) \n"

s_tt_ind2=          "PARAMETERS \n" +
                     "1) (Par): Used for indicator Extra parameters availability.\n"+ 
                     "  a) (Use Defaults) use only indicator(Source,Length) with default parameters.\n" +
                     "  b) (Use Extra Parameters P1, P2) use  indicator(Source,Length,p1,p2) with additional parameters (p1,p2) if indicator needs\n" +
                     "2) (P1), (P2) : If V=2 (ADVANCED) is selected and if the requested indicator needs extra parameter P1, P2 then fill this area\n" 
                     
s_tt_ind3=          "1) FACTORIZER VALUE (Factor):\n" +
                     "  Double, Triple, Quadruple factorizer value (like convert EMA to DEMA, TEMA, QEMA...) 1= returns indicator Original value \n" +
                     "2) LOG VALUE (Log):\n" +
                     "  log calculation option added on indicator function entries such as simple and log10\n" 
                     
s_tt_ind4=          "1) INDICATOR PLOTTING TYPE (PType): This is an input selection field about how indicaor will be displayed on the screen. \n" +
                     "  a) ORIGINAL: The indicator is displayed on the screen with its current values. Can be used to display moving average indicators such as ( EMA , SMA ) \n" +
                     "  b) STOCHASTIC: The indicator is displayed on the screen with stochastic calculation in the range of -1.1.It uses the stochastic (ST/%) calculation method to spread indicators such as ( RSI , COB) in the range (-1,1).  You can see the original values of the relevant indicator on the TV Data Window screen.\n" +
                     "  c) PERCENTRANK: The indicator is displayed on the screen with Percentrank calculation in the range of -1.1.It uses the Percentrank (ST/%) calculation method to spread indicators such as ( RSI , COB) in the range (-1,1).  You can see the original values of the relevant indicator on the TV Data Window screen.\n" +
                     "  d) ORG RANGE (-1,1): If your indicator is in the range of -1.1, your indicator will be displayed on the screen with its original calculation in the range of -1.1.\n" +
                     "2) STOCHASTIC/PERCENTAGE VALUE (ST/%):\n" +
                     "  Stoch, Perc% plot type value. for realistic not filtered results you can enter a bigger value (ex:4999 max bars according to your subscription)  (Note: this value does not impact plot type ORIGINAL and ORG RANGE )\n" +
                     "3) INDICATOR COLOR:\n" +
                     "   Define indicator color and other drawing properties on the chart "
                     
s_tt_combination=   "COMBINATION:\n"+
                     "Each combination are build from 4 parts\n"+
                     "1)1ST INDICATOR: If is set to NONE this combination and following combinations in the condition will not be used on calculations.You can select \n"+
                     "  IND1-5: from indicators (See above),\n"+ 
                     "  VALUE: a float value defined in the combinations value parameter\n  "+ 
                     "  EXT: value from externally imported indicator.\n"+ 
                     "  Stock builtin values: close,open...\n"+
                     "2)OPERATOR : Selected Operator compares 1st Indicator with the 2nd one. You can select different operators such as crossover, crossunder, cross,>,<,=....\n"+
                     "  Standart operators USAGE 1: [ 1)1st Indicator  2)cross 3)2nd Indicator 4)2nd indicator[VALUE] ] \n"+
                     "  Standart operators USAGE 2: [ 1)1st Indicator  2)cross 3)VALUE 4)Value ]  \n"+
                     "3)2ND INDICATOR : This indicator will be compared with the 1st one via selected Operator. You can select\n" + 
                     "  IND1-5: from indicators (See above),\n"+ 
                     "  VALUE: a float value defined in the combinations value parameter\n  "+ 
                     "  EXT: value from externally imported indicator.\n"+ 
                     "  Stock builtin values: close,open...\n"+
                     "4)VALUE: When the 2nd indicator field selected as \n"+
                      " a)VALUE, value area compares the entered flaot value with indicator 1\n"+ 
                      " b)Other than VALUE, Value area define 2nd indicator's previous value ex: If 2ND INDICATOR='close' and VALUE =2 this mean 2ND INDICATOR=close[2]"

s_tt_comb_op=       "COMBINATION OPERATOR:\n" +
                     "Each combination in Condition is compared with the next one via JOIN operator. The join operator can be selected as AND or OR."

s_tt_custind=       "CUSTOM INDICATOR:\n" +
                     "There is an area in the code for design/import your Custom Indicator.\n" +
                     "Here you can design/import your own indicator and use them in the framework.\n" +
                     "You can also create unlimited parameters for your indicator in the custom indicator area.\n" +
                     "CRONEX custom indicator is entered in the code area for demonstration. (See Source Code for Implementation) "
                     
s_tt_signals=       "SIGNAL EXPORT:\n"+
                     "1) Select already defined strategy framework/template for exporting your signals that produced by your Indicators combinations \n"+
                     "In strategy framework/template there will be a import signal input and here select the source which include 'connect' word\n"+
                     "2) When 'Custom' is selected, you can define your signal such as long, short, longexit, shortexit for unlisted strategy framework or templates "

s_tt_Profit=        "STRATEGY PART:\n"+
                     "You can use this script as a simple raw strategy by remarking strategy part at the end and the switching the strategy to study at the start of the script source code\n"+
                     "Note: When you use it as a strategy you can not export signals to another strategy\n"+
                     "1)SHOW PROFIT:It appears if the script is in strategy mode (not in study) this can display current or open profit for better reanalyzing your strategy entry exit points. (Currently under development)"

//_______________END TOOLTIPS CONSTANTS}

//************END CONSTANTS}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ VARIABLES{
float f_indicator1=0
float f_indicator2=0
float f_indicator3=0
float f_indicator4=0
float f_indicator5=0
float f_custom_ind=0
//******** END VARIABLES}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ INPUTS{    

//*************** GENERAL SETTINGS INPUTS{
//_______________F_SECURITY***NOREPAINT
Timeframe =       input.timeframe(defval='',    title='Timeframe',                                          group=s_grp_settings, inline="settings",   tooltip=s_tt_settings)
secure =          input.string(   defval='Secure',options=['Secure', 'Semi Secure', 'Repaint'], title='',   group=s_grp_settings, inline="settings")
data_ext =        input.source(   defval=close, title='Ext Source',                                         group=s_grp_settings, inline="data_ext",   tooltip=s_tt_data_ext) //The ext source Accept extrenal Indicator sources also. To export the External indicator plot it with a title. It will be visible in source dropdown input

//_______________SETTINGS 
t_testPeriodStart=   input.time(     defval=timestamp('01 Apr 2021 00:00'),title='Start Time:',             group=s_grp_settings, inline='test period', tooltip=s_tt_testPeriod)
t_testPeriodStop =   input.time(     defval=timestamp('30 Dec 2022 23:30'),title='End Time  :',             group=s_grp_settings, inline='test period')
b_plotalert =        input.bool(     defval=true,        title='Plot Alerts',                               group=s_grp_settings, inline="settings1",   tooltip=s_tt_settings1)
b_isopposite =       input.bool(      defval=true,       title="Close on opposite",                         group=s_grp_settings, inline="settings1")

//_______________PLOT TYPE INPUTS 
i_ind_mult=          input.int(      defval=2000,        title="mult",                                      group= s_grp_plottype,inline="plot type",   step=100, tooltip=s_tt_PlotType)
i_ind_shift=         input.int(      defval=35000,       title="shift",                                     group= s_grp_plottype,inline="plot type",   step=1000)
b_ind_hline=         input.bool(     defval=true,        title="hline",                                     group= s_grp_plottype,inline="plot type")
//************ END GENERAL SETTINGS INPUTS}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//*************** INDICATOR INPUTS{ 
//_______________INDICATOR 1    
s_ind1_src=        input.string(   defval=ema,             title='IND1:',       options=[hide, org, ovrly, 
                                                                                     alma, ama  , acdst, cma,  dema, ema, gmma, hghst, hl2ma, hma, lgAdt, lgAdV, lguer, lsrcp, lexp, linrg, lowst, 
                                                                                     mgi,pcnl, pcnli, prev , pvth, pvtl, rema, rma, sar, sma, smma, supr2, supr3, strnd, swma, tema, tma, vida, vwma, vstop, wma, vwap, 
                                                                                     nvrly, 
                                                                                     adx, angle, aroon, atr, awsom, bbr, bbw, cci, cctbb, chng, cmf, cmo, cog, cpcrv, corrl, count, cti, dev, dpo, efi, eom, 
                                                                                     fall, fit, hvo, kcr, kcw, kli, macd, mfi, msi, nvi, obv, pvi, pvt, rangs, rise, roc, rsi, rvi, smosc, smsig, stc, stdev, trix, 
                                                                                     tsi, vari, wilpc, wad, wvad] 
                                                                          ,   group=s_grp_indicator1, inline="ind1", tooltip=s_tt_ind1)
s_ind1_data =      input.string(   defval="close",        title='',           group=s_grp_indicator1, inline="ind1", options=[s07, s08, s09, s10, s11, s12, s13, s14, s15, s16] ) 
f_ind1_len   =     input.float(    defval=7,              title='Len',        group=s_grp_indicator1, inline="ind1")
s_ind1_ver =       input.string(   defval=v01,            title="Par",        group=s_grp_indicator1, inline="ind2", options=[v01,v02], tooltip=s_tt_ind2)
f_ind1_p1   =      input.float(    defval=0,              title='P1',         group=s_grp_indicator1, inline="ind2")
f_ind1_p2   =      input.float(    defval=0,              title='P2',         group=s_grp_indicator1, inline="ind2")
s_ind1_fact =      input.string(   defval=f01,            title='factor',     group=s_grp_indicator1, inline="ind4", options=[f01,f02,f03,f04],  tooltip=s_tt_ind3)
s_ind1_log =       input.string(   defval="None",         title='Log',        group=s_grp_indicator1, inline="ind4", options=['None', 'Simple', 'Log10'])
s_ind1_pType =     input.string(   defval=p01,            title="PType",      group=s_grp_indicator1, inline="ind3", options=[p01,p02,p03], tooltip=s_tt_ind4)
i_ind1_stlen =     input.int(      defval=50,             title='St/% val',   group=s_grp_indicator1, inline="ind3")
b_ind1_pSWMA=      input.bool(     defval=false,          title="Smooth",     group=s_grp_indicator1, inline="ind3")
c_ind1_color =     input(          defval=color.green,    title="",           group=s_grp_indicator1, inline="ind3")
b_plt1_candle =    false
b_plt1_ind =       true
b_plt1_heikin =    false
//f_ind1_p3   =    input.float(    defval=0,              title='P3',         group=s_grp_indicator1, inline="ind2")  //to be activated in the future
 
    
//_______________INDICATOR 2    
s_ind2_src=        input.string(   defval=ema,             title='IND2:',        options=[hide, org, ovrly, 
                                                                                     alma, ama  , acdst, cma,  dema, ema, gmma, hghst, hl2ma, hma, lgAdt, lgAdV, lguer, lsrcp, lexp, linrg, lowst, 
                                                                                     mgi,pcnl, pcnli, prev , pvth, pvtl, rema, rma, sar, sma, smma, supr2, supr3, strnd, swma, tema, tma, vida, vwma, vstop, wma, vwap, 
                                                                                     nvrly, 
                                                                                     adx, angle, aroon, atr, awsom, bbr, bbw, cci, cctbb, chng, cmf, cmo, cog, cpcrv, corrl, count, cti, dev, dpo, efi, eom, 
                                                                                     fall, fit, hvo, kcr, kcw, kli, macd, mfi, msi, nvi, obv, pvi, pvt, rangs, rise, roc, rsi, rvi, smosc, smsig, stc, stdev, trix, 
                                                                                     tsi, vari, wilpc, wad, wvad] 
                                                                         ,     group=s_grp_indicator2, inline="ind1", tooltip=s_tt_ind1)
s_ind2_data =      input.string(   defval="close",         title='',           group=s_grp_indicator2, inline="ind1", options=[s07, s08, s09, s10, s11, s12, s13, s14, s15, s16, s01]) 
f_ind2_len   =     input.float(    defval=14,              title='Len',        group=s_grp_indicator2, inline="ind1")
s_ind2_ver =       input.string(   defval=v01,             title="Par",        group=s_grp_indicator2, inline="ind2", options=[v01,v02], tooltip=s_tt_ind2)
f_ind2_p1   =      input.float(    defval=0,               title='P1',         group=s_grp_indicator2, inline="ind2")
f_ind2_p2   =      input.float(    defval=0,               title='P2',         group=s_grp_indicator2, inline="ind2")
s_ind2_fact =      input.string(   defval=f01,             title='factor',     group=s_grp_indicator2, inline="ind4", options=[f01,f02,f03,f04],  tooltip=s_tt_ind3)
s_ind2_log =       input.string(   defval="None",          title='Log',        group=s_grp_indicator2, inline="ind4", options=['None', 'Simple', 'Log10'])
s_ind2_pType =     input.string(   defval=p01,             title="PType",      group=s_grp_indicator2, inline="ind3", options=[p01,p02,p03], tooltip=s_tt_ind4)
i_ind2_stlen =     input.int(      defval=50,              title='St/% val',   group=s_grp_indicator2, inline="ind3")
b_ind2_pSWMA=      input.bool(     defval=false,           title="Smooth",     group=s_grp_indicator2, inline="ind3")
c_ind2_color =     input(          defval=color.red,       title="",           group=s_grp_indicator2, inline="ind3")
b_plt2_candle =    false
b_plt2_ind =       true
b_plt2_heikin =    false
//ind2_p3   =     input.float(    defval=0,               title='P3',        group=s_grp_indicator2, inline="ind2")  //to be activated in the future
        
//_______________INDICATOR 3    
s_ind3_src=        input.string(   defval=ema,             title='IND3:',        options=[hide, org, ovrly, 
                                                                                     alma, ama  , acdst, cma,  dema, ema, gmma, hghst, hl2ma, hma, lgAdt, lgAdV, lguer, lsrcp, lexp, linrg, lowst, 
                                                                                     mgi,pcnl, pcnli, prev , pvth, pvtl, rema, rma, sar, sma, smma, supr2, supr3, strnd, swma, tema, tma, vida, vwma, vstop, wma, vwap, 
                                                                                     nvrly, 
                                                                                     adx, angle, aroon, atr, awsom, bbr, bbw, cci, cctbb, chng, cmf, cmo, cog, cpcrv, corrl, count, cti, dev, dpo, efi, eom, 
                                                                                     fall, fit, hvo, kcr, kcw, kli, macd, mfi, msi, nvi, obv, pvi, pvt, rangs, rise, roc, rsi, rvi, smosc, smsig, stc, stdev, trix, 
                                                                                     tsi, vari, wilpc, wad, wvad] 
                                                                         ,     group=s_grp_indicator3, inline="ind1", tooltip=s_tt_ind1)
s_ind3_data =      input.string(   defval="close",         title='',           group=s_grp_indicator3, inline="ind1", options=[s07, s08, s09, s10, s11, s12, s13, s14, s15, s16, s01,s02]) 
f_ind3_len   =     input.float(    defval=21,              title='Len',        group=s_grp_indicator3, inline="ind1")
s_ind3_ver =       input.string(   defval=v01,             title="Par",        group=s_grp_indicator3, inline="ind2", options=[v01,v02], tooltip=s_tt_ind2)
f_ind3_p1   =      input.float(    defval=0,               title='P1',         group=s_grp_indicator3, inline="ind2")
f_ind3_p2   =      input.float(    defval=0,               title='P2',         group=s_grp_indicator3, inline="ind2")
s_ind3_fact =      input.string(   defval=f01,             title='factor',     group=s_grp_indicator3, inline="ind4", options=[f01,f02,f03,f04],  tooltip=s_tt_ind3)
s_ind3_log =       input.string(   defval="None",          title='Log',        group=s_grp_indicator3, inline="ind4", options=['None', 'Simple', 'Log10'])
s_ind3_pType =     input.string(   defval=p01,             title="PType",      group=s_grp_indicator3, inline="ind3", options=[p01,p02,p03], tooltip=s_tt_ind4)
i_ind3_stlen =     input.int(      defval=50,              title='St/% val',   group=s_grp_indicator3, inline="ind3")
b_ind3_pSWMA=      input.bool(     defval=false,           title="Smooth",     group=s_grp_indicator3, inline="ind3")
c_ind3_color =     input(          defval=color.blue,      title="",           group=s_grp_indicator3, inline="ind3")
b_plt3_candle =    false,
b_plt3_ind =       true
b_plt3_heikin =    false
//ind3_p3   =     input.float(    defval=0,               title='P3',        group=s_grp_indicator3, inline="ind2")  //to be activated in the future
        
    
//_______________INDICATOR 4    
s_ind4_src=        input.string(   defval=ema,             title='IND4:',        options=[hide, org, ovrly, 
                                                                                     alma, ama  , acdst, cma,  dema, ema, gmma, hghst, hl2ma, hma, lgAdt, lgAdV, lguer, lsrcp, lexp, linrg, lowst, 
                                                                                     mgi,pcnl, pcnli, prev , pvth, pvtl, rema, rma, sar, sma, smma, supr2, supr3, strnd, swma, tema, tma, vida, vwma, vstop, wma, vwap, 
                                                                                     nvrly, 
                                                                                     adx, angle, aroon, atr, awsom, bbr, bbw, cci, cctbb, chng, cmf, cmo, cog, cpcrv, corrl, count, cti, dev, dpo, efi, eom, 
                                                                                     fall, fit, hvo, kcr, kcw, kli, macd, mfi, msi, nvi, obv, pvi, pvt, rangs, rise, roc, rsi, rvi, smosc, smsig, stc, stdev, trix, 
                                                                                     tsi, vari, wilpc, wad, wvad] 
                                                                         ,     group=s_grp_indicator4, inline="ind1", tooltip=s_tt_ind1)
s_ind4_data =      input.string(   defval="close",         title='',           group=s_grp_indicator4, inline="ind1", options=[s07, s08, s09, s10, s11, s12, s13, s14, s15, s16, s01,s02,s03]) 
f_ind4_len   =     input.float(    defval=50,              title='Len',        group=s_grp_indicator4, inline="ind1")
s_ind4_ver =       input.string(   defval=v01,             title="Par",        group=s_grp_indicator4, inline="ind2", options=[v01,v02], tooltip=s_tt_ind2)
f_ind4_p1   =      input.float(    defval=0,               title='P1',         group=s_grp_indicator4, inline="ind2")
f_ind4_p2   =      input.float(    defval=0,               title='P2',         group=s_grp_indicator4, inline="ind2")
s_ind4_fact =      input.string(   defval=f01,             title='factor',     group=s_grp_indicator4, inline="ind4", options=[f01,f02,f03,f04],  tooltip=s_tt_ind3)
s_ind4_log =       input.string(   defval="None",          title='Log',        group=s_grp_indicator4, inline="ind4", options=['None', 'Simple', 'Log10'])
s_ind4_pType =     input.string(   defval=p01,             title="PType",      group=s_grp_indicator4, inline="ind3", options=[p01,p02,p03], tooltip=s_tt_ind4)
i_ind4_stlen =     input.int(      defval=50,              title='St/% val',   group=s_grp_indicator4, inline="ind3")
b_ind4_pSWMA=      input.bool(     defval=false,           title="Smooth",     group=s_grp_indicator4, inline="ind3")
c_ind4_color =     input(          defval=color.purple,    title="",           group=s_grp_indicator4, inline="ind3")
b_plt4_candle =    false
b_plt4_ind =       true
b_plt4_heikin =    false
//ind4_p3   =     input.float(    defval=0,               title='P3',        group=s_grp_indicator4, inline="ind2")  //to be activated in the future

//_______________INDICATOR 5    
s_ind5_src=        input.string(   defval=ema,           title='IND5:',        options=[hide, org, ovrly, 
                                                                                     alma, ama  , acdst, cma,  dema, ema, gmma, hghst, hl2ma, hma, lgAdt, lgAdV, lguer, lsrcp, lexp, linrg, lowst, 
                                                                                     mgi,pcnl, pcnli, prev , pvth, pvtl, rema, rma, sar, sma, smma, supr2, supr3, strnd, swma, tema, tma, vida, vwma, vstop, wma, vwap, 
                                                                                     nvrly, 
                                                                                     adx, angle, aroon, atr, awsom, bbr, bbw, cci, cctbb, chng, cmf, cmo, cog, cpcrv, corrl, count, cti, dev, dpo, efi, eom, 
                                                                                     fall, fit, hvo, kcr, kcw, kli, macd, mfi, msi, nvi, obv, pvi, pvt, rangs, rise, roc, rsi, rvi, smosc, smsig, stc, stdev, trix, 
                                                                                     tsi, vari, wilpc, wad, wvad] 
                                                                         ,     group=s_grp_indicator5, inline="ind1", tooltip=s_tt_ind1)
s_ind5_data =      input.string(   defval="close",         title='',           group=s_grp_indicator5, inline="ind1", options=[s07, s08, s09, s10, s11, s12, s13, s14, s15, s16, s01,s02,s03,s04]) 
f_ind5_len   =     input.float(    defval=100,             title='Len',        group=s_grp_indicator5, inline="ind1")
s_ind5_ver =       input.string(   defval=v01,             title="Par",        group=s_grp_indicator5, inline="ind2", options=[v01,v02], tooltip=s_tt_ind2)
f_ind5_p1   =      input.float(    defval=0,               title='P1',         group=s_grp_indicator5, inline="ind2")
f_ind5_p2   =      input.float(    defval=0,               title='P2',         group=s_grp_indicator5, inline="ind2")
s_ind5_fact =      input.string(   defval=f01,             title='factor',     group=s_grp_indicator5, inline="ind4", options=[f01,f02,f03,f04],  tooltip=s_tt_ind3)
s_ind5_log =       input.string(   defval="None",          title='Log',        group=s_grp_indicator5, inline="ind4", options=['None', 'Simple', 'Log10'])
s_ind5_pType =     input.string(   defval=p01,             title="PType",      group=s_grp_indicator5, inline="ind3", options=[p01,p02,p03], tooltip=s_tt_ind4)
i_ind5_stlen =     input.int(      defval=50,              title='St/% val',   group=s_grp_indicator5, inline="ind3")
b_ind5_pSWMA=      input.bool(     defval=false,           title="Smooth",     group=s_grp_indicator5, inline="ind3")
c_ind5_color =     input(          defval=color.orange,    title="",           group=s_grp_indicator5, inline="ind3")
b_plt5_candle =    false
b_plt5_ind =       true
b_plt5_heikin =    false
//ind5_p3   =     input.float(    defval=0,               title='P3',        group=s_grp_indicator5, inline="ind2")  //to be activated in the future

//************END INDICATOR INPUTS}  

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//*************** CONDITION INPUTS{  

//************ LONG ENTRY CONDITIONS INPUTS 
//_______________LONG ENTRY 1 CONDITION 
s_Cond_LE_1_ind1=    input.string(defval="IND1",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond1")
s_Cond_LE_1_op=      input.string(defval="crossover",    title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LEC,inline="LE_cond1")
s_Cond_LE_1_ind2=    input.string(defval="IND2",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond1")
f_Cond_LE_1_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LEC,inline="LE_cond1")
  
//_______________LONG ENTRY 1-2 JOIN   
s_Cond_LE_1_join_2=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_LEC, tooltip=s_tt_comb_op)
      
//_______________LONG ENTRY 2 CONDITION       
s_Cond_LE_2_ind1=    input.string(defval="IND2",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond2")
s_Cond_LE_2_op=      input.string(defval="<",            title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LEC,inline="LE_cond2")
s_Cond_LE_2_ind2=    input.string(defval="VALUE",        title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond2")
f_Cond_LE_2_ind2_val=input.float( defval=-0.9,           title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LEC,inline="LE_cond2")
    
//_______________LONG ENTRY 2-3 JOIN    
s_Cond_LE_2_join_3=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_LEC, tooltip=s_tt_comb_op)

//_______________LONG ENTRY 3 CONDITION     
s_Cond_LE_3_ind1=    input.string(defval="IND1",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond3")
s_Cond_LE_3_op=      input.string(defval="<",            title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LEC,inline="LE_cond3")
s_Cond_LE_3_ind2=    input.string(defval="low",          title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond3")
f_Cond_LE_3_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LEC,inline="LE_cond3")
        
//_______________LONG ENTRY 3-4 JOIN    
s_Cond_LE_3_join_4=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_LEC, tooltip=s_tt_comb_op)

//_______________LONG ENTRY 4 CONDITION     
s_Cond_LE_4_ind1=    input.string(defval="NONE",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond4")
s_Cond_LE_4_op=      input.string(defval="<",            title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LEC,inline="LE_cond4")
s_Cond_LE_4_ind2=    input.string(defval="low",          title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LEC,inline="LE_cond4")
f_Cond_LE_4_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LEC,inline="LE_cond4")

//************SHORT ENTRY CONDITIONS INPUTS       
//_______________SHORT ENTRY 1 CONDITION        
s_Cond_SE_1_ind1=    input.string(defval="IND2",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond1")
s_Cond_SE_1_op=      input.string(defval="crossunder",   title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_SEC,inline="SE_cond1")
s_Cond_SE_1_ind2=    input.string(defval="IND3",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond1")
f_Cond_SE_1_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SEC,inline="SE_cond1")
         
//_______________SHORT ENTRY 1-2 JOIN        
s_Cond_SE_1_join_2=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_SEC, tooltip=s_tt_comb_op)
         
//_______________SHORT ENTRY 2 CONDITION     
s_Cond_SE_2_ind1=    input.string(defval="IND2",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond2")
s_Cond_SE_2_op=      input.string(defval=">",            title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_SEC,inline="SE_cond2")
s_Cond_SE_2_ind2=    input.string(defval="VALUE",        title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond2")
f_Cond_SE_2_ind2_val=input.float( defval=0.9,            title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SEC,inline="SE_cond2")
         
//_______________SHORT ENTRY 2-3 JOIN        
s_Cond_SE_2_join_3=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_SEC, tooltip=s_tt_comb_op)
         
//_______________SHORT ENTRY 3 CONDITION         
s_Cond_SE_3_ind1=    input.string(defval="IND1",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond3")
s_Cond_SE_3_op=      input.string(defval=">",            title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_SEC,inline="SE_cond3")
s_Cond_SE_3_ind2=    input.string(defval="high",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond3")
f_Cond_SE_3_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SEC,inline="SE_cond3")
         
//_______________SHORT ENTRY 3-4 JOIN        
s_Cond_SE_3_join_4=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_SEC, tooltip=s_tt_comb_op)
         
//_______________SHORT ENTRY 4 CONDITION         
s_Cond_SE_4_ind1=    input.string(defval="NONE",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond4")
s_Cond_SE_4_op=      input.string(defval=">",            title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_SEC,inline="SE_cond4")
s_Cond_SE_4_ind2=    input.string(defval="high",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_SEC,inline="SE_cond4")
f_Cond_SE_4_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SEC,inline="SE_cond4")

//************LONG CLOSE CONDITIONS INPUTS         
//_______________LONG CLOSE 1 CONDITION          
s_Cond_LC_1_ind1=    input.string(defval="NONE",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond1")
s_Cond_LC_1_op=      input.string(defval="crossover",    title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LCC,inline="LC_cond1")
s_Cond_LC_1_ind2=    input.string(defval="IND1",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond1")
f_Cond_LC_1_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LCC,inline="LC_cond1")
         
//_______________LONG CLOSE 1-2 JOIN         
s_Cond_LC_1_join_2=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_LCC, tooltip=s_tt_comb_op)
         
//_______________LONG CLOSE 2 CONDITION          
s_Cond_LC_2_ind1=    input.string(defval="NONE",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond2")
s_Cond_LC_2_op=      input.string(defval="crossover",    title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LCC,inline="LC_cond2")
s_Cond_LC_2_ind2=    input.string(defval="IND2",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond2")
f_Cond_LC_2_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LCC,inline="LC_cond2")
         
//_______________LONG CLOSE 2-3 JOIN         
s_Cond_LC_2_join_3=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_LCC, tooltip=s_tt_comb_op)
         
//_______________LONG CLOSE 3 CONDITION          
s_Cond_LC_3_ind1=    input.string(defval="NONE",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond3")
s_Cond_LC_3_op=      input.string(defval="crossover",    title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LCC,inline="LC_cond3")
s_Cond_LC_3_ind2=    input.string(defval="IND3",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond3")
f_Cond_LC_3_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LCC,inline="LC_cond3")
         
//_______________LONG CLOSE 3-4 JOIN         
s_Cond_LC_3_join_4=  input.string(defval="AND",          title="",   options=["AND","OR"] ,    group= s_grp_LCC, tooltip=s_tt_comb_op)
         
//_______________LONG CLOSE 4 CONDITION          
s_Cond_LC_4_ind1=    input.string(defval="NONE",         title="",   options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond4")
s_Cond_LC_4_op=      input.string(defval="crossover",    title="",   options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                    group= s_grp_LCC,inline="LC_cond4")
s_Cond_LC_4_ind2=    input.string(defval="IND3",         title="",   options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],          group= s_grp_LCC,inline="LC_cond4")
f_Cond_LC_4_ind2_val=input.float( defval=0,              title="",   step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_LCC,inline="LC_cond4")



//************ SHORT CLOSE CONDITIONS INPUTS        
//_______________SHORT CLOSE 1 CONDITION         
s_Cond_SC_1_ind1=    input.string(defval="NONE",         title="",  options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond1")
s_Cond_SC_1_op=      input.string(defval="crossover",    title="",  options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                     group= s_grp_SCC,inline="SC_cond1")
s_Cond_SC_1_ind2=    input.string(defval="IND1",         title="",  options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond1")
f_Cond_SC_1_ind2_val=input.float( defval=0,              title="",  step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SCC,inline="SC_cond1")
        
//_______________SHORT CLOSE 1-2 JOIN       
s_Cond_SC_1_join_2=  input.string(defval="AND",          title="",  options=["AND","OR"] ,    group= s_grp_SCC, tooltip=s_tt_comb_op)
        
//_______________SHORT CLOSE 2 CONDITION        
s_Cond_SC_2_ind1=    input.string(defval="NONE",         title="",  options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond2")
s_Cond_SC_2_op=      input.string(defval="crossover",    title="",  options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                     group= s_grp_SCC,inline="SC_cond2")
s_Cond_SC_2_ind2=    input.string(defval="IND2",         title="",  options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond2")
f_Cond_SC_2_ind2_val=input.float( defval=0,              title="",  step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SCC,inline="SC_cond2")
        
//_______________SHORT CLOSE 2-3 JOIN       
s_Cond_SC_2_join_3=  input.string(defval="AND",          title="",  options=["AND","OR"] ,    group= s_grp_SCC, tooltip=s_tt_comb_op)
        
//_______________SHORT CLOSE 3 CONDITION        
s_Cond_SC_3_ind1=    input.string(defval="NONE",         title="",  options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond3")
s_Cond_SC_3_op=      input.string(defval="crossover",    title="",  options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                     group= s_grp_SCC,inline="SC_cond3")
s_Cond_SC_3_ind2=    input.string(defval="IND3",         title="",  options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond3")
f_Cond_SC_3_ind2_val=input.float( defval=0,              title="",  step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SCC,inline="SC_cond3")

//_______________SHORT CLOSE 3-4 JOIN       
s_Cond_SC_3_join_4=  input.string(defval="AND",          title="",  options=["AND","OR"] ,    group= s_grp_SCC, tooltip=s_tt_comb_op)
        
//_______________SHORT CLOSE 4 CONDITION        
s_Cond_SC_4_ind1=    input.string(defval="NONE",         title="",  options=[s00, s01, s02, s03, s04, s05, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond4")
s_Cond_SC_4_op=      input.string(defval="crossover",    title="",  options=[op01, op02, op03, op04, op05, op06, op07, op08, op09],                                     group= s_grp_SCC,inline="SC_cond4")
s_Cond_SC_4_ind2=    input.string(defval="IND3",         title="",  options=[s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16],           group= s_grp_SCC,inline="SC_cond4")
f_Cond_SC_4_ind2_val=input.float( defval=0,              title="",  step=0.1, tooltip=s_tt_combination,                                                                group= s_grp_SCC,inline="SC_cond4")

//************ END CONDITION INPUTS}  

//************END INPUTS}     


//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ FUNCTIONS{

//**************** GENERIC FUNCTIONS{
//___________________PERIOD DEFINITION
fn_testPeriod() =>         
    time >= t_testPeriodStart and time <= t_testPeriodStop ? true : false
//___________________F_SECURITY***NOREPAINT (or Minimize it) 
f_security(_symbol, _res, _src, _secure) =>
    math.round_to_mintick(_secure ==    'Secure' ? request.security(_symbol, _res, _src[1], lookahead=barmerge.lookahead_on) : _secure == 'Semi Secure' ? request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1] : _secure == 'Repaint' ? request.security(_symbol, _res, _src[0])[0] : na)

src_open =        f_security(syminfo.tickerid, Timeframe, open,  secure)
src_close =       f_security(syminfo.tickerid, Timeframe, close, secure)
src_high =        f_security(syminfo.tickerid, Timeframe, high,  secure)
src_low =         f_security(syminfo.tickerid, Timeframe, low,   secure)
src_hl2 =         f_security(syminfo.tickerid, Timeframe, hl2,   secure)
src_hlc3 =        f_security(syminfo.tickerid, Timeframe, hlc3,  secure)
src_ohlc4 =       f_security(syminfo.tickerid, Timeframe, ohlc4, secure)
//src_data =        f_security(syminfo.tickerid, Timeframe, fn_get_source(data), secure)
src_external =    f_security(syminfo.tickerid, Timeframe, data_ext, secure)

//___________________Convert string sources to series sources
fn_get_source(string source_) => 
//     source_ == 'Avg Price'? close : 
    result  =   switch source_
        s01 =>  f_indicator1 
        s02 =>  f_indicator2 
        s03 =>  f_indicator3 
        s04 =>  f_indicator4 
        s05 =>  f_indicator5   
        s06 =>  0
        s07 =>  src_close 
        s08 =>  src_open 
        s09 =>  src_high 
        s10 =>  src_low 
        s11 =>  src_hl2 
        s12 =>  src_hlc3 
        s13 =>  src_ohlc4 
        s14 =>  volume        
        s15 =>  src_external        
        s16 =>  f_custom_ind        
      
        =>na
    result

fn_split(simple string s_data,sep_=".-")=>
    a=str.pos(s_data,sep_)
    result=str.substring(s_data,0,a)


//**************** END GENERIC FUNCTIONS}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//**************** CUSTOM INDICATORS FUNCTIONS{
//******************** CUSTOM INDICATOR DESIGN 
// define custom indicator  below. Define and Get input parameters from INPUTS/CUSTOM INDICATOR 1
// you can change the name of the custom indicator by updating CONSTANTS/CUSTOM INDICATORS c01="Cust Ind1" to your preffered name Ex: c01="My Custom EMA". (name should be unique and be different from other indicators names) 
// NOTE:!!! Custom indicators dont use the value on the SETTINGS / INDICATOR selection screen.. Just accepts the parameters on the current custom indicator(n) setting area
//Builtin tradingview EMA indicator for customization example
s_cind_src=        input.string(   defval=sma,          title='IND:' ,       options=[hide, org, ovrly, 
                                                                                     alma, ama  , acdst, cma,  dema, ema, gmma, hghst, hl2ma, hma, lgAdt, lgAdV, lguer, lsrcp, lexp, linrg, lowst, 
                                                                                     mgi,pcnl, pcnli, prev , pvth, pvtl, rema, rma, sar, sma, smma, supr2, supr3, strnd, swma, tema, tma, vida, vwma, vstop, wma, vwap, 
                                                                                     nvrly, 
                                                                                     adx, angle, aroon, atr, awsom, bbr, bbw, cci, cctbb, chng, cmf, cmo, cog, cpcrv, corrl, count, cti, dev, dpo, efi, eom, 
                                                                                     fall, fit, hvo, kcr, kcw, kli, macd, mfi, msi, nvi, obv, pvi, pvt, rangs, rise, roc, rsi, rvi, smosc, smsig, stc, stdev, trix, 
                                                                                     tsi, vari, wilpc, wad, wvad] 
                                                                 ,              group= s_grp_custom_ind, inline="cind_1")
s_cind_data =       input.string( defval="close",       title='',               group= s_grp_custom_ind, inline="cind_1", options=[s07, s08, s09, s10, s11, s12, s13, s14]) 
i_cind_len   =      input.int(    defval=74,            title='MALen',          group= s_grp_custom_ind, inline="cind_1")
i_cind_demlen =     input.int(    defval=68,            title='DemLen',         group= s_grp_custom_ind, inline="cind_2")  
i_cind_step   =     input.int(    defval=8,             title='Step',           group= s_grp_custom_ind, inline="cind_2")  
f_cind_curv   =     input.float(  defval=1.27,          title='Curv',           group= s_grp_custom_ind, inline="cind_2")  
f_cind_div =        input.float(  defval=0.5,           title='div',            group= s_grp_custom_ind, inline="cind_4")
s_cind_sig    =     input.string( defval="Signal",      title='Select Signal',  group= s_grp_custom_ind, inline="cind_3", options=["Signal","Demarker-T","Demarker-V"])  
b_cind_cross =      input.bool(   defval=false,         title="Cross",          group= s_grp_custom_ind, inline="cind_3")
s_cind_pType =      input.string( defval=p01,           title="PType",          group= s_grp_custom_ind, inline="cind_4", options=[p01,p02,p03], tooltip=s_tt_ind4)
i_cind_stlen =      input.int(    defval=50,            title='St/% val',       group= s_grp_custom_ind, inline="cind_4")
c_cind_color =      input(        defval=color.black ,  title="",               group= s_grp_custom_ind, inline="cind_4")

fn_demarker(simple int dem_length) =>
    deMax = src_high - src_high[1] > 0 ? src_high - src_high[1] : 0
    deMin = src_low[1] - src_low > 0 ? src_low[1] - src_low : 0
//    sma_deMax / (sma_deMax + sma_deMin)

//-------------------------------
    t=ta.ema(src_close,i_cind_len)
    a=t>src_close
//    sma_deMax=f_ma(deMax, dem_length, ma_type), 
//    sma_deMin=f_ma(deMin, dem_length, ma_type)
        
    sma_deMax = a?dtu.f_func(fn_split(s_cind_src),deMax, length_=int(dem_length/f_cind_div)):dtu.f_func(fn_split(s_cind_src),deMax, length_=int(dem_length))
    sma_deMin = a?dtu.f_func(fn_split(s_cind_src),deMin, length_=int(dem_length/f_cind_div)):dtu.f_func(fn_split(s_cind_src),deMax, length_=int(dem_length))

//    sma_deMax := a?f_ma(deMax,int(dem_length/cr_div),ma_type):f_ma(deMin,dem_length,ma_type)
//    sma_deMin := a?f_ma(deMin, int(dem_length/cr_div),ma_type):f_ma(deMin, dem_length,ma_type)
    sma_deMax / (sma_deMax + sma_deMin)

fn_cronex() =>
    bool crossing           = b_cind_cross
    int demarker_length     = i_cind_demlen
    int dem_step            = i_cind_step
    float curvature         = f_cind_curv

    e1 = 0.0, e2 = 0.0,e3 = 0.0, e4 = 0.0, e5 = 0.0, e6 = 0.0
    n  = 1 + 0.5 * (demarker_length - 1)
    w1 = 2 / (demarker_length + 1)
    w2 = 1 - w1
    b2 = curvature * curvature
    b3 = b2 * curvature
    c1 = -b3
    c2 = (3 * (b2 + b3))
    c3 = -3 * (2 * b2 + curvature + b3)
    c4 = (1 + 3 * curvature + b3 + 3 * b2)
    
    demarker_v = (fn_demarker(demarker_length) + fn_demarker(demarker_length + dem_step) + fn_demarker(demarker_length + dem_step * 2) + fn_demarker(demarker_length + dem_step * 3)) * 100 / 4 - 50
    e1 := not na(demarker_v) ? w1 * demarker_v + w2 * e1[1] : 0
    e2 := not na(demarker_v) ? w1 * e1 + w2 * e2[1] : 0
    e3 := not na(demarker_v) ? w1 * e2 + w2 * e3[1] : 0
    e4 := not na(demarker_v) ? w1 * e3 + w2 * e4[1] : 0
    e5 := not na(demarker_v) ? w1 * e4 + w2 * e5[1] : 0
    e6 := not na(demarker_v) ? w1 * e5 + w2 * e6[1] : 0
    
    demarker_t = c1*e6 + c2*e5 + c3*e4 + c4*e3
    signal = 0
    if crossing
        signal := ta.crossover(demarker_v,demarker_t)?1:ta.crossunder(demarker_v,demarker_t)?-1:0
    else
        signal := (demarker_v > demarker_t)? 1:-1
    [signal,demarker_v,demarker_t]

fn_custom_ind()=>
    [x,y,z]=fn_cronex()
    src_=s_cind_sig=="Signal"?x:s_cind_sig=="Demarker-V"?y:z
    f_plot_= switch s_cind_pType 
        "Stochastic" => ta.stoch(src_, src_, src_, i_cind_stlen) / 50 - 1 
        "PercentRank" => ta.percentrank(src_, i_cind_stlen) / 50 - 1 
        "Original" => src_
        => src_
    f_plot_
    
//********************* END CUSTOM INDICATORS DEFINITIONS}


//**************** CONDITION FUNCTIONS{
fn_get_Condition_Indicator(string cond_ind1_,string cond_ind2_,float cond_ind_value_)=>
// if selection other than "VALUE"
// and if first_ind=flse then use condition's value field for second  indicator's #previous value
    float cond_ind_val1_ = switch cond_ind1_
        s00	=> 0. 
    	s01	=> f_indicator1 
    	s02	=> f_indicator2
    	s03	=> f_indicator3
    	s04	=> f_indicator4
    	s05	=> f_indicator5
    	s07	=> src_close
    	s08	=> src_open 
    	s09	=> src_high
    	s10	=> src_low 
    	s11	=> src_hl2
    	s12	=> src_hlc3
    	s13	=> src_ohlc4
    	s14	=> volume
    	s15	=> src_external
    	s16	=> f_custom_ind 
    	s06	=> cond_ind_value_
        => 0.

    float cond_ind_val2_ = switch cond_ind2_
        s00	=> 0.
    	s01	=> f_indicator1[cond_ind_value_]
    	s02	=> f_indicator2[cond_ind_value_]
    	s03	=> f_indicator3[cond_ind_value_]
    	s04	=> f_indicator4[cond_ind_value_]
    	s05	=> f_indicator5[cond_ind_value_]
    	s06	=> cond_ind_value_
    	s07	=> src_close[cond_ind_value_] 
    	s08	=> src_open[cond_ind_value_]  
    	s09	=> src_high[cond_ind_value_]  
    	s10	=> src_low[cond_ind_value_]   
    	s11	=> src_hl2[cond_ind_value_]   
    	s12	=> src_hlc3[cond_ind_value_]  
    	s13	=> src_ohlc4[cond_ind_value_] 
    	s14	=> volume[cond_ind_value_]
    	s15	=> src_external[cond_ind_value_]
    	s16	=> f_custom_ind[cond_ind_value_] 
        => 0.

    [cond_ind_val1_,cond_ind_val2_]
    
fn_get_Condition_Result(string cond_ind1_,string cond_op_,string cond_ind2_,float cond_ind2_value_)=>
    result=0
    if fn_testPeriod()
        [cond_ind1_val_,cond_ind2_val_] = fn_get_Condition_Indicator(cond_ind1_,cond_ind2_, cond_ind2_value_)
//        cond_ind2_val_ = fn_get_Condition_Indicator(cond_ind2_, cond_ind2_value_, false)
        

        int cond_result_=   switch cond_op_     
        	op01	=> ta.crossover(cond_ind1_val_,cond_ind2_val_)?  1 : -1
        	op02	=> ta.crossunder(cond_ind1_val_,cond_ind2_val_)? 1 : -1
        	op03	=> ta.cross(cond_ind1_val_,cond_ind2_val_)? 1 : -1
        	op04	=> cond_ind1_val_ >  cond_ind2_val_ ? 1 : -1
        	op05	=> cond_ind1_val_ <  cond_ind2_val_ ? 1 : -1
        	op06	=> cond_ind1_val_ >= cond_ind2_val_ ? 1 : -1
        	op07	=> cond_ind1_val_ <= cond_ind2_val_ ? 1 : -1
        	op08	=> cond_ind1_val_ == cond_ind2_val_ ? 1 : -1
        	op09	=> cond_ind1_val_ != cond_ind2_val_ ? 1 : -1
			=> 0

        result:=cond_ind1_=="NONE"?0:cond_result_
    result

//**************** JOIN CONDITIONS
fn_join_Condition_Result(int cond1_=0,int cond2_=0,int cond3_=0,int cond4_=0, string cond_1_join_2_="AND", string cond_2_join_3_="AND", string cond_3_join_4_="AND")=>
    bool cond_=false
    if cond1_!=0
        cond_:=cond1_==1
        if cond1_!=0 and cond2_ !=0
            cond_ := switch cond_1_join_2_
            	"AND"   => cond1_==1 and cond2_==1
            	"OR"    => cond1_==1 or cond2_ ==1
            if cond3_ !=0
                cond_:= switch cond_2_join_3_
                	"AND"   => cond_==1 and cond3_==1
                	"OR"    => cond_==1 or  cond3_==1
                if cond4_ !=0
                    cond_:= switch cond_3_join_4_
                    	"AND"   => cond_==1 and cond4_==1
                    	"OR"    => cond_==1 or  cond4_==1
    result=cond_

//**************** GET CONDITIONS
fn_get_conditions(string type_)=> 
    result=false
    if type_=="LONG" and (s_Cond_LE_1_ind1!="NONE" or s_Cond_LE_2_ind1!="NONE" or s_Cond_LE_3_ind1!="NONE") 
        int long_entry1=fn_get_Condition_Result(s_Cond_LE_1_ind1,s_Cond_LE_1_op,s_Cond_LE_1_ind2,f_Cond_LE_1_ind2_val)
        int long_entry2=fn_get_Condition_Result(s_Cond_LE_2_ind1,s_Cond_LE_2_op,s_Cond_LE_2_ind2,f_Cond_LE_2_ind2_val)
        int long_entry3=fn_get_Condition_Result(s_Cond_LE_3_ind1,s_Cond_LE_3_op,s_Cond_LE_3_ind2,f_Cond_LE_3_ind2_val)
        int long_entry4=fn_get_Condition_Result(s_Cond_LE_4_ind1,s_Cond_LE_4_op,s_Cond_LE_4_ind2,f_Cond_LE_4_ind2_val)
        result := fn_join_Condition_Result(cond1_=long_entry1,cond2_=long_entry2,cond3_=long_entry3,cond4_=long_entry4, cond_1_join_2_=s_Cond_LE_1_join_2, cond_2_join_3_=s_Cond_LE_2_join_3, cond_3_join_4_=s_Cond_LE_3_join_4)
    
    if type_=="SHORT" and (s_Cond_SE_1_ind1!="NONE" or s_Cond_SE_2_ind1!="NONE" or s_Cond_SE_3_ind1!="NONE")
        int short_entry1=fn_get_Condition_Result(s_Cond_SE_1_ind1,s_Cond_SE_1_op,s_Cond_SE_1_ind2,f_Cond_SE_1_ind2_val)
        int short_entry2=fn_get_Condition_Result(s_Cond_SE_2_ind1,s_Cond_SE_2_op,s_Cond_SE_2_ind2,f_Cond_SE_2_ind2_val)
        int short_entry3=fn_get_Condition_Result(s_Cond_SE_3_ind1,s_Cond_SE_3_op,s_Cond_SE_3_ind2,f_Cond_SE_3_ind2_val)
        int short_entry4=fn_get_Condition_Result(s_Cond_SE_4_ind1,s_Cond_SE_4_op,s_Cond_SE_4_ind2,f_Cond_SE_4_ind2_val)
        result := fn_join_Condition_Result(cond1_=short_entry1,cond2_=short_entry2,cond3_=short_entry3,cond4_=short_entry4, cond_1_join_2_=s_Cond_SE_1_join_2, cond_2_join_3_=s_Cond_SE_2_join_3, cond_3_join_4_=s_Cond_SE_3_join_4)
    
    if type_=="LONGCLOSE" and (s_Cond_LC_1_ind1!="NONE" or s_Cond_LC_2_ind1!="NONE" or s_Cond_LC_3_ind1!="NONE")
        int long_close1=fn_get_Condition_Result(s_Cond_LC_1_ind1,s_Cond_LC_1_op,s_Cond_LC_1_ind2,f_Cond_LC_1_ind2_val)
        int long_close2=fn_get_Condition_Result(s_Cond_LC_2_ind1,s_Cond_LC_2_op,s_Cond_LC_2_ind2,f_Cond_LC_2_ind2_val)
        int long_close3=fn_get_Condition_Result(s_Cond_LC_3_ind1,s_Cond_LC_3_op,s_Cond_LC_3_ind2,f_Cond_LC_3_ind2_val)
        int long_close4=fn_get_Condition_Result(s_Cond_LC_4_ind1,s_Cond_LC_4_op,s_Cond_LC_4_ind2,f_Cond_LC_4_ind2_val)
        result := fn_join_Condition_Result(cond1_=long_close1,cond2_=long_close2,cond3_=long_close3,cond4_=long_close4, cond_1_join_2_=s_Cond_LC_1_join_2, cond_2_join_3_=s_Cond_LC_2_join_3, cond_3_join_4_=s_Cond_LC_3_join_4)
    
    if type_=="SHORTCLOSE" and (s_Cond_SC_1_ind1!="NONE" or s_Cond_SC_2_ind1!="NONE" or s_Cond_SC_3_ind1!="NONE")
        int short_close1=fn_get_Condition_Result(s_Cond_SC_1_ind1,s_Cond_SC_1_op,s_Cond_SC_1_ind2,f_Cond_SC_1_ind2_val)
        int short_close2=fn_get_Condition_Result(s_Cond_SC_2_ind1,s_Cond_SC_2_op,s_Cond_SC_2_ind2,f_Cond_SC_2_ind2_val)
        int short_close3=fn_get_Condition_Result(s_Cond_SC_3_ind1,s_Cond_SC_3_op,s_Cond_SC_3_ind2,f_Cond_SC_3_ind2_val)
        int short_close4=fn_get_Condition_Result(s_Cond_SC_4_ind1,s_Cond_SC_4_op,s_Cond_SC_4_ind2,f_Cond_SC_4_ind2_val)
        result := fn_join_Condition_Result(cond1_=short_close1,cond2_=short_close2,cond3_=short_close3,cond4_=short_close4, cond_1_join_2_=s_Cond_SC_1_join_2, cond_2_join_3_=s_Cond_SC_2_join_3, cond_3_join_4_=s_Cond_SC_3_join_4)
    result
//**************** CONDITION FUNCTIONS}

//************ END FUNCTIONS}

fn_paramVer(simple string pver_)=>
    int ver_=switch pver_
        v01 =>  1
        v02 =>  2
    ver_
    
fn_factorVer(simple string fver_)=>
    int ver_=switch fver_
        f01 =>  1
        f02 =>  2
        f03 =>  3
        f04 =>  4
    ver_
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ CUSTOM INDICATOR CALCULATIONS{   
f_custom_ind:=fn_custom_ind()      //dont change "float custom_ind". this is result of the indicator used by the system 
//******END CUSTOM INDICATORS CALCULATIONS}

//**************** INDICATORS CALCULATIONS{
if  s_ind1_src!=hide and b_plt1_ind!=false 
    s_ind1_data_=fn_get_source(s_ind1_data)
    f_indicator1:=dtu.fn_factor(FuncType_=fn_split(s_ind1_src), src_data_=s_ind1_data_, length_=f_ind1_len, p1=f_ind1_p1, p2=f_ind1_p2, version_=fn_paramVer(s_ind1_ver), fact_=fn_factorVer(s_ind1_fact), plotingType_=s_ind1_pType, stochlen_=i_ind1_stlen, plotSWMA_=b_ind1_pSWMA,  log_=s_ind1_log)

if  s_ind2_src!=hide and b_plt2_ind!=false 
    s_ind2_data_=fn_get_source(s_ind2_data)
    f_indicator2:=dtu.fn_factor(FuncType_=fn_split(s_ind2_src), src_data_=s_ind2_data_, length_=f_ind2_len, p1=f_ind2_p1, p2=f_ind2_p2, version_=fn_paramVer(s_ind2_ver), fact_=fn_factorVer(s_ind2_fact), plotingType_=s_ind2_pType, stochlen_=i_ind2_stlen, plotSWMA_=b_ind2_pSWMA,  log_=s_ind2_log)

if  s_ind3_src!=hide and b_plt3_ind!=false 
    s_ind3_data_=fn_get_source(s_ind3_data)
    f_indicator3:=dtu.fn_factor(FuncType_=fn_split(s_ind3_src), src_data_=s_ind3_data_, length_=f_ind3_len, p1=f_ind3_p1, p2=f_ind3_p2, version_=fn_paramVer(s_ind3_ver), fact_=fn_factorVer(s_ind3_fact), plotingType_=s_ind3_pType, stochlen_=i_ind3_stlen, plotSWMA_=b_ind3_pSWMA,  log_=s_ind3_log)

if  s_ind4_src!=hide and b_plt4_ind!=false 
    s_ind4_data_=fn_get_source(s_ind4_data)
    f_indicator4:=dtu.fn_factor(FuncType_=fn_split(s_ind4_src), src_data_=s_ind4_data_, length_=f_ind4_len, p1=f_ind4_p1, p2=f_ind4_p2, version_=fn_paramVer(s_ind4_ver), fact_=fn_factorVer(s_ind4_fact), plotingType_=s_ind4_pType, stochlen_=i_ind4_stlen, plotSWMA_=b_ind4_pSWMA,  log_=s_ind4_log)

if  s_ind5_src!=hide and b_plt5_ind!=false 
    s_ind5_data_=fn_get_source(s_ind5_data)
    f_indicator5:=dtu.fn_factor(FuncType_=fn_split(s_ind5_src), src_data_=s_ind5_data_, length_=f_ind5_len, p1=f_ind5_p1, p2=f_ind5_p2, version_=fn_paramVer(s_ind5_ver), fact_=fn_factorVer(s_ind5_fact), plotingType_=s_ind5_pType, stochlen_=i_ind5_stlen, plotSWMA_=b_ind5_pSWMA,  log_=s_ind5_log)


//**************** END INDICATORS CALCULATIONS}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ SIGNAL CALCULATIONS{
bool long=      fn_get_conditions("LONG")
bool short=     fn_get_conditions("SHORT")
bool longclose= fn_get_conditions("LONGCLOSE")     
bool shortclose= fn_get_conditions("SHORTCLOSE")    
if b_isopposite
    longclose:= longclose or short
    shortclose:=shortclose or long
//************END SIGNAL CALCULATIONS}



//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ ALERTS{
alertcondition(long,        title="Long",       message="LONG")  
alertcondition(short,       title="Short",      message="SHORT") 
alertcondition(longclose,   title="Close Long", message="CLOSE LONG") 
alertcondition(longclose,   title="Close Short",message="CLOSE SHORT") 
//************END ALERTS{


//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//************ PLOTs{
//_________PLOT TYPE CALCULATIONS FOR HLINES
fn_plot(float indicator_, simple string pType_, simple int stoch_)=>
    float result= switch pType_
        p01 =>  indicator_
        p02 =>  i_ind_shift + (indicator_ * i_ind_mult)   
        p03 =>  i_ind_shift + (indicator_ * i_ind_mult)   
    result
//p01='Original' , p02='Stochastic' , p03='PercentRank' , p04='Org. Range (-1,1)'    


//_________PLOT INDICATORS  (if Indicator PlotType is "Original" plot over chart otherwise plot between HLines) 
plot(s_ind1_src!=hide ? fn_plot(indicator_=f_indicator1, pType_=s_ind1_pType, stoch_=i_ind1_stlen):na, "",c_ind1_color) 
plot(s_ind2_src!=hide ? fn_plot(indicator_=f_indicator2, pType_=s_ind2_pType, stoch_=i_ind2_stlen):na, "",c_ind2_color) 
plot(s_ind3_src!=hide ? fn_plot(indicator_=f_indicator3, pType_=s_ind3_pType, stoch_=i_ind3_stlen):na, "",c_ind3_color) 
plot(s_ind4_src!=hide ? fn_plot(indicator_=f_indicator4, pType_=s_ind4_pType, stoch_=i_ind4_stlen):na, "",c_ind4_color) 
plot(s_ind5_src!=hide ? fn_plot(indicator_=f_indicator5, pType_=s_ind5_pType, stoch_=i_ind5_stlen):na, "",c_ind5_color) 

plot(s_cind_src!=hide ? fn_plot(indicator_=f_custom_ind, pType_=s_cind_pType, stoch_=i_cind_stlen):na, "",c_cind_color) 


//plot(s_ind1_src!=hide ? (s_ind1_pType=="Original"?f_indicator1: i_ind_shift + (f_indicator1 * i_ind_mult)):na, "",c_ind1_color) 
//plot(s_ind2_src!=hide ? (s_ind2_pType=="Original"?f_indicator2: i_ind_shift + (f_indicator2 * i_ind_mult)):na, "",c_ind2_color) 
//plot(s_ind3_src!=hide ? (s_ind3_pType=="Original"?f_indicator3: i_ind_shift + (f_indicator3 * i_ind_mult)):na, "",c_ind3_color) 
//plot(s_ind4_src!=hide ? (s_ind4_pType=="Original"?f_indicator4: i_ind_shift + (f_indicator4 * i_ind_mult)):na, "",c_ind4_color) 
//plot(s_ind5_src!=hide ? (s_ind5_pType=="Original"?f_indicator5: i_ind_shift + (f_indicator5 * i_ind_mult)):na, "",c_ind5_color) 


//_________SHOW REAL INDICATOR VALUES ON DATA WINDOW
plotshape(s_ind1_src!=hide ? f_indicator1:na, "INDICATOR1", text="",color=color.new(c_ind1_color,100)) 
plotshape(s_ind2_src!=hide ? f_indicator2:na, "INDICATOR2", text="",color=color.new(c_ind2_color,100)) 
plotshape(s_ind3_src!=hide ? f_indicator3:na, "INDICATOR3", text="",color=color.new(c_ind3_color,100)) 
plotshape(s_ind4_src!=hide ? f_indicator4:na, "INDICATOR4", text="",color=color.new(c_ind4_color,100)) 
plotshape(s_ind5_src!=hide ? f_indicator5:na, "INDICATOR5", text="",color=color.new(c_ind5_color,100)) 

plotshape(s_cind_src!=hide ? f_custom_ind:na, "IND CUSTOM", text="",color=color.new(c_cind_color,100)) 

//_________PLOT HLINE for Stochastic/Precentage/Org Range(-1,1) between range -1 and 1
hline(b_ind_hline?i_ind_shift + (1 *  i_ind_mult):na, title="LINE 1",   linestyle=hline.style_dashed ,color=color.new(color.black, 0)) 
hline(b_ind_hline?i_ind_shift + (0.5 *i_ind_mult):na, title="LINE 0.5", linestyle=hline.style_dashed ,color=color.new(color.black, 75)) 
hline(b_ind_hline?i_ind_shift + (0 *  i_ind_mult):na, title="LINE 0",   linestyle=hline.style_dashed ,color=color.new(color.black, 0)) 
hline(b_ind_hline?i_ind_shift + (-0.5*i_ind_mult):na, title="LINE -0.5",linestyle=hline.style_dashed ,color=color.new(color.black, 75)) 
hline(b_ind_hline?i_ind_shift + (-1 * i_ind_mult):na, title="LINE -1",  linestyle=hline.style_dashed ,color=color.new(color.black, 0)) 

//_________PLOT ALERTS for LONG at Bottom and for SHORT at TOP of the screen 
plotshape(b_plotalert ? long : na,        title='LONG',      style=shape.triangleup,    location=location.bottom,   color=color.new(color.green, 0),size=size.tiny)
plotshape(b_plotalert ? short : na,       title='SHORT',     style=shape.triangledown,  location=location.top,      color=color.new(color.blue, 0), size=size.tiny)
plotshape(b_plotalert ? longclose : na,   title='EXIT LONG', style=shape.triangledown,  location=location.bottom,   color=color.new(color.red, 0),  size=size.tiny)
plotshape(b_plotalert ? shortclose : na,  title='EXIT SHORT',style=shape.triangleup,    location=location.top,      color=color.new(color.black, 0),size=size.tiny)

//************END PLOTs}

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//********** INDICATOR's SIGNALS EXPORT{
// Followings are for my personal usage on my own strategy framework. 
// Created Parallel data transfer algorithm (@DTurkuler)
// With this algo all builded signals can be transferred to another strategy/indicator without interferring with another signal
longCondition =long
shortCondition = short
ExitlongCondition = longclose
ExitshortCondition = shortclose

s_signalVersion= input.string(defval="Strategy Framework v2 @DTU", title="Output Signal for Framework", options=["Strategy Framework v1 @DTU", 
                                                                                                                 "Strategy Framework v2 @DTU", 
                                                                                                                 "Ultimate Strategy Template @Devatt", 
                                                                                                                 "Backtesting & Trading Engine @Pinecoders" , 
                                                                                                                 "Strategy Template @Benson", 
                                                                                                                 "Custom"], group=s_grp_signal, inline="sig1", tooltip=s_tt_signals)
//Folowing inputs are used for custom signal output design
lCon = input.int(     title='Long Entry',   defval= 1, group=s_grp_signal, inline="sig2" )
sCon = input.int(     title='Short Entry',  defval=-1, group=s_grp_signal, inline="sig2" )
lConExit = input.int( title='Long Exit',    defval= 2, group=s_grp_signal, inline="sig3" )
sConExit = input.int( title='Short Exit',   defval=-2, group=s_grp_signal, inline="sig3" )


f_signalEncoder()=>
    int i_SignalVersion=switch s_signalVersion
        "Strategy Framework v1 @DTU"                =>  1
        "Strategy Framework v2 @DTU"                =>  2
        "Ultimate Strategy Template @Devatt"        =>  3
        "Backtesting & Trading Engine @Pinecoders"  =>  4
        "Strategy Template @Benson"                 =>  5
        "Custom Values"                             =>  6
        =>  na  
    float f_Signal_=0
    if  i_SignalVersion==1
        //_______________DATA ENCODER V1 
        //is used prepare indicator values  as signal for my Strategy Framework v1 DTU. 
        //Signal data  added as to the fractional part   
        //Long Entry Signals 
        //(10:Long Entry 20:Long Exit 30:No Operation)
        f_Signal_ := longCondition ? 10 : ExitlongCondition ? 20 : 30
        //Short Entry Signals 
        //(10:Long Entry 20:Long Exit 30:No Operation)
        f_Signal_ := f_Signal_ + (shortCondition ? 1 : ExitshortCondition ? 2 : 3)
        //TODO: Entry/Exit Filter Signals (1:Entry 2:No Entry 3:No Operation)
        //Signal1 := Signal1 + (entryFilter ? 100 : exitFilter ? 200 : 300)
        //TODO: Trend Filter Signals (1:Up 2:down 3:Sideways)
        //Signal1 := Signal1 + (trend==1 ? 1000 : trend==-1 ? 2000 : 3000)

    if  i_SignalVersion==2
        //_______________DATA ENCODER V2 
        //(Set precision to 4)
        //is used prepare indicator values  as signal for my Strategy Framework v1 DTU. 
        //plot the indicator values  over the stock by using close value. 
        //Signal data shifted to digit area and close value added as carrier to the fractional part   
        f_Signal_ := longCondition ? 10 : ExitlongCondition ? 20 : 30
        f_Signal_ := f_Signal_ + (shortCondition ? 1 : ExitshortCondition ? 2 : 3)
        float f_carrier=int(close)
        f_Signal_:=0.0001*f_Signal_
        f_Signal_+=f_carrier

    if  i_SignalVersion==3
        //_______________DATA ENCODER V3 
        //is used prepare indicator values  as a signal for @Daveatt's "Ultimate Strategy Template"   
        f_Signal_ := longCondition ? 1 : shortCondition ? -1 : ExitlongCondition ? 2 : ExitshortCondition ? -2 : 0

    if  i_SignalVersion==4
        //_______________DATA ENCODER V4 
        //is used prepare indicator values  as a signal for   @Pinecoders's "Backtesting & Teading Engine"  
        f_Signal_ := longCondition ? 1 : shortCondition ? -1 : ExitlongCondition ? 2 : ExitshortCondition ? -2 : 0

    if  i_SignalVersion==5
        //_______________DATA ENCODER V5 
        //is used prepare indicator values  as a signal for  @Benson's "Strategy Template"  
        f_Signal_ := longCondition ? 1 : shortCondition ? -1 : ExitlongCondition ? 2 : ExitshortCondition ? -2 : 0

    if  i_SignalVersion==6
        //_______________DATA ENCODER V6 
        //is used prepare indicator values  as a signal by using custom values  
        f_Signal_ := longCondition ? lCon : shortCondition ? sCon : ExitlongCondition ? lConExit : ExitshortCondition ? sConExit : 0
    f_Signal_

plot(f_signalEncoder(), title='🔌Connector🔌', color=color.new(color.blue,100))

//************END INDICATOR's SIGNALS EXPORT}


//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
////************************************************
////************ STRATEGY DEFINITIONS{
////************************************************
////For indicator usage: Mark following lines 
////and  Change strategy(....) to indicator(....) at start of the code 
////________________STRATEGY ENTRIES & EXITS
//if fn_testPeriod() and long       
////    strategy.entry("buy",strategy.long,alert_message=web_hook("Buy",close,bot_json))
//    strategy.entry("buy", strategy.long, alert_message="L",comment="L")
//
//if fn_testPeriod() and short       
////    strategy.entry("sell",strategy.short,alert_message=web_hook("Sell",close,bot_json))
//    strategy.entry("sell",strategy.short,alert_message="S",comment="S")
//
//if fn_testPeriod() and longclose 
////    strategy.close_all(alert_message=web_hook("Close",close,bot_json))
//    strategy.close("buy", alert_message="CL",comment="CL")
//
//if fn_testPeriod() and shortclose
////    strategy.close_all(alert_message=web_hook("Close",close,bot_json))
//    strategy.close("sell",alert_message="CS",comment="CS")
////-------------------------------------------------------------
//
////_____________SHOW PROFIT    // Should be improved I am stucked !!!
//s_showProfit=       input.string(   defval="None",  title="Show Profit", options=["None", "Open+Net Profit", "Current Profit" ],  group=s_grp_strategy,inline="show profit")
//i_showProfit_trans= input.int(      defval=80,      title="Transparency",                                                         group=s_grp_strategy,inline="show profit", tooltip=s_tt_Profit)
//
//fn_get_profit_bytype(string s_profitType_)=>
//    float f_profit_=switch s_profitType_
//        "None"           =>  na
//        "Open+Net Profit"=>  (strategy.netprofit+strategy.openprofit)
//        "Open Profit"    =>  strategy.openprofit
//    f_profit_
//var openposprof= array.new_float(0)
//
//float cur=0.
//float max=1.
//float min=0.
//if s_showProfit!="None"
//    array.push(openposprof,fn_get_profit_bytype(s_showProfit)/strategy.initial_capital)
//    cur:=array.get(openposprof,bar_index)
//    max:=array.max(openposprof)
//    min:=array.min(openposprof)
//float f_profit=cur/ (max - min)
//f_profitper=f_profit
//
//fill(plot(s_showProfit!="None"?i_ind_shift + (f_profit * i_ind_mult):na,   title="",color=f_profit<0?color.new(color.red,i_showProfit_trans):color.new(color.green,i_showProfit_trans)),
//     plot(s_showProfit!="None"?i_ind_shift:na,                                title="",color=color.new(color.white,100)),
//     f_profit<0?color.new(color.red,i_showProfit_trans+5):color.new(color.green,i_showProfit_trans+5))  //Fill area on Profit value on between hlines
//plotshape(s_showProfit!="None"?f_profit*100:na,  title="PROFIT%",text="",color=color.new(color.white,100))  //Show Real Profit value on Data Window
////************END STRATEGY DEFINITIONS}
//
//
