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. 

首页 股票筛选器 外汇筛选器 加密货币筛选器 财经日历 如何运作 图表功能 价格 推荐朋友 网站规则 帮助中心 网站 & 经纪商解决方案 插件 图表解决方案 轻量图表库 博客 & 新闻 Twitter
概览 个人资料设置 账户和账单 推荐朋友 代币 我的客服工单 帮助中心 已发表观点 粉丝 正在关注 私人消息 在线聊天 退出