JP977

Strategia TUN V 0.1

22
Test Strategy
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?
//@version=2
study("Strategia", overlay = true)

// CM_DI_Plus_Minus_V1 e CM_ADX_V1 ***************************
len = input(14, minval=1, title="DI Length")
lensig = input(14, title="ADX Smoothing", minval=1, maxval=50)
up = change(high)
down = -change(low)
trur = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / trur)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / trur)
sum = plus + minus
DI = plus > minus ? 1 : -1   //IMPORTANT
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 10 : sum), lensig) //IMPORTANT restituisce il valore dell'adx
adx_check = (adx[0]>adx[1]) and (adx[1] < 20) and (adx[0] >= 20) ? 1 : -1 //IMPORTANT controlla se adx ha appena superato 20
//************************************************************

// Supertrend ************************************************
Factor=input(3, minval=1,maxval = 100, title="Supertrend Factor")
Pd=input(7, minval=1,maxval = 100,title="Supertrend Pd")
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1) //IMPORTANTE indica la direzione del trend
//************************************************************

// MACD ******************************************************
fast = input(5, minval=1, title="MACD Fast") 
slow = input(35, minval=1, title="MACD Fast") 
smoothing = input(5, minval=1, title="MACD Signal Smoothing") 
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, smoothing)
//************************************************************


Uptrend = (Trend == 1) and (adx_check == 1) and (DI == 1) and (macd > 0) and (macd > signal) ? 1 : 0 // Se tutti i controlli sono positivi allora Uptrend è uguale a 1 altrimenti è 0
Downtrend = (Trend ==-1) and (adx_check == 1) and (DI == -1) and (macd < 0) and (signal > macd) ? 1 : 0 // Se tutti i controlli sono positivi allora Downtrend è uguale a 1 altrimenti è 0


// Visualizzazione
Valore = (Uptrend==1 and Downtrend==0) ? 2 : (Uptrend==0 and Downtrend==1) ? 1 : 0 
Colore = (Uptrend==1 and Downtrend==0) ? green : (Uptrend==0 and Downtrend==1) ? red : white   
plotshape(Valore, style=shape.circle, location=location.bottom, color=Colore)