برق، الکترونیک، الکتروتکنیک، مکاترونیک، پزشکی، کشاورزی

برق، الکترونیک، الکتروتکنیک، مکاترونیک، پزشکی، کشاورزی و

برق، الکترونیک، الکتروتکنیک، مکاترونیک، پزشکی، کشاورزی

برق، الکترونیک، الکتروتکنیک، مکاترونیک، پزشکی، کشاورزی و

داده هایی در مورد برق، الکترونیک، الکتروتکنیک، مکاترونیک، پزشکی، کشاورزی و

تبلیغات
آخرین نظرات

pine script2

ShahBaz | يكشنبه, ۹ دی ۱۳۹۷، ۱۱:۰۵ ب.ظ

//@version=3
strategy(title='MyStrategy',max_bars_back=100)

// Getting inputs
fast_length = input(title="Fast Length", type=integer, defval=5)
slow_length = input(title="Slow Length", type=integer, defval=8)
slowest_length = input(title="Slowest Length", type=integer, defval=14)
k = input(title="k-histogram", type=integer, defval=10)
//d = input(title="sl", type=float, defval=1)
//h = input(title="h", type=integer, defval=10)
//p = input(title="p", type=integer, defval=10)
src = input(title="Source", type=source, defval=close)
//i=input(title="i", type=integer, defval=0)

// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00

// Calculating
fast_ma =  sma(src, fast_length)
slow_ma =  sma(src, slow_length)


hist = (fast_ma - slow_ma)


hist2=hist*k

macd=hist2>=1?1:0

//alertcondition(macd==1, title='Alert on Green Bar', message='Green Bar!')
//i=macd==1?1:0
plot(macd, title="Histogram", style=stepline, color=col_macd, transp=0 )

 //if(month(time) > 10 and year(time) >2014)
//  if(year(time) >2017)

strategy.entry(id="Buy", long=true, when=crossover(fast_ma , slow_ma) ) //buy
//strategy.exit(id="Sell", from_entry="Long Entry", when=crossunder(fast_ma , slow_ma))     
//tp1=close[1]*(d/100)
//tp2=close-tp1
// strategy.position_avg_price
//strategy.entry(id="Short Entry", long=false, when=(macd==0)) //sell

//strategy.exit(id="Sell",profit = 50)
sell=crossover(slow_ma , fast_ma)
s=sell==true?1:0
plot(s, title="s", style=stepline, color=col_signal, transp=0 )
strategy.close("Buy", when = crossover(slow_ma , fast_ma))
//strategy.exit(id="Sell",from_entry="Buy",when=sell)



//plot(macd, title="Histogram", style=area, color=(macd>=0 ? (macd[1] < macd ? col_grow_above : col_fall_above) : (macd[1] < macd ? col_grow_below : col_fall_below) ), transp=0 )
//plot(fast_ma, title="Fast Length", color=col_macd, transp=0)
//plot(slow_ma, title="Slow Length", color=col_signal, transp=0)
//plot(slowest_ma, title="Slowest Length", color=col_grow_below, transp=0)


  • ShahBaz

نظرات  (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی