Reputation: 619
I would like to create some strategy based on Moving Average, However when I converted base MA indicator to strategy, overlay not working and MA is ploting on another plot area. Any idea ?
//@version=4
strategy(title="MAStrategy", shorttitle="MyMA Strategy_0.01", format=format.price, initial_capital=1000, overlay=true)
lenShort = input(9, minval=1, title="LengthShort")
srcShort = input(close, title="SourceShort")
offsetShort = input(title="OffsetShort", type=input.integer, defval=0, minval=-500, maxval=500)
outShort = sma(srcShort, lenShort)
plot(outShort, color=color.green, title="MA_Short", offset=offsetShort)
Upvotes: 1
Views: 846
Reputation: 8789
The code you showed will load fine as an overlay when you add it to the chart. What probably happened is that you loaded a non-overlay piece of code, added the overlay = true
and then only saved the script. When you change an indicator's location in your study()
call, you need to re-add the script to the chart for the change to happen.
Upvotes: 1