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 MooreTech with 5 posts (1 thanks)
    3. looks_3 gregid 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,635 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

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

Maybe I should have the settings under Initialize() like in the original vwap indicator?

protected override void Initialize()
{
Add(new Plot(Color.Orange, "VWAP"));
Add(new Plot(Color.Blue, "SD1 Upper"));
Add(new Plot(Color.Blue, "SD1 Lower"));
Add(new Plot(Color.Blue, "SD2 Upper"));
Add(new Plot(Color.Blue, "SD2 Lower"));
Add(new Plot(Color.Blue, "SD3 Upper"));
Add(new Plot(Color.Blue, "SD3 Lower"));

vwapsd = new DataSeries(this);
AutoScale = false;
BarsRequired = 1;
CalculateOnBarClose = false;
Overlay = true;
PriceTypeSupported = true;
}

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #12 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


mpe66 View Post
I'm using the indicator from post 258 in this thread on the NT forum. I'm pretty sure the name of the plot is just VWAP or at least that's what it's called in the indicator settings...

Names of the plots are not the ones in the indicator's settings but in the properties region of the vwap.cs file

Attached Thumbnails
Click image for larger version

Name:	2010-08-28_1436.png
Views:	216
Size:	113.5 KB
ID:	19289  
Reply With Quote
Thanked by:
  #13 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


As for properties: use the wizard and ask for one of the VWAP plots, then generate the code and you will see what parameters were included

You could actually have your indicator done using wizard only

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


gregid View Post
As for properties: use the wizard and ask for one of the VWAP plots, then generate the code and you will see what parameters were included

You could actually have your indicator done using wizard only

Thanks, I'll try that.

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


gregid View Post
As for properties: use the wizard and ask for one of the VWAP plots

How do I do that? Been going through the help guides but can't get this to work.

Started this thread Reply With Quote
  #16 (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

Use the attached indicator. You can call it from your code as follows:

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double a = VWAP(1,endtime,1,1,1,1,true,true,starttime)[0];

Attached Files
Elite Membership required to download: VWAP.zip
Follow me on Twitter Reply With Quote
  #17 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

what exactly you can't do?

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


MooreTech View Post
Use the attached indicator. You can call it from your code as follows:

TimeSpan endtime = new TimeSpan(0,0,0);
TimeSpan starttime = new TimeSpan(0,0,0);
double a = VWAP(1,endtime,1,1,1,1,true,true,starttime)[0];

Thanks for all your help. I don't really know what I'm doing but I tried pasting the 3 lines into my script in onbarupdate(?) and parameters into VWAP() and got it to compile without errors. However, it doesn't plot anything on my chart. Should it be VWAP().VWAPLine or just VWAP().VWAP for this VWAP indicator? I'll attach my indicator...

Mpe

Attached Files
Elite Membership required to download: VwapOscillator2.zip
Started this thread Reply With Quote
  #19 (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

Your indicator should look like this

 
Code
                            

            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); 

Follow me on Twitter Reply With Quote
  #20 (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


This works, however I was not able to pass the starttime and endtime parameters into the vwap function call. The line that is commented out had syntax errors.

The code is optimized for fast execution by using predefined instances of the external indicator (VWAP). Not doing this is poor practice.


This oscillator does a really great job of FOLLOWING the price. While coding it was fun, I do not see how it would be useful in trading.



public class VwapOscillator2 : 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);

}

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