Bollinger Bands Strategy Directed

Definition

"Strategy Direction" specifies what types of orders the strategy is allowed to create. If the setting value is 0, it can be both long and short. If the setting is -1 it can only short and if it’s 1 it can only go long. The Bollinger Bands Strategy Direction enters long when the symbol crosses below the lower band of the Bollinger bands and it enters short if the symbol crosses above the upper band. But remember, in the strategy settings you can adjust the direction to be only long, only short or both.

Calculations

Pine Script

//@version=4 strategy("Bollinger Bands Strategy directed", overlay=true) source = close length = input(20, minval=1) mult = input(2.0, minval=0.001, maxval=50) direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1) strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long)) basis = sma(source, length) dev = mult * stdev(source, length) upper = basis + dev lower = basis - dev if (crossover(source, lower)) strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE") else strategy.cancel(id="BBandLE") if (crossunder(source, upper)) strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE") else strategy.cancel(id="BBandSE") //plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)

Summary

The Bollinger Bands Strategy Directed was created to buy or sell when a symbol is potentially overextended from its average price. For example, the strategy can be directed to buy if a symbol falls below its lower Bollinger Band or sell if it goes above its upper Bollinger Band. Some traders might view this as mean reversion because Bollinger Bands are created using a standard deviation of a symbols average price. Remember, the strategy is directed and in the settings you can control the value i.e. if it’s 0 it will be both long and short. If the setting is -1 it can only short and if it’s 1 it can only go long. 

首頁 股票篩選器 外匯篩選器 加密貨幣篩選器 全球財經日曆 如何運作 圖表功能 價格 推薦朋友 網站規則 幫助中心 網站 & 經紀商解決方案 小工具 圖表解決方案 輕量圖表庫 部落格 & 新聞 推特
概覽 個人資料設定 賬戶和賬單 推薦朋友 代幣 我的客服工單 幫助中心 發表的想法 粉絲 正在關注 私人訊息 在線聊天 登出