pine script to matriks
Budget: $10 – $30 USD
//@version=4
study("NEYHA",overlay=true)
calc_HighLow = (( high - low ) * 100)
calc_Volume = (volume / calc_HighLow)
calc_OpenClose = (( close - open ) * 100)
Volume_Spread = (calc_OpenClose * calc_Volume)
Price_Spread = stdev(high - low, 30)
vp = Volume_Spread + cum(Volume_Spread)
smooth = sma(vp, 15)
shadow = (vp - smooth) / stdev(vp - smooth, 30) * Price_Spread
out = shadow > 0 ? high + shadow : low + shadow
// INPUTS //
Multiplier = input( 1, title = 'Multiplier', minval = 0, maxval = 100, step = 0.01)
Period = input(10, title = 'Period', minval = 1)
// Trend Hesaplaması //
Trend_Up = ema(out,10) - (Multiplier * atr(Period))
Trend_Down = ema(out,10) + (Multiplier * atr(Period))
Factor = input(title="Factor", defval = 0.05, minval = 0.01, maxval = 5, step = 0.01, type = input.float) // Trend çarpanı
// =============== Variables =================== /
// En yüksek
Highest_Trend = 0.00 , Highest_Trend := nz(Highest_Trend[1]) // En yüksek trend seviyesi - Bunu trend çizgisini çizebilmek için kullanıyor.
Highest_Close = 0.000, Highest_Close := nz(Highest_Close[1]) // En yüksek close
// En düşük
Lowest_Trend = 0.00 , Lowest_Trend := nz(Lowest_Trend[1]) // En düşük trend seviyesi - Bunu trend çizgisini çizebilmek için kullanıyor.
Lowest_Close = 0.000, Lowest_Close := nz(Lowest_Close[1]) // En düşük close
// Mum kapanışını sayıyor. Yani her yeni mum kapanışı gerçekleşinde + 1 oluyor
// * İndikatör eklendiğinden beri, yani trend değişiminde sıfırlanmıyor.
new_Candle = 0, new_Candle := nz(new_Candle[1]) + 1
// Trend Control
Trend = 0, Trend := nz(Trend[1])
// ============================================= /
if barstate.isfirst
new_Candle := 0
Lowest_Trend := Trend_Down
Highest_Trend := Trend_Up
Lowest_Close := close
Highest_Close := close
Highest_Close
if new_Candle == 1
if Trend_Up >= Highest_Trend[1]
Highest_Trend := Trend_Up
Highest_Close := close
Trend := 1
Trend
else
Lowest_Trend := Trend_Down
Lowest_Close := close
Trend := -1
Trend
if new_Candle > 1
if Trend[1] > 0
Highest_Close := max(Highest_Close[1], close)
if Trend_Up >= Highest_Trend[1]
Highest_Trend := Trend_Up
Highest_Trend
else
if Trend_Down < Highest_Trend[1] - Highest_Trend[1] * Factor
Lowest_Trend := Trend_Down
Lowest_Close := close
Trend := -1
Trend
else
Lowest_Close := min(Lowest_Close[1], close )
if Trend_Down <= Lowest_Trend[1]
Lowest_Trend := Trend_Down
Lowest_Trend
else
if Trend_Up > Lowest_Trend[1] + Lowest_Trend[1] * Factor
Highest_Trend := Trend_Up
Highest_Close := close
Trend := 1
Trend
plot(Trend == 1 ? Highest_Trend : Trend == -1 ? Lowest_Trend : na, color = Trend == 1 ? color.blue : color.yellow, style = plot.style_circles, linewidth = 1, title = "Trend", transp = 0, join = true)
//
Long = Trend == 1 and Trend[1] == -1
Short = Trend == -1 and Trend[1] == 1
//
last_long = 0.0, last_short = 0.0
last_long := Long ? time : nz(last_long[1])
last_short := Short ? time : nz(last_short[1])
buy = crossover(last_long, last_short)
sell = crossover(last_short, last_long)
/////////////// Plotting ///////////////
plotshape(buy, title="buy", text="Buy", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0) //plot for buy icon
plotshape(sell, title="sell", text="Sell", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0)
/////////////// Alerts ///////////////
alertcondition(buy, title='buy', message='Buy')
alertcondition(sell, title='sell', message='Sell')
study("NEYHA",overlay=true)
calc_HighLow = (( high - low ) * 100)
calc_Volume = (volume / calc_HighLow)
calc_OpenClose = (( close - open ) * 100)
Volume_Spread = (calc_OpenClose * calc_Volume)
Price_Spread = stdev(high - low, 30)
vp = Volume_Spread + cum(Volume_Spread)
smooth = sma(vp, 15)
shadow = (vp - smooth) / stdev(vp - smooth, 30) * Price_Spread
out = shadow > 0 ? high + shadow : low + shadow
// INPUTS //
Multiplier = input( 1, title = 'Multiplier', minval = 0, maxval = 100, step = 0.01)
Period = input(10, title = 'Period', minval = 1)
// Trend Hesaplaması //
Trend_Up = ema(out,10) - (Multiplier * atr(Period))
Trend_Down = ema(out,10) + (Multiplier * atr(Period))
Factor = input(title="Factor", defval = 0.05, minval = 0.01, maxval = 5, step = 0.01, type = input.float) // Trend çarpanı
// =============== Variables =================== /
// En yüksek
Highest_Trend = 0.00 , Highest_Trend := nz(Highest_Trend[1]) // En yüksek trend seviyesi - Bunu trend çizgisini çizebilmek için kullanıyor.
Highest_Close = 0.000, Highest_Close := nz(Highest_Close[1]) // En yüksek close
// En düşük
Lowest_Trend = 0.00 , Lowest_Trend := nz(Lowest_Trend[1]) // En düşük trend seviyesi - Bunu trend çizgisini çizebilmek için kullanıyor.
Lowest_Close = 0.000, Lowest_Close := nz(Lowest_Close[1]) // En düşük close
// Mum kapanışını sayıyor. Yani her yeni mum kapanışı gerçekleşinde + 1 oluyor
// * İndikatör eklendiğinden beri, yani trend değişiminde sıfırlanmıyor.
new_Candle = 0, new_Candle := nz(new_Candle[1]) + 1
// Trend Control
Trend = 0, Trend := nz(Trend[1])
// ============================================= /
if barstate.isfirst
new_Candle := 0
Lowest_Trend := Trend_Down
Highest_Trend := Trend_Up
Lowest_Close := close
Highest_Close := close
Highest_Close
if new_Candle == 1
if Trend_Up >= Highest_Trend[1]
Highest_Trend := Trend_Up
Highest_Close := close
Trend := 1
Trend
else
Lowest_Trend := Trend_Down
Lowest_Close := close
Trend := -1
Trend
if new_Candle > 1
if Trend[1] > 0
Highest_Close := max(Highest_Close[1], close)
if Trend_Up >= Highest_Trend[1]
Highest_Trend := Trend_Up
Highest_Trend
else
if Trend_Down < Highest_Trend[1] - Highest_Trend[1] * Factor
Lowest_Trend := Trend_Down
Lowest_Close := close
Trend := -1
Trend
else
Lowest_Close := min(Lowest_Close[1], close )
if Trend_Down <= Lowest_Trend[1]
Lowest_Trend := Trend_Down
Lowest_Trend
else
if Trend_Up > Lowest_Trend[1] + Lowest_Trend[1] * Factor
Highest_Trend := Trend_Up
Highest_Close := close
Trend := 1
Trend
plot(Trend == 1 ? Highest_Trend : Trend == -1 ? Lowest_Trend : na, color = Trend == 1 ? color.blue : color.yellow, style = plot.style_circles, linewidth = 1, title = "Trend", transp = 0, join = true)
//
Long = Trend == 1 and Trend[1] == -1
Short = Trend == -1 and Trend[1] == 1
//
last_long = 0.0, last_short = 0.0
last_long := Long ? time : nz(last_long[1])
last_short := Short ? time : nz(last_short[1])
buy = crossover(last_long, last_short)
sell = crossover(last_short, last_long)
/////////////// Plotting ///////////////
plotshape(buy, title="buy", text="Buy", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0) //plot for buy icon
plotshape(sell, title="sell", text="Sell", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0)
/////////////// Alerts ///////////////
alertcondition(buy, title='buy', message='Buy')
alertcondition(sell, title='sell', message='Sell')
Related categories:
Pine Script