pine-script - 四舍五入到刻度精度有什么好处
问题描述
我close
将下面代码段中的值用于多种目的。
与以下代码无关的两个示例:
ema = ema(close, 200)
. 如果我使用rounded close
代替有真正的好处close
吗?我听说它在外汇中最有用。close > ema
. 这里怎么样?
圆形刻度精度的真正好处是什么?
说到它,我可以用它的圆形版本替换每个close
, open
, high
,用法吗?low
f_roundedToTickOHLC()
// ————— Functions rounding OHLC to tick precision
f_roundedToTickOHLC() =>
float _op = round(open / syminfo.mintick) * syminfo.mintick
float _hi = round(high / syminfo.mintick) * syminfo.mintick
float _lo = round(low / syminfo.mintick) * syminfo.mintick
float _cl = round(close / syminfo.mintick) * syminfo.mintick
[_op, _hi, _lo, _cl]
// ————— Get rounded prices
[rOpen, rHigh, rLow, rClose] = f_roundedToTickOHLC()
// ————— Pullback
ema = ema(close, i_emaPullback)
// ————— TV built-in MACD code
fastLength = 12
slowlength = 26
MACDLength = 9
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
// ————— Filter
filterLong = MACD > 0
filterShort = MACD < 0
// ————— States
var float entryPrice = na
var bool inLong = false
var bool inShort = false
bool inTrade = inLong or inShort
// ————— Entries
enterLong = doLongs and not inTrade and crossover(MACD, 0)
enterShort = doShorts and not inTrade and crossunder(MACD, 0)
// ————— Stops
atr = atr(14)
stopLong = min(lowest(5), min(close, open) - atr * 1.5)
stopShort = max(highest(5), max(close, open) + atr * 1.5)
// ————— Exits
exitLong = inLong and ((crossunder(MACD, aMACD) and MACD > 0) or close < stopLong[1])
exitShort = inShort and ((crossover(MACD, aMACD) and MACD < 0) or close > stopShort[1])
if enterLong
inLong := true
entryPrice := close
else if enterShort
inShort := true
entryPrice := close
else if exitLong
inLong := false
entryPrice := na
else if exitShort
inShort := false
entryPrice := na
解决方案
推荐阅读
- computer-vision - 计算机视觉
- python - 通过拆分计算列表python中的总数
- java - 如何在标记自定义信息窗口上刷新 ImageView
- javascript - 如何制作客户端指纹javascript
- ios - 通过滑动而不是点击选择的 UITableViewCell
- python - MainWindow 不会同时处理事件和用户操作
- facebook - Facebook Graph APi 不回馈页面本身所写的评论
- javascript - 单击@Html.Checkboxfor时如何向控制器提交数据
- python - 将 txt 解析为块
- c# - 如何通过实体框架在 C# 中的表值函数中循环值?