JayRogers

High-Low Difference Channels - SMA/EMA

JayRogers تم تحديثه   
I wrote this up as a potential replacement for my BB based strategies, and so far it's looking pretty nice.

Description / Usage:
  • Adjust length and multiplier much the same way you would expect with Bollinger Bands.
  • Multiplier of 1 gives you a base channel consisting of one high, and one low sourced SMA (or EMA)
  • The outer channels are increments of the base channels width, away from the median hl2 sourced SMA (..or EMA)
تعليق:
New revision here, with more MA options than you can shake a stick at:
تعليق:
Final revision done.

Added (optional) select-able fixed resolutions, so you can have 1 hour bands on your 1 minute chart if you do so feel inclined.

Otherwise just some minor code cleaning and proper commenting:
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟
//@version=2

study(title="High-Low Difference Channels - SMA/EMA", shorttitle="HLDC", overlay=true)

// Revision:    1
// Author:      JayRogers
// Reasoning:   I wrote this up as a potential replacement for my BB based strategies, and so far it's
//              looking pretty nifty.
//
// Description / Usage:
//
//  - Adjust length and multiplier much the same way you would expect with Bollinger Bands.
//  - multiplier of 1 gives you a base channel consisting of one high, and one low sourced SMA (or EMA)
//  - The outer channels are increments of the base channels width, away from the median hl2 sourced SMA (..or EMA)

hlc_length      = input(50, title="Channel Length", minval=1)
hlc_diffMult    = input(1.5, title="Difference Multiplier", minval=0.1, maxval=50)
hlc_useEMA      = input(false, title="Use EMA instead of SMA?")

hl2_line    = hlc_useEMA ? ema(hl2, hlc_length) : sma(hl2, hlc_length)
high_line   = hlc_useEMA ? ema(high, hlc_length) : sma(high, hlc_length)
low_line    = hlc_useEMA ? ema(low, hlc_length) : sma(low, hlc_length)

diffMult(num) =>
    hldm = (high_line - low_line) * hlc_diffMult
    r = hldm * num

midline     = plot(hl2_line, title="Midline", color=silver, transp=0)

highLine    = plot(hl2_line + (diffMult(1) / 2), title="Center Channel Upper", color=silver, transp=100)
lowLine     = plot(hl2_line - (diffMult(1) / 2), title="Center Channel Lower", color=silver, transp=100)

diffUp1     = plot(hl2_line + diffMult(1), title="High Diff 1", color=silver, transp=0)
diffUp2     = plot(hl2_line + diffMult(2), title="High Diff 2", color=silver, transp=0)
diffUp3     = plot(hl2_line + diffMult(3), title="High Diff 3", color=silver, transp=0)

diffDown1   = plot(hl2_line - diffMult(1), title="Low Diff 1", color=silver, transp=0)
diffDown2   = plot(hl2_line - diffMult(2), title="Low Diff 2", color=silver, transp=0)
diffDown3   = plot(hl2_line - diffMult(3), title="Low Diff 3", color=silver, transp=0)

fill(highLine, lowLine, title="Center High-Low Fill", color=silver, transp=50)