need help with VWAP cross over signal

Questions about MultiCharts and user contributed studies.
fernando43611
Posts: 33
Joined: 12 Mar 2015
Has thanked: 4 times

need help with VWAP cross over signal

Postby fernando43611 » 08 Apr 2015

I've been trying to create a signal that:

1. buy when price crosses over VWAP
2. sell short when price crosses under VWAP

so far this is the code:

input:
Price(AvgPrice),
LocalHrsOffset(0),
time1(0900),
time2(0930),
time3(1129),
time4(1315),
time5(1415),
upColor(Cyan),
dnColor(Magenta);

var:
var0(0);
var0 = VWAPResettable(Price,LocalHrsOffset,time1,time2,time3,time4,time5);
plot1(var0,"vwap_reset");

var: var1(yellow);
if var0 > var0[1] then var1 = upColor;
if var0 < var0[1] then var1 = dnColor;
SetPlotColor(1,var1);


if price crosses over vwapResettable then buy this bar ;
if price crosses under vwapResettable then sellshort this bar ;

but after trying to compile the signal it shows this message and I cant figure out wheres the error (im new to multicharts):

------ Compiled with error(s): ------
Invalid number of parameters. 7 parameter(s) expected
line 23, column 22

can someone can help me to create this signal??

thanks!!

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: need help with VWAP cross over signal

Postby TJ » 08 Apr 2015

I've been trying to create a signal that:
1. buy when price crosses over VWAP
2. sell short when price crosses under VWAP
so far this is the code:
input:
Price(AvgPrice),
LocalHrsOffset(0),
time1(0900),
time2(0930),
time3(1129),
time4(1315),
time5(1415),
upColor(Cyan),
dnColor(Magenta);
var:
var0(0);
var0 = VWAPResettable(Price,LocalHrsOffset,time1,time2,time3,time4,time5);
plot1(var0,"vwap_reset");
var: var1(yellow);
if var0 > var0[1] then var1 = upColor;
if var0 < var0[1] then var1 = dnColor;
SetPlotColor(1,var1);
if price crosses over vwapResettable then buy this bar ;
if price crosses under vwapResettable then sellshort this bar ;
but after trying to compile the signal it shows this message and I cant figure out wheres the error (im new to multicharts):
------ Compiled with error(s): ------
Invalid number of parameters. 7 parameter(s) expected
line 23, column 22
can someone can help me to create this signal??
thanks!!
Please read the error message carefully...

line 23, column 22: 7 parameter(s) expected

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: need help with VWAP cross over signal

Postby TJ » 08 Apr 2015

ps.
[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: need help with VWAP cross over signal

Postby TJ » 08 Apr 2015

If you are new to programming or MultiCharts,
please go to PowerLanguage Editor and open one of the 150+ signals that came with MultiCharts.
There are lots examples you can explore, test, and codes to borrow.

shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Re: need help with VWAP cross over signal

Postby shanemcdonald » 10 Apr 2015

check to see if the plot part of the code is causing the problem.

I remember something about not being able to use plot commands in a signal.

shane

fernando43611
Posts: 33
Joined: 12 Mar 2015
Has thanked: 4 times

Re: need help with VWAP cross over signal

Postby fernando43611 » 13 Apr 2015

ok, I tried to create the code based on the moving average cross signal and this is what I got, but still cant get it right:

Code: Select all

input:
Price(AvgPrice),
LocalHrsOffset(0),
time1(0900),
time2(0930),
time3(1129),
time4(1315),
time5(1415),
upColor(Cyan),
dnColor(Magenta);

var:
var0(0);
var0 = VWAPResettable(Price,LocalHrsOffset,time1,time2,time3,time4,time5);
plot1(var0,"vwap_reset");

var: var1(yellow);
if var0 > var0[1] then var1 = upColor;
if var0 < var0[1] then var1 = dnColor;
SetPlotColor(1,var1);

condition1 = Price > "vwap_Reset" ;
if condition1 then
var0 = var0 + 1
else
var0 = 0 ;

condition1 = CurrentBar > ConfirmBars and var0 = ConfirmBars ;
if condition1 then
Buy ( "vwap_reset" ) next bar at limit ;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: need help with VWAP cross over signal

Postby TJ » 13 Apr 2015

ok, I tried to create the code based on the moving average cross signal and this is what I got, but still cant get it right:
::
See post #5


You cannot have PLOT in a signal.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: need help with VWAP cross over signal

Postby TJ » 13 Apr 2015

You have multiple coding errors in your signal.

Please read post #4 again.



This is a good place to start:
viewtopic.php?f=16&t=6929


Return to “MultiCharts”