pine-script - 如何使退出信号打印低于先前的进入信号?(Pine Script 交易视图 PineScript 交易视图)
问题描述
如果 Exit 信号小于 Entry,则保持到下一个 Exit 信号。我不想打印退出信号,除非它有利润。有人可以教我如何用我的脚本实现这一目标吗?
我试图说 longentry 必须是 < longexit 但这是错误...“无法使用 'expr2'=series[bool] 调用 'operator >'。参数的类型应为:float”
这是代码的一部分。
//Long ◄◄◄
emalong = out1 > out2
macdlong = macd > signal and ((macd[1] < signal[1]) or (macd[2] < signal[2]))
histlong = hist > hist[1] and hist[1] < hist[2]
psarlong = psar < close and ((psar[1] > close[1]) or (psar[2] > close[2]))
//Short ◄◄◄
emashort = out1 < out2
macdshort = macd < signal and ((macd[1] > signal[1]) or (macd[2] > signal[2]))
histshort = hist < hist[1] and hist[1] > hist[2]
psarshort = psar > close and ((psar[1] < close[1]) or (psar[2] < close[2]))
//Collect Signals ◄◄◄
longentry = emalong and macdlong and psarlong
longexit = histshort
shortentry = emashort and macdshort and psarshort
shortexit = histlong[enter image description here][1]
//Position of Signals ◄◄◄
var pos = 0
if longentry and pos <= 0
pos := 1
if longexit and pos == 1
pos := 2
if shortentry and pos >= 0
pos := -1
if shortexit and pos == -1
pos := -2
longensignal = pos == 1 and (pos != 1)[1]
longexsignal = pos == 2 and (pos != 2)[1]
shortensignal = pos == -1 and (pos != -1)[1]
shortexsignal = pos == -2 and (pos != -2)[1]
//Shapes ◄◄◄
plotshape(longensignal, style=shape.circle, color=#26a69a, text="LEN",
textcolor=#ffffff, location=location.belowbar, size=size.tiny)
plotshape(longexsignal, style=shape.xcross, color=#26a69a, text="LEX",
textcolor=#ffffff, location=location.abovebar, size=size.tiny)
plotshape(shortensignal, style=shape.circle, color=#ef5350, text="SEN",
textcolor=#ffffff, location=location.abovebar, size=size.tiny)
plotshape(shortexsignal, style=shape.xcross, color=#ef5350, text="SEX",
textcolor=#ffffff, location=location.belowbar, size=size.tiny)
再次......我不想打印“LEX”,除非它大于“LEN”,我不想打印“SEX”,除非它小于“SEN”。
解决方案
推荐阅读
- python - 如何正确声明函数之外的变量,以便迷你文本冒险中的 test() 运行
- android - 进行应用内购买时出现空点异常
- rust - 为什么即使我没有设置 default-features = false,rand::Rng 也能在无标准环境中工作?
- angular - 元素改变时的事件
- sql-server - 如何将 Pivot 与 RowNumber 和日期一起使用
- python - 如何在 python 中打印“动态/收敛”数组
- electron - 包含子进程中使用的exe
- html - 如何修复导航栏和第一个标题的重叠?
- php - Sentrifugo - PHP 无法正确显示 Unicode(越南语)
- r - how to count the number of rows of specific column that has specific character