Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pine script 补偿交叉策略问题_Pine Script - Fatal编程技术网

Pine script 补偿交叉策略问题

Pine script 补偿交叉策略问题,pine-script,Pine Script,正如你所见,我制作了2个船体,长度均为75。对于蓝色的,我偏移到-10。如何从2 MA的交叉点创建策略? 我的问题是偏移量只是改变了图,所以如果我尝试交叉(hullma,hullma1),什么都不会发生,因为tradingview认为这些线是相同的。 那么,是否有任何改变,以左移动10条指标和设置一个交叉策略? 谢谢 使用负偏移意味着将当前数据偏移到过去,并且您将无法确定活蜡烛上的十字架,只有延迟等于偏移值 这将使得不可能在发生交叉的同一时刻创建交叉信号,但您可以使用该信号对历史蜡烛进行分析 请

正如你所见,我制作了2个船体,长度均为75。对于蓝色的,我偏移到-10。如何从2 MA的交叉点创建策略? 我的问题是偏移量只是改变了图,所以如果我尝试交叉(hullma,hullma1),什么都不会发生,因为tradingview认为这些线是相同的。 那么,是否有任何改变,以左移动10条指标和设置一个交叉策略? 谢谢


使用负偏移意味着将当前数据偏移到过去,并且您将无法确定活蜡烛上的十字架,只有延迟等于偏移值

这将使得不可能在发生交叉的同一时刻创建交叉信号,但您可以使用该信号对历史蜡烛进行分析

请注意,在最后10支(等于偏移值)蜡烛期间,您将无法发现十字架

//@version=4
study(title="HMA Cross the Offset HMA", overlay=true)

length = input(75, minval=1)
src = input(close, title="Source")
hullMa = wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))

// Current Hull Moving Average
plot(hullMa, color = color.red)

// Hull Moving Average with a negative offset
plot(hullMa, color = color.blue, offset = -10)

float hullMaWithOffset = nz(hullMa[10])

bool cross = cross(hullMa, hullMaWithOffset)

// Mark Cross with Background color
// To spot the exact bar with a crossover we should use the equal offset value
bgcolor(cross? color.orange : na, offset = -10)