Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
strategy(title="IMACD_LB Backtest", overlay=false)
// 計算SMMA
calc_smma(src, len) =>
//ta.sma(src, len)
var float smma = na // 定義 smma 變數
if(na(smma[1]))
smma := ta.sma(src, len)
else
smma := (smma[1] * (len - 1) + src) / len
//smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len // 更新 smma
// 計算ZLEMA
calc_zlema(src, length) =>
ema1 = ta.ema(src, length)
ema2 = ta.ema(ema1, length)
d = ema1 - ema2
ema1 + d
// 設定策略參數
lengthMA = input.int(34)
lengthSignal = input.int(9)
// 計算指標
src = hlc3
hi = calc_smma(high, lengthMA)
lo = calc_smma(low, lengthMA)
mi = calc_zlema(src, lengthMA)
md = (mi > hi) ? (mi - hi) : (mi < lo) ? (mi - lo) : 0
sb = ta.sma(md, lengthSignal)
sh = md - sb
// 設定交易條件
buy_signal = md > sb
sell_signal = md < sb
// 設定進場、出場價格
entry_price = close
exit_price = close
// 設定訂單大小
var order_size = 0.0 // 初始化 order_size 變數
if (strategy.position_size == 0)
order_size := strategy.equity * 0.9 / entry_price
else
order_size := strategy.position_size
// 設定交易策略
if (buy_signal)
strategy.entry("Buy", strategy.long, qty=order_size)
if (sell_signal)
strategy.close("Buy")
// 設定圖表顯示
plot(0, color=color.gray, linewidth=1, title="MidLine")
mdc = buy_signal ? color.green : sell_signal ? color.red : na
plot(md, color=mdc, linewidth=2, title="ImpulseMACD", style=plot.style_histogram)
plot(sh, color=color.blue, linewidth=2, title="ImpulseHisto", style=plot.style_histogram)
plot(sb, color=color.maroon, linewidth=2, title="ImpulseMACDCDSignal")
// 設定顏色
ebc = input(false, title="Enable bar colors")
barcolor(ebc ? mdc : na)
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team