NexusFi: Find Your Edge


Home Menu

 





EasyLanguage VWAP code help


Discussion in Platforms and Indicators

Updated
      Top Posters
    1. looks_one MilesT with 4 posts (4 thanks)
    2. looks_two olobay with 3 posts (0 thanks)
    3. looks_3 treydog999 with 2 posts (3 thanks)
    4. looks_4 ABCTG with 1 posts (0 thanks)
    1. trending_up 16,701 views
    2. thumb_up 10 thanks given
    3. group 7 followers
    1. forum 12 posts
    2. attach_file 1 attachments




 
Search this Thread

EasyLanguage VWAP code help

  #1 (permalink)
 MilesT 
Orlando, FL
 
Experience: Intermediate
Platform: OEC
Broker: VanKar/OEC
Trading: 6E
Posts: 11 since Dec 2011
Thanks Given: 44
Thanks Received: 11

I need some help modifying an EL VWAP indicator I found. It does what I want except for the start time. I would like it to start daily at 1800 ET instead of midnight. Sounds like a simple adjustment if you are not a dummy like me.
Any help would be much appreciated.

vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),
standarddeviation(0);
If date > date[1]
then
begin
Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum);
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation);

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Deepmoney LLM
Elite Quantitative GenAI/LLM
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
27 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #2 (permalink)
 
Lampert's Avatar
 Lampert 
Calgary, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: IB, IQFeed
Trading: GC
Posts: 76 since Nov 2011
Thanks Given: 73
Thanks Received: 142

MT - You just need to modify the code as shown below, between the /// lines. It tested OK in Multicharts.
 
Code
vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),

///
standarddeviation(0),
OncePerDay(0);
If date > date[1] then OncePerDay = 0 ;
If Time >= 1800 and OncePerDay = 0 then begin
OncePerDay = 1 ;
///	 
	 
Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum); 
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation);

Len

Reply With Quote
Thanked by:
  #3 (permalink)
 MilesT 
Orlando, FL
 
Experience: Intermediate
Platform: OEC
Broker: VanKar/OEC
Trading: 6E
Posts: 11 since Dec 2011
Thanks Given: 44
Thanks Received: 11


Worked like a charm. Thank you very much for your help Len.

Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 MilesT 
Orlando, FL
 
Experience: Intermediate
Platform: OEC
Broker: VanKar/OEC
Trading: 6E
Posts: 11 since Dec 2011
Thanks Given: 44
Thanks Received: 11

Len,

Can you help me make the start time an input instead of hard coded?

Thanks in advance,

Miles

vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),

///
standarddeviation(0),
OncePerDay(0);
If date > date[1] then OncePerDay = 0 ;
If Time >= 1800 and OncePerDay = 0 then begin
OncePerDay = 1 ;
///

Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum);
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation);

Started this thread Reply With Quote
  #5 (permalink)
 MilesT 
Orlando, FL
 
Experience: Intermediate
Platform: OEC
Broker: VanKar/OEC
Trading: 6E
Posts: 11 since Dec 2011
Thanks Given: 44
Thanks Received: 11

I figured it out. Here it is in case any one is interested...changes in red...

input: time_start (1800);
vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),

standarddeviation(0),
OncePerDay(0);
If date > date[1] then OncePerDay = 0 ;
If Time >= time_start and OncePerDay = 0 then begin
OncePerDay = 1 ;

Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum);
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation);

Started this thread Reply With Quote
Thanked by:
  #6 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

Could somebody please add the ability to only plot the VWAP starting from a start time and ending at an end time in the code below? In other words, the VWAP would only be visible on the chart from say 930 - 1615. The reason for this is that you can use an ETH chart but plot an RTH VWAP. Right now the VWAP calculates from the input time but it plots throughout the chart.

Thanks.

 
Code
input: time_start (1800), upColor(Cyan), dnColor(Magenta);

vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),

standarddeviation(0),
OncePerDay(0);
If date > date[1] then OncePerDay = 0 ;
If Time >= time_start and OncePerDay = 0 then begin
OncePerDay = 1 ; 

Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum); 
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation); 

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

Reply With Quote
  #7 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

Can anybody help with the above code?

Reply With Quote
  #8 (permalink)
 
treydog999's Avatar
 treydog999 
seoul, Korea
 
Experience: Intermediate
Platform: Multicharts
Broker: CQG, DTN IQfeed
Trading: YM 6E
Posts: 897 since Jul 2012
Thanks Given: 291
Thanks Received: 1,039


olobay View Post
Could somebody please add the ability to only plot the VWAP starting from a start time and ending at an end time in the code below? In other words, the VWAP would only be visible on the chart from say 930 - 1615. The reason for this is that you can use an ETH chart but plot an RTH VWAP. Right now the VWAP calculates from the input time but it plots throughout the chart.

Thanks.

 
Code
input: time_start (1800), upColor(Cyan), dnColor(Magenta);

vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),

standarddeviation(0),
OncePerDay(0);
If date > date[1] then OncePerDay = 0 ;
If Time >= time_start and OncePerDay = 0 then begin
OncePerDay = 1 ; 

Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum); 
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation); 

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


olobay View Post
Can anybody help with the above code?


Just by looking at the code, no idea if it will work is change


 
Code
standarddeviation=SquareRoot(deviationsum); 
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation);
to

 
Code
standarddeviation=SquareRoot(deviationsum); 
if time <= 1615 then begin
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation); 
end;

Reply With Quote
Thanked by:
  #9 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011


treydog999 View Post
Just by looking at the code, no idea if it will work is change

 
Code
standarddeviation=SquareRoot(deviationsum); 
if time <= 1615 then begin
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation); 
end;

Thanks @treydog999 but it did not work.

Reply With Quote
  #10 (permalink)
 
treydog999's Avatar
 treydog999 
seoul, Korea
 
Experience: Intermediate
Platform: Multicharts
Broker: CQG, DTN IQfeed
Trading: YM 6E
Posts: 897 since Jul 2012
Thanks Given: 291
Thanks Received: 1,039



olobay View Post
Thanks @treydog999 but it did not work.

 
Code
input: time_start (0930), time_end (1615), upColor(Cyan), dnColor(Magenta);

vars: vwap(0),
pv(0),
Totalvolume(0),
Barfromstart(0),
Squareddeviations(0),
Probabilityweighteddeviations(0),
deviationsum(0),

standarddeviation(0),
OncePerDay(0);
If date > date[1] then OncePerDay = 0 ;
If Time >= time_start and OncePerDay = 0 then begin
OncePerDay = 1 ; 

Barfromstart=0;
pv=AvgPrice*volume;
Totalvolume=volume;
vwap=pv/totalvolume;
end
else
begin
Barfromstart=Barfromstart[1]+1;
pv=pv[1] + AvgPrice*Volume;
Totalvolume=Totalvolume[1] + Volume;
vwap=pv/Totalvolume;
end;
deviationsum=0;
for value1= 0 to Barfromstart
begin
Squareddeviations=Square( vwap-avgprice[value1]);
Probabilityweighteddeviations=volume[value1]*Squareddeviations/Totalvolume;
deviationsum=deviationsum +Probabilityweighteddeviations;
end;

standarddeviation=SquareRoot(deviationsum); 
if time <= time_end and time >= time_start then begin
Plot1(vwap);
Plot2(vwap+standarddeviation);
Plot3(vwap+2*standarddeviation);
Plot4(vwap-standarddeviation);
Plot5(vwap-2*standarddeviation); 
end
else begin
Plot1(0); // outside of session plots, edit as needed
Plot2(0);
Plot3(0);
Plot4(0);
Plot5(0); 
end;

var: var1(yellow);
if vwap > vwap[1] then var1 = upColor;
if vwap < vwap[1] then var1 = dnColor;
SetPlotColor(1,var1);
This is just a really quick fix, it makes the plots plot 0 when its outside of your time, so they are basically hidden. But as you can see in my screenshot it makes vertical lines. which may be annoying. but at least you have the time function that is customizable.



Reply With Quote
Thanked by:




Last Updated on April 18, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts