I want to create a simple crossover condition where I want to have a buy sell signal on the cross over, I have tried it without resoultion, but I want it with resoultion so that I can set different timeframe for my VWMA. Here's my code, please edit it and let me know, it'd be a great help.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bhavikap141
//@version=4
strategy(title="VWMA", shorttitle="VWMA", overlay=true)
len = input(33, "Length", minval=1)
src = input(close, "Source", type = input.source)
resolution = input(title="Resolution", type=input.resolution, defval="5")
outer = vwma(src, len)
ss1 = security(syminfo.tickerid, resolution, outer, gaps=true)
mm2 = plot(ss1, color=#3A6CA8)
length = input(20, "Length", minval=1)
srce = input(close, "Source", type = input.source)
res = input(title="Resolution", type=input.resolution, defval="15")
//ma = vwma(src, len)
//offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
//plot(ma, title="VWMA", color=#3A6CA8, offset = offset)
out = vwma(srce, length)
s1 = security(syminfo.tickerid, res, out, gaps=true)
m2 = plot(s1, color=#3A6CA8)
I am not so familiar with pinescrpit so I am trying my best to add the condition, but always a bummer. So I just need a condition here in my code.
//@version=4
study(title="VWMA", shorttitle="VWMA", overlay=true)
//vwma 1
len = input(9, "Length", minval=1)
src = input(close, "Source", type = input.source)
ma = vwma(src, len)
plot(ma, title="VWMA", color=color.blue)
//vwma 2
len2 = input(20, "Length", minval=1)
src2 = input(close, "Source", type = input.source)
ma2 = vwma(src2, len2)
plot(ma2, title="VWMA", color=color.yellow)
//cond
longcondition = crossover(ma, ma2)
plotshape(longcondition, size = size.small)
//MTF
t = input("240", type = input.resolution)
ma_mtf = security(syminfo.tickerid, t, ma)
ma2_mtf = security(syminfo.tickerid, t, ma2)
plot(ma_mtf, title="VWMA MTF", color=color.red)
plot(ma2_mtf, title="VWMA MTF", color=color.aqua)
//cond MTF
longcondition_mtf = crossover(ma_mtf, ma2_mtf)
plotshape(longcondition_mtf, size = size.small, color = color.fuchsia)
Hey Edward thanks for answering the question, but the concern here is that I need the same in the form of strategy with both resolutions, and here I want a condition as well as a signal whenever buy/sell and short/cover. I am able to do the same in study format as you mentioned here, but I don't know I get stuck at the strategy part, and I want that resolution as well like I can set the time frame for both the VWMA. See if you can help me here, it'd be a huge problem saver, anyways thanks for answering once again.
I edited my answer, please check it, I added 2 VWMA for normal resolution and another 2 for MTF, with crossover conditions. I think from here you will figure it out how to change it if you need.
Thank you so much, Edward, that saves the day. Yes, that's what I exactly wanted to figure out. Once again Thanks! Really appreciate your help.
Great, you can also check the
security()
function documentation, it's very usefu and can be done a lot of things with it, like MTF as you've seen above, or accessing any symbol...