Alıntı Originally Posted by @yörük@ Yazıyı Oku
https://tr.tradingview.com/script/Ze6GlKJO/


https://tr.tradingview.com/script/LG...es-ChartPrime/ bu da ....olasılık ihtimali...rastlantısal yürüyüş kodu...
bunu inceleyip...sadeleyip....üste yazılan koda ilave etsek ne olacak bakalım...
rastlantısal yürüyüş için görsel sadelendi....
olasılık ihtimali...mavi-fuşya sutun bırakıldı....
standart iptal edilip...lineer ayarlandı...
bar color içinse...olasılığa uyum olsun diye....
maviler yükseliş...fuşyalar düşüş rengine göre eşleştrildi...
https://www.tradingview.com/x/ekvp8lbJ/

https://www.tradingview.com/x/0Ld2KBBE/

kodun birleşmiş hali....
PHP Code:
 // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ChartPrime
 
//@version=5
indicator("."max_boxes_count=500max_lines_count=500max_bars_back=500overlay=true)

prng(series float seedseries int _range=100) =>
    var 
float random 1.0
    random 
:=   ((3.1415926 random %   seed) * 271.828) % _range
    float new_seed 
= ((seed 1.618) % _range) + random
    
[randomnew_seed]

method probability(series float[] selfseries int idxseries float sum) => self.get(idx) / sum 100.0

percent    
(series float   endseries float   start) => (end -   start) / start
add_percent
(series float valueseries float percent) => (1.0 percent) * value

log_returns    
(series float   endseries float       start) => math.log(end start)
add_log_returns(series float valueseries float log_returns) => math.exp(log_returns) * value

returns    
(series float   endseries float   startsimple bool style) => style ?     percent(  end,   start) :     log_returns(  end,   start)
add_returns(series float valueseries float returnsseries bool style) => style add_percent(valuereturns) : add_log_returns(valuereturns)

method add        (series int[] selfseries int     idxseries int     value=1) => self.set(idxself.get(idx) + value)
method add_to_dist(series int[] selfseries float valueseries float bin_width) => self.add(int(math.abs(value) / bin_width), 1)

method normal_valueseries float[] self,
                     
series int      idx,
                     
simple int    scale,
                     
simple bool  invert=true) =>
    
float  min self.min()
    
int normal int((self.get(idx) - min) * (scale 1) / (self.max() - min)) + 1
    
if invert
        normal 
:= scale normal
    normal

sinc
(series float sourceseries float bandwidth) =>
    
float omega math.pi source bandwidth
    source 
!= 0.0 math.sin(omega) / omega 1.0

type move
    int
[]  polarity
    int
[]  up
    int
[]  down
    float  bin_width
    float  extreme
    float  drift
    string drift_style
    bool   return_style
    float  vol

slope
(series int length) =>
    
float sumx  0.0
    float sumy  
0.0
    float sumx2 
0.0
    float sumxy 
0.0
    
for int i 0 to length 1
        float src 
close[i]
        
int idx_1 1
        sumx     
+= idx_1
        sumy     
+= src
        sumx2    
+= math.pow(idx_12)
        
sumxy    +=    src idx_1
    float slope 
= -((length sumxy sumx sumy) / (length sumx2 sumx sumx))

standard_drift(series int length) => 
    
float log_return  math.log(close close[1])
    
float log_return2 math.powlog_return,  )
    
float vari 0.0
    float mean 
0.0
    
for int i 0 to length 1
        mean 
+= log_returni]
        
vari += log_return2[i]
    
mean /= length
    vari 
/= length 2
    float drift 
mean vari

drift
(series int lengthsimple string style) =>
    switch 
style
        
"Standard"          => standard_drift(length)
        
"Linear Regression" =>          slope(length)
        =>                     
0.0 // "None"

volatility_adjustment(series float sourcesimple int lengthsimple bool enable) =>
    
float vol_adj ta.sma(math.sqrt(math.sum(math.pow(source2), length) / (length 1)), length) * 0.5
    
if not enable
        vol_adj 
:= 0.0
    vol_adj

moves
(simple int       precision,
      
simple int            bins,
      
simple int        lookback,
      
simple string  drift_style,
      
simple int    drift_length,
      
simple string       source,
      
simple bool   return_style,
      
simple int           steps,
      
simple bool volatility_adj) =>
    array<
intpolarity        = array.new<int>(       20)
    array<
intdelta_up_dist   = array.new<int>(bins 10)
    array<
intdelta_down_dist = array.new<int>(bins 10)
    
float      last source=="Move" close[1] : open
    float       ret 
returns(closelastreturn_style)
    
int    rounding precision + (return_style 2)
    
float     delta math.round(retrounding)
    
float   volatil volatility_adjustment(retstepsvolatility_adj)
    
float   extreme math.max(math.abs(ta.highest(delta[1], lookback)),
                               
math.abs(ta.lowest (delta[1], lookback)))
    
float     drift drift(drift_length == lookback drift_lengthdrift_style)
    
float bin_width extreme bins
    
if barstate.islast
        
for int i 1 to lookback
            
if close[i] <= last[i]
                
polarity.add(1)
                
add_to_dist(delta_down_distdelta[i], bin_width)
            else
                
polarity.add(0)
                
add_to_dist(delta_up_distdelta[i], bin_width)
    
move.new(polaritydelta_up_distdelta_down_distbin_widthextremedriftdrift_stylereturn_stylevolatil)

method idx_to_percent(series move     self,
                      
series int     index,
                      
series float volatil,
                      
simple bool polarity) =>
    (
polarity : -1) * (index self.bin_width volatil)
                                    

monte_carlo(series move movesseries float seedsimple int steps) =>
    array<
floatmonte = array.new<float>(steps)
    
float    over_seed seed
    int   polarity_sum 
moves.polarity.sum()
    
int   moves_up_sum moves.up.sum()
    
int   moves_dn_sum moves.down.sum()
    if 
moves.up.max() > and moves.down.max() > 0
        
for int i 0 to steps 1
            
[polarity_randompolarity_seed] = prng(over_seed)
            
over_seed := polarity_seed
            
if moves.polarity.probability(0polarity_sum) >= polarity_random 
                int moves_up_size_1 
moves.up.size() - 1
                
[move_randommove_random_seed] = prng(over_seedmoves_up_size_1)
                
over_seed      := move_random_seed
                int  up_index   
int(move_random)
                
bool move_found false
                
while not move_found
                    
if  up_index moves_up_size_1
                        up_index 
:= 0
                    
if moves.up.get(up_index) == 0
                        up_index 
+= 1
                        
continue
                    [
move_find_randommove_find_seed] = prng(over_seed)
                    
over_seed := move_find_seed
                    
if moves.up.probability(up_indexmoves_up_sum) >= move_find_random 
                        monte
.set(imoves.idx_to_percent(up_indexmoves.voltrue))
                        
move_found := true
                        
break
                    else
                        
up_index += 1
                
continue
            else
                
int moves_down_size_1 moves.down.size() - 1
                
[move_randommove_random_seed] = prng(over_seedmoves_down_size_1)
                
over_seed      := move_random_seed
                int  down_index 
int(move_random)
                
bool move_found false
                
while not move_found
                    
if  down_index moves_down_size_1
                        down_index 
:= 0
                    
if moves.down.get(down_index) == 0
                        down_index 
+= 1
                        
continue 
                    [
move_find_randommove_find_seed] = prng(over_seed)
                    
over_seed := move_find_seed
                    
if moves.down.probability(down_indexmoves_dn_sum) >= move_find_random 
                        monte
.set(imoves.idx_to_percent(down_indexmoves.volfalse))
                        
move_found := true
                        
break
                    else
                        
down_index += 1
                
continue
    [
monteover_seed]

add_drift(series float valueseries float driftseries string style) =>
    switch 
style
        
"Standard"          => add_log_returns(valuedrift)
        
"Linear Regression" => value drift
        
=>                     value // "None"

sim(series move movesseries float seedsimple int steps) =>
    
float simulation open
    
[movements_seed] = monte_carlo(movesseedsteps)
    for 
int i 0 to steps 1
        simulation 
:= add_drift(add_returns(simulationmovements.get(i), moves.return_style), moves.driftmoves.drift_style)
    [
simulation_seed]

sinc_filter(series array<floatsourcesimple float length) =>
    var 
float length_1 length 1.0
    
if length 0.0 and source.size() > 0
        int source_size   
= array.size(source)
        
int source_size_1 source_size 1
        
array<floatest  = array.new<float>(source_size)
        for 
int i 0 to source_size_1
            float sum  
0.0
            float sumw 
0.0
            
for int j 0 to source_size_1
                float weight 
=  sinc(jlength_1)
                
sum  += weight * array.get(sourcej)
                
sumw += weight
            float current_price 
sum sumw
            
array.set(esticurrent_price >= 0.0 current_price 0.0)
        
est
    
else
        
source

monte_carlo_distribution
(series move moves,
                         
series float seed,
                         
simple int   bins,
                         
simple int  steps,
                         
simple int   sims) =>
    array< 
int distribution = array.new< int >(bins 10)
    array<
floatsim_outcomes = array.new<float>()
    var 
int sims_1  sims 1
    float sum_stdev 
0.0
    float    reseed 
seed
    
for int i 0 to sims_1
        
[simulationseed_sim] = sim(movesreseedsteps)
        
reseed    := seed_sim
        sum_stdev 
+= math.pow(simulation open2)
        
sim_outcomes.push(simulation)
    
float sim_lowest  sim_outcomes.min()
    
float sim_highest sim_outcomes.max()
    
float bin_width   = (sim_highest sim_lowest) / bins
    float avg_idx_up  
0.0
    float sum_idx_up  
0.0
    float avg_idx_dn  
0.0
    float sum_idx_dn  
0.0
    
for int i 0 to sim_outcomes.size() - 1
        float outcome 
sim_outcomes.get(i)
        
int idx int((outcome sim_lowest) / bin_width)
        if 
outcome open
            avg_idx_up 
+= idx
            sum_idx_up 
+= 1
        
else
            
avg_idx_dn += idx
            sum_idx_dn 
+= 1
        distribution
.add(idx)
    
float avg_up   avg_idx_up   sum_idx_up
    float avg_dn 
avg_idx_dn sum_idx_dn
    float stdev    
math.sqrt(sum_stdev sims)
    [
distributionbin_widthsim_lowestsim_highestavg_upavg_dnstdevreseed]

draw_distribution(series move           moves,
                  
series float           seed,
                  
series bool     orientation,
                  
simple int             bins,
                  
simple int            steps,
                  
simple int      simulations,
                  
simple int            scale,
                  
simple bool        avg_move,
                  
simple float      deviation,
                  
simple bool    enable_stdev,
                  
simple bool     enable_bias,
                  
simple bool      background,
                  
simple color max_bear_color,
                  
simple color min_bear_color,
                  
simple color max_bull_color,
                  
simple color min_bull_color,
                  
simple color dev_high_color,
                  
simple color  dev_low_color,
                  
simple color     text_color,
                  
simple bool    extend_lines,
                  
simple bool     outcomes_on,
                  
simple bool    text_on_dist,
                  
simple string  move_help_on,
                  
simple bool    max_expected,
                  
simple float      smoothing,
                  
simple bool      start_line,
                  
simple color    start_color) =>
    var array< 
box>     dist = array.new< box>()
    var array<
lineavg_line = array.new<line>()
    var 
string    xtend_line extend_lines extend.left extend.none
    
const color    invisible #00000000
    
int offset    steps
    int direction 
orientation : -1
    int position  
orientation offset
    int width     
= (scale offset) * direction
    
[_montebin_widthlowest_simhighest_simavg_idx_upavg_idx_downstdev_seed] = monte_carlo_distribution(movesseedbinsstepssimulations)
    array<
floatmonte sinc_filter(_montesmoothing)
    
float max_freq  monte.max()
    
float half_bin  bin_width 0.5
    float variation 
stdev deviation
    float dev_up    
=               open variation
    float dev_down  
math.max(0.0open variation)
    
float avg_up    avg_idx_up   bin_width lowest_sim
    float avg_down  
avg_idx_down bin_width lowest_sim
    
if avg_line.size() > 0
        
for int i avg_line.size() - 1 to 0
            avg_line
.get(i).delete()
            
avg_line.remove(i)
    if 
dist.size() > 
        
for int i dist.size() - 1 to 0
            dist
.get(i).delete()
            
dist.remove(i)
    
int x2 outcomes_on ?  width bar_index :
             
orientation offset bar_index :
                               -
bar_index
    
if max_expected
        float expected       
monte.indexof(max_freq) * bin_width lowest_sim
        color expected_color 
expected open min_bull_color min_bear_color
        
//avg_line.push(line.new(bar_index + position, expected, x2, expected, color=expected_color, style=line.style_solid,  extend=xtend_line, width=2))

    
if enable_stdev
        
//avg_line.push(line.new(bar_index + position, dev_up,   x2, dev_up,   color=dev_high_color, style=line.style_dotted, extend=xtend_line, width=2))
        //avg_line.push(line.new(bar_index + position, dev_down, x2, dev_down, color=dev_low_color,  style=line.style_dotted, extend=xtend_line, width=2))
        
if   move_help_on == "Deviation Range"
          
or move_help_on == "Both"
            
avg_line.push(line.new(bar_indexopenbar_index offsetdev_up,   color=dev_high_colorstyle=line.style_arrow_right))
            
avg_line.push(line.new(bar_indexopenbar_index offsetdev_downcolor=dev_low_color,  style=line.style_arrow_right))
    if 
avg_move
        
//avg_line.push(line.new(bar_index + position, avg_up,   x2, avg_up,   color=min_bull_color, style=line.style_dashed, extend=xtend_line, width=2))
        //avg_line.push(line.new(bar_index + position, avg_down, x2, avg_down, color=min_bear_color, style=line.style_dashed, extend=xtend_line, width=2))
        
if   move_help_on == "Expected"
          
or move_help_on == "Both"
            
avg_line.push(line.new(bar_indexopenbar_index offsetavg_up,   color=min_bull_colorstyle=line.style_arrow_right))
            
avg_line.push(line.new(bar_indexopenbar_index offsetavg_downcolor=min_bear_colorstyle=line.style_arrow_right))
    if 
start_line
        avg_line
.push(line.new(bar_index positionopenx2opencolor=start_colorextend=xtend_line))
    
float polarity 0.0
    float monte_sum 
monte.sum()
    for 
int i 0 to monte.size() - 1
        float top    
= (i) * bin_width lowest_sim half_bin
        float bottom 
=      i  bin_width lowest_sim half_bin
        float center 
math.avg(topbottom)
        
int   value  monte.normal_value(iscale)
        
float prob   monte.probability(imonte_sum
        if 
center open
            polarity 
+= prob
        color grad_color 
= if center >= open
            float upper 
highest_sim half_bin
            color
.from_gradient(centeropenuppermin_bull_colormax_bull_color)
        else
            
float lower lowest_sim bin_width 0.5
            color
.from_gradient(centerloweropenmax_bear_colormin_bear_color)
        if 
prob 0.0 and outcomes_on
            int left   
bar_index + (value offset) * direction
            string txt 
text_on_dist str.tostring(math.round(prob2)) + "%" ""
            
dist.push(box.new(lefttopbar_index widthbottomtext=txtborder_color=invisiblebgcolor=grad_colortext_color=text_color))
        if 
background
            int left  
bar_index position
            int right 
outcomes_on ? (value offset) * direction bar_index :
                                              
orientation offset bar_index :
                                                               -
1  bar_index
            
var string ext extend_lines ? (orientation extend.left extend.right) : extend.none
            color bg_color 
color.from_gradient(monte.get(i), 0.0max_freqcolor.new(grad_color99), color.new(grad_color75))
            
dist.push(box.new(lefttoprightbottominvisiblebgcolor=bg_colorextend=ext))
    if 
enable_bias
        int left     
outcomes_on ?  width bar_index :
                       
orientation offset bar_index :
                                         -
bar_index
        int right    
left direction
        float bottom 
lowest_sim half_bin
        float div    
= (highest_sim half_bin - (lowest_sim half_bin)) * (polarity 100.0)
        
dist.push(box.new(lefthighest_sim half_binrightdiv bottomborder_color=invisiblebgcolor=min_bull_colortext="🢁\n\n" str.tostring(math.round(100.0 polarity2)) + "%"text_color=text_color))
        
dist.push(box.new(left,      bottom div,      right,       bottomborder_color=invisiblebgcolor=min_bear_colortext=str.tostring(math.round(        polarity2)) + "%" "\n\n🢃"text_color=text_color))
    
_seed



string source 
input.string("Candle""Derivative Source"options=["Candle""Move"], tooltip="Candle uses the difference between Close and Open. Move uses the difference between the current close and the previous close.")

string controls "Primary Controls"
int simulations input.int  500"Number of Simulations"group=controlsminval50step=  50tooltip="This adjusts the number of simulations the indicator will preform. A larger number is alway preferable but isn't always feasible. The larger the number the more accurate the indicator will be.")
int    lookback input.int  500,              "Lookback"group=controlsminval50step=  50tooltip="This determines the number of historical candles to take into account. A larger number will allow for more detail in the simulation but will also make it less relevant.")
int       steps input.int  (  10,     "Steps Into Future"group=controlsminval=  2step=   1tooltip="This determines the number of steps into the future to predict. The further into the future you go, the more resources it will utilize. potentially resulting in the indicator not loading.")
int        bins input.int  (  10,   "Outcome Granularity"group=controlsminval10step=   5tooltip="This is the number of rows in the final distribution of simulations. This determines the granularity of the final result.")
float smoothing input.float(1.75,     "Outcome Smoothing"group=controlsminval=0.0step=0.25tooltip="Smooth the distribution of the outcomes. When its set to 0 it will not apply smoothing.")
int granularity input.int  (  25,   "Returns Granularity"group=controlsminval=  5step=   5tooltip="This adjusts the granularity of the distribution of price movements. A larger number can be more accurate but it will sacrifice loading time.")

string  adjustments "Additional Adjustments"
int    drift_length input.int   (           34,             "Drift"group=adjustmentsinline="drift"minval=0)
string  drift_style input.string(   "Linear Regression",            "Style:"group=adjustmentsinline="drift"options=["Linear Regression""Standard""None"], tooltip="Drift adds trend to the simulation. Without drift, the simulation will assume a trendless market. Linear Regression uses linear regression to determine trend while Standard Drift uses a volatility degraded average return.\n\nBoth are excellent options and are generally very similar. Set this to 0 to use the same window size as the lookback. A shorter period will use the short term trend while a longer period will use a longer term trend.")
bool volatility_adj input.bool  (         true"Volatility Adjust"group=adjustments,            tooltip="Adjust the simulation to include the current volatility of returns. This will prevent the simulation from underestimating the variance in movements.")
bool   return_style input.string("Log Returns",     "Returns Style"group=adjustmentsoptions=["Percent""Log Returns"], tooltip="Percent uses % change for the calculations while Log Returns uses log returns for the calculations.") == "Percent"
int       precision input.int   (            1,         "Precision"group=adjustments,  minval=1tooltip="Precision lets you adjust the level of rounding for the price movements. A smaller number will be faster but it will sacrifice accuracy.")
bool wait_for_steps input.bool  (        true,  "Update Every Bar"group=adjustments,            tooltip="Enable this to update the prediction on every bar.")

string      visuals "Visual Preferences"
bool    orientation input.string("Right",         "Side of Chart"group=visualsoptions=["Right""Left"], tooltip="Choose which side of the chart you want the indicator on.") == "Right"
string move_help_on input.string"Both",    "Move Visualization"group=visualsoptions=["Expected""Deviation Range""Both""None"])
bool       avg_move input.bool  (   true,      "Most Likely Move"group=visualstooltip="This plots the most likely up and down move for the current estimation period. These may be used as targets for your trade.")
bool   enable_stdev input.bool  (   true,    "Standard Deviation"group=visuals,  inline="stdev")
float     deviation input.float (    1.0,                      ""group=visuals,  inline="stdev"minval=0.0step=0.5tooltip="This is the range in which most of the simulations fall between. It acts as a prediction level for a  volatile move.")
bool    enable_bias input.bool  (   true"Most Likely Direction"group=visualstooltip="This shows you the sum of up and down probabilities. It allows you to quickly see what the likelihood of a move in either direction is.")
bool   max_expected input.bool  (   true,  "Max Probability Zone"group=visualstooltip="This highlights the area with the largest outcome probability.")
bool    outcomes_on input.bool  (   false,  "Outcome Distribution"group=visuals,  inline="dist")
int           scale input.int   (     10,                      ""group=visuals,  inline="dist"minval=10tooltip="Enable to display the distribution of outcomes. Adjust this changes the horizontal length of the distribution.")
bool   text_on_dist input.bool  (   false,     "Distribution Text"group=visualstooltip="Enable outcome probabilities to be show in the distribution.")
bool     background input.bool  (   false,            "Background"group=visualstooltip="Display a background of the distribution for the duration of the prediction interval.")
bool     start_line input.bool  (   false,         "Starting Line"group=visualstooltip="Show the starting point of the simulation.")
bool   extend_lines input.bool  (   false,          "Extend Lines"group=visualstooltip="Extend the lines and background.")

string      coloring "Color Preferences"
color max_bear_color input.color(#FFA0CC,     "Bearish Colors     ", group=coloring, inline="bear")
color min_bear_color input.color(#FF22CC,                        "", group=coloring, inline="bear")
color max_bull_color input.color(#00FFFF,    "Bullish Colors      ", group=coloring, inline="bull")
color min_bull_color input.color(#0066FF,                        "", group=coloring, inline="bull")
color dev_high_color input.color(#FFB617, "Deviation Color - High:", group=coloring, inline="dev" )
color dev_low_color  input.color(#2672ff,                    "Low:", group=coloring, inline="dev" )
color start_color    input.color(#7E7E7E,        "Start Line Color", group=coloring)
color text_color     input.color(#FFFFFF,              "Text Color", group=coloring)



move rand_moves moves(precisiongranularitylookbackdrift_styledrift_lengthsourcereturn_stylestepsvolatility_adj)
var 
float seed 1
[_re_seed] = prng(seed)
seed := re_seed

if barstate.islast 
    
var int counter = -1
    
if counter == -1
        int bar_index_1 
bar_index 1
        
if bar_index_1 lookback
            runtime
.error('Please use a "Lookback" input setting that is less than: ' str.tostring(bar_index))
        if 
bar_index_1 drift_length
            runtime
.error('Please use a "Drift" input setting that is less than: '    str.tostring(bar_index))
    
counter += 1
    bool once 
counter == true barstate.isconfirmed
    bool wait 
not wait_for_steps == counter steps and once :
                                     
== counter or barstate.isconfirmed
    
if wait
        seed 
:=  draw_distribution(rand_movesseedorientationbinsstepssimulationsscaleavg_movedeviationenable_stdevenable_bias,
                                   
backgroundmax_bear_colormin_bear_colormax_bull_colormin_bull_colordev_high_colordev_low_colortext_color,
                                   
extend_linesoutcomes_ontext_on_distmove_help_onmax_expectedsmoothingstart_linestart_color)
                                   
/////////////////////////////////
//@version=5

// Inputs
input(2title='Key Vaule. \'This changes the sensitivity\'')
input(10title='ATR Period')
input(truetitle='Signals from Heikin Ashi Candles')

xATR ta.atr(c)
nLoss xATR

src 
request.security(ticker.heikinashi(syminfo.tickerid), timeframe.periodcloselookahead=barmerge.lookahead_off) : close

xATRTrailingStop 
0.0
iff_1 
src nz(xATRTrailingStop[1], 0) ? src nLoss src nLoss
iff_2 
src nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src nLoss) : iff_1
xATRTrailingStop 
:= src nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src nLoss) : iff_2

pos 
0
iff_3 
src[1] > nz(xATRTrailingStop[1], 0) and src nz(xATRTrailingStop[1], 0) ? -nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src nz(xATRTrailingStop[1], 0) ? iff_3

xcolor 
pos == -color.red pos == color.green color.blue

ema 
ta.ema(src1)
above ta.crossover(emaxATRTrailingStop)
below ta.crossover(xATRTrailingStopema)

buy src xATRTrailingStop and above
sell 
src xATRTrailingStop and below

barbuy 
src xATRTrailingStop
barsell 
src xATRTrailingStop

plotshape
(buytitle='Buy'text='L'style=shape.labeluplocation=location.belowbarcolor=color.new(color.green0), textcolor=color.new(color.white0), size=size.tiny)
plotshape(selltitle='Sell'text='S'style=shape.labeldownlocation=location.abovebarcolor=color.new(color.red0), textcolor=color.new(color.white0), size=size.tiny)

////////
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Seckin42

//@version=5
source99 close
windowsize 
input(title="Window Size"defval=25)
offset input.float(title="Offset"defval=0.85)
sigma input.float(title="Sigma"defval=6)
plot(ta.alma(source99windowsizeoffsetsigma))

atrPeriod input.int(10,    "ATR Length"minval 1)
factor =    input.float(3.0"Factor",     minval 0.01step 0.01)

[
supertrenddirection] = ta.supertrend(factoratrPeriod)

supertrend := barstate.isfirst na supertrend
upTrend 
=    plot(direction supertrend na"Up Trend",   color color.greenstyle plot.style_linebr)
downTrend =  plot(direction na supertrend"Down Trend"color color.red,   style plot.style_linebr)
bodyMiddle plot(barstate.isfirst na : (open close) / 2"Body Middle",display display.none)
//////
//@version=5
// Dr. Abhiram's Golden Strategy //@version=5
// srflip2011

// --- inputs
source55 close
TITLE 
input(falsetitle='Turn on Alerts & Enable Background Color options are based on EMA1 & EMA2 Crossovers, (This button does nothing)')
turnon2 input(truetitle='Turn on Alerts?')
colorbars  input(truetitle "Color Bars?")
colorbars2 input(true,title "Color Bar when price closes under / above Ema 1 & 2?" inline "1")
barc1 input (color.rgb(017255), "+"inline "1")
barc2 input(color.rgb(2124248), "-"inline ="1")
turnon input(truetitle='Turn on Ema 1 & 2?')
//backgroundcolor = input(false, title='Enable Background Color?')

//Ema 1 & 2
len1 input.int(10minval=1title='EMA1')
len2 input.int(21minval=1title='EMA2')
ema1 ta.ema(source55len1)
ema2 ta.ema(source55len2)
//---

cond1 ta.crossover(close,ema1) and ta.crossover(close,ema2)
cond2 ta.crossunder(close,ema1) and ta.crossunder(close,ema2)

barcolor(cond1 color.rgb(017255) : cond2 color.rgb(2124248): na)
//-- Candle Color
colbar ema1 ema2 color.rgb(1525023) :  color.rgb(25500
barcolor(colorbars colbar :na)


// Ema Cross 
mylong ta.crossover(ema1ema2)
myshort ta.crossunder(ema1ema2)

first ta.ema(closelen1)
sec ta.ema(closelen2)

// Calculations
last_long float(na)
last_short float(na)
last_long := mylong time nz(last_long[1])
last_short := myshort time nz(last_short[1])

in_long last_long last_short 0
in_short 
last_short last_long 0

condlongx 
in_long
condlong 
ta.crossover(condlongx1.9)
condlongclose ta.crossunder(condlongx1.9)

condshortx in_short
condshort 
ta.crossover(condshortx1.9)
condshortclose ta.crossover(condshortx1.9)

// Color Fill
fcolor first sec #0aff68 : first < sec ? #ff0a5a : #cccccc

// Plots
plotshape(turnon2 condlong natitle='Breakout'color=color.new(#112f16, 0), location=location.belowbar, style=shape.labelup, text='L', textcolor=color.new(color.white, 0), size=size.small, offset=1)
plotshape(turnon2 condshort natitle='Breakdown'color=color.new(#9d0d0d, 0), style=shape.labeldown, text='S', textcolor=color.new(color.white, 0), size=size.small, offset=1)

///// 
selamlar....