NexusFi: Find Your Edge


Home Menu

 





A little programming help plz


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one mpe66 with 15 posts (1 thanks)
    2. looks_two gregid with 5 posts (1 thanks)
    3. looks_3 MooreTech with 5 posts (1 thanks)
    4. looks_4 Zondor with 3 posts (8 thanks)
      Best Posters
    1. looks_one Zondor with 2.7 thanks per post
    2. looks_two gregid with 0.2 thanks per post
    3. looks_3 MooreTech with 0.2 thanks per post
    4. looks_4 mpe66 with 0.1 thanks per post
    1. trending_up 10,656 views
    2. thumb_up 11 thanks given
    3. group 5 followers
    1. forum 31 posts
    2. attach_file 6 attachments




 
Search this Thread

A little programming help plz

  #21 (permalink)
 mpe66 
Sweden
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 49 since Mar 2010
Thanks Given: 29
Thanks Received: 12

Guys,

I appreciate your help and tried your suggestions but get the same error message in both when I try compiling: CS1501 "No overload for method VWAP takes 1 argument". Any thoughts on how this could be fixed?

Thanks,

Mpe

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
 
  #22 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,469 since Jun 2009
Thanks Given: 33,246
Thanks Received: 101,669


mpe66 View Post
Guys,

I appreciate your help and tried your suggestions but get the same error message in both when I try compiling: CS1501 "No overload for method VWAP takes 1 argument". Any thoughts on how this could be fixed?

Thanks,

Mpe

Please attach your complete code (file).

Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #23 (permalink)
 mpe66 
Sweden
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 49 since Mar 2010
Thanks Given: 29
Thanks Received: 12



Big Mike View Post
Please attach your complete code (file).

Mike

I have 2 different ones but can't export them with errors(?). The first one, MooreTech's, looks like this:

public class VwapOscillator4 : Indicator
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "Plot0"));
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double vwap = VWAP(1,endtime,3,1,2,3,true,true,starttime).VWAPLine[0];
double sdupper = VWAP(1,endtime,3,1,2,3,true,true,starttime).SD1Upper[0];
double denom = sdupper-vwap;

if (denom!=0)
Value.Set ((Close[0] - vwap) / (sdupper - vwap));
else
Value.Set(0);
}



Zondor's:



public class WvapOscillator3 : Indicator

{
#region Variables
private VWAP vwap1;
private bool init = false;
TimeSpan starttime, endtime;
private double vwap, sdupper, denom;
#endregion


protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
}


protected override void OnBarUpdate()
{
if (!init)
{
//endtime = new TimeSpan(0, 0, 0);
//starttime = new TimeSpan(0, 0, 0);
//vwap1 = VWAP(1, endtime, 3, 1, 2, 3, true, true, starttime);
vwap1=VWAP(Close); // define the instance of the external indicator to be used later
init = true;
}
//endtime = new TimeSpan(0, 0, 0);
//starttime = new TimeSpan(0, 0, 0);

vwap = vwap1.VWAPLine[0];
sdupper = vwap1.SD1Upper[0];
denom = sdupper - vwap;

if (denom != 0)
Value.Set((Close[0] - vwap) / denom);
else
Value.Set(0);

}


I get the same error in both: CS1501 "No overload for method VWAP takes 1 argument"

Started this thread Reply With Quote
  #24 (permalink)
 MooreTech 
Orlando, Florida
 
Experience: Advanced
Platform: NinjaTrader, TradeStation, MultiCharts, eSignal, MetaTrader
Trading: ES
Posts: 57 since Aug 2010
Thanks Given: 6
Thanks Received: 73


mpe66 View Post
I have 2 different ones but can't export them with errors(?). The first one, MooreTech's, looks like this:

public class VwapOscillator4 : Indicator
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "Plot0"));
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double vwap = VWAP(1,endtime,3,1,2,3,true,true,starttime).VWAPLine[0];
double sdupper = VWAP(1,endtime,3,1,2,3,true,true,starttime).SD1Upper[0];
double denom = sdupper-vwap;

if (denom!=0)
Value.Set ((Close[0] - vwap) / (sdupper - vwap));
else
Value.Set(0);
}



Zondor's:



public class WvapOscillator3 : Indicator

{
#region Variables
private VWAP vwap1;
private bool init = false;
TimeSpan starttime, endtime;
private double vwap, sdupper, denom;
#endregion


protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
}


protected override void OnBarUpdate()
{
if (!init)
{
//endtime = new TimeSpan(0, 0, 0);
//starttime = new TimeSpan(0, 0, 0);
//vwap1 = VWAP(1, endtime, 3, 1, 2, 3, true, true, starttime);
vwap1=VWAP(Close); // define the instance of the external indicator to be used later
init = true;
}
//endtime = new TimeSpan(0, 0, 0);
//starttime = new TimeSpan(0, 0, 0);

vwap = vwap1.VWAPLine[0];
sdupper = vwap1.SD1Upper[0];
denom = sdupper - vwap;

if (denom != 0)
Value.Set((Close[0] - vwap) / denom);
else
Value.Set(0);

}


I get the same error in both: CS1501 "No overload for method VWAP takes 1 argument"

The issue in Zondor's code is in the following line:

vwap1=VWAP(Close); // define the instance of the external indicator to be used later

The VWAP indicator accepts numerous inputs (as shown in the code I provided). I don't see how that error would occur with the code I provided, as my code never passes only 1 parameter to the VWAP indicator. Please try to download the indicator I provided, then call it from your indicator as I did above. It seemed to work fine on my end.

Follow me on Twitter Reply With Quote
Thanked by:
  #25 (permalink)
 mpe66 
Sweden
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 49 since Mar 2010
Thanks Given: 29
Thanks Received: 12


MooreTech View Post
The issue in Zondor's code is in the following line:

vwap1=VWAP(Close); // define the instance of the external indicator to be used later

The VWAP indicator accepts numerous inputs (as shown in the code I provided). I don't see how that error would occur with the code I provided, as my code never passes only 1 parameter to the VWAP indicator. Please try to download the indicator I provided, then call it from your indicator as I did above. It seemed to work fine on my end.

Beautiful. I got it working now. Thanks a lot for all your help. I want to get different colored histogram for positive/negative values. When I get that figured out I'll post it for anyone who wants to try it.

Started this thread Reply With Quote
Thanked by:
  #26 (permalink)
 mpe66 
Sweden
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 49 since Mar 2010
Thanks Given: 29
Thanks Received: 12

I'm trying to add a positive and a negative plot with different colors. If indicator value is > 0 plot "Positive" plot etc but don't really know how to do it.

protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Bar, "Positive"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Bar, "Negative"));
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double vwap = VWAP(1,endtime,3,1,2,3,true,true,starttime).VWAPLine[0];
double sdupper = VWAP(1,endtime,3,1,2,3,true,true,starttime).SD1Upper[0];
double denom = sdupper-vwap;


if (denom!=0)
Value.Set ((Close[0] - vwap) / (sdupper - vwap));
else
Value.Set(0);

if (Value > 0)
Positive.Set;
else
Negative.Set;

}

Started this thread Reply With Quote
  #27 (permalink)
 mpe66 
Sweden
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 49 since Mar 2010
Thanks Given: 29
Thanks Received: 12

Or could I do something like this:

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double vwap = VWAP(1,endtime,3,1,2,3,true,true,starttime).VWAPLine[0];
double sdupper = VWAP(1,endtime,3,1,2,3,true,true,starttime).SD1Upper[0];
double denom = sdupper-vwap;
double plotval = ((Close[0] - vwap) / (sdupper - vwap));



if ((denom!=0) && (plotval>0 )
Positive.Set( plotval );
else
0
if ((denom!=0) && (plotval<0 )
Negative.Set( plotval );
else
0

Started this thread Reply With Quote
  #28 (permalink)
 mpe66 
Sweden
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 49 since Mar 2010
Thanks Given: 29
Thanks Received: 12

Figured it out:

{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double vwap = VWAP(1,endtime,3,1,2,3,true,true,starttime).VWAPLine[0];
double sdupper = VWAP(1,endtime,3,1,2,3,true,true,starttime).SD1Upper[0];
double denom = sdupper-vwap;
double plotval = ((Close[0] - vwap) / (sdupper - vwap));

if ((denom!=0) && plotval > 0)
{
Positive.Set(plotval);
}
if ((denom!=0) && plotval < 0)
{
Negative.Set(plotval);
}


}

Started this thread Reply With Quote
  #29 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: NinjatraderŽ
Broker: CQG, Kinetick
Trading: Gameplay KlownbineŽ Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

My code did not work because I was not using the same version of VWAP as MooreTech. My version (form post 258 on NT forum) did not accept any parameters. After switching to his version and changing the ONE LINE of my code that calls the external VWAP to use his parameter syntax, it worked.

However his code is extremely and unnecessarily inefficient and wasteful of resources. To understand why, see this:

RWT-004 :: Move the Markets

In addition, note that the color of the plot should be changed by using the PlotColors method on a SINGLE plot, NOT by switching back and forth between two different plots, which is SO NT6.5.

So let's take full advantage of the PlotColors method and have a FOUR COLOR plot. The four colors will represent above VWAP rising and falling and below VWAP risng and falling.

To be continued....

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #30 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: NinjatraderŽ
Broker: CQG, Kinetick
Trading: Gameplay KlownbineŽ Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731


Made some changes. Note that this is for NT7 ONLY.

Incorporated Cvax's version of VWAP, the one that MooreTech used. Renamed it so that it won't get confused with the other versions of VWAP that are floating around out there.

Added the ability to change the start time and end time; they are now user settings of the VWAP oscillator.

Added a zero line so you can tell at a glance whether price is above or below VWAP. It plots two different colors depending on whether VWAP is rising or falling.

Added multi color plotting to the oscillator line, different colors for rising and falling.

Retained correct implementation of calls to external indicator using predefined instances.

You will note that in addition to the enhanced features, this runs much faster than the MooreTech version, which uses the incorrect "newbie" method of calling VWAP. Try both versions on a 10,000 bar chart with calculate on bar close set to false and see which one loads faster.

Attached Thumbnails
Click image for larger version

Name:	VWAP Oscillator.jpg
Views:	297
Size:	120.9 KB
ID:	19345  
Attached Files
Elite Membership required to download: VwapOscillator.zip
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on July 27, 2011


© 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