I apologize for the request to solve the trivial problem for you, but please help the newbie: 1. I want to create a moving Hull indicator with an offset - I need to implement an offset function in the indicator. 2. The crossover strategy of the “moving Hull with offset” based on a simple strategy script in a long position. If it doesn’t make it difficult for respected experienced people, I will be very grateful for my help in the analysis.
1.need to embed "//shift the step
step_shift = input(0,"Step Shift")"
//@version=4
study(title = "Hull MA", shorttitle="HMA", overlay = true)
length = input(9, minval=1)
src = input(close, title="Source")
hullma = wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))
plot(hullma)
2.insert the received indicator into this strategy script long position only
//@version=4
strategy("My strategy", overlay=true)
longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
12.01.2020. I also edited your code for a more necessary idea for checks. Now it remains to apply the correction there so that the offset works
//@version=4
strategy(title = "Hull MA", shorttitle="HMA", overlay = true)
fastLength = input(14, minval=2)
offsetfastLength = input(0)
src1 = input(close, title="Source")
slowLength = input(28, minval=2)
offsetslowLength = input(0)
src2 = input(open, title="Source")
fastHma = wma(2*wma(src1, fastLength/2)-wma(src1, fastLength), round(sqrt(fastLength)))
slowHma = wma(2*wma(src2, slowLength/2)-wma(src2, slowLength), round(sqrt(slowLength)))
longCondition = crossover(fastHma, slowHma)
closeCondition = crossunder(fastHma, slowHma)
strategy.entry("long",strategy.long,when = longCondition)
strategy.close("long",when = closeCondition)
plot(fastHma, "fastHma", color.orange, offset = offsetfastLength)
plot(slowHma, "slowHma", color.blue, offset = offsetslowLength)