OnStartUp error - NinjaTrader Programming | futures io social day trading
futures io futures trading


OnStartUp error
Updated: Views / Replies:2,016 / 15
Created: by Ragdoll Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

OnStartUp error

  #11 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


Ragdoll View Post
OK,

I've had my RTFM moment and have solved the object problem with a little help from Bertrand. I added an if statement to check for a null on GetDayBar(1). The problem now is it is always null.

you can add;
if (Bars.LastBarOfSession)
{
priordayOpen = Open[0];
priordayHigh = High[0];
priordayLow = Low[0];
priordayClose = Close[0];
}

Reply With Quote
 
  #12 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


cory View Post
you can add;
if (Bars.LastBarOfSession)
{
priordayOpen = Open[0];
priordayHigh = High[0];
priordayLow = Low[0];
priordayClose = Close[0];
}

Is the prior day close the settlement price?

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #13 (permalink)
Elite Member
Walterboro, South Carolina
 
Futures Experience: Intermediate
Platform: ninjatrader, amibroker, thinkorswim
Favorite Futures: futures
 
Posts: 13 since Aug 2013
Thanks: 1 given, 5 received


Finally got it to work!

here is the working code:

 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    /// <summary>
    /// this is a strategythat uses pivot points and support / resistance levels to set exit and entry points
    /// </summary>
    [Description("this is a strategythat uses pivot points and support / resistance levels to set exit and entry points")]
    public class PivotPlay : Strategy
    {
        #region Variables
        // Wizard generated variables
        private double pct = 0.005; // Default setting for Pct
        // User defined variables (add any user defined variables below
		private bool firstTime;
		private bool islong;
		
		private double pvtu;
		private double pvtl;
		private double rl1u;
		private double rl1l;
		private double rl2u;
		private double rl2l;
		private double rl3u;
		private double rl3l;
		private double sl1u;
		private double sl1l;
		private double sl2u;
		private double sl2l;
		private double sl3u;
		private double sl3l;
		
		private double pvt;
		private double rl1;
        private double rl2;
		private double rl3;
		private double sl1;
		private double sl2;
		private double sl3;
		private double prevDayClose;
		private double prevDayHigh;
		private double prevDayLow;
		
		
        #endregion

        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
			firstTime = false;
			islong = false;
			CalculateOnBarClose = true;
			
					
		
        }
		protected override void OnStartUp()
		{
		}
		/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
		if(Bars.FirstBarOfSession && FirstTickOfBar)
		{
		if (Bars.GetDayBar(1) != null)
			{
			prevDayClose = Bars.GetDayBar(1).Close; 
			prevDayHigh	 = Bars.GetDayBar(1).High; 
			prevDayLow = Bars.GetDayBar(1).Low;
			}
			pvt = (prevDayClose + prevDayHigh + prevDayLow) / 3;
			
			 pvtu = pvt + (pvt * pct);
			 pvtl = pvt - (pvt * pct);
			 rl1u = rl1 + (rl1 * pct);
			 rl1l = rl1 - (rl1 * pct);
			 rl2u = rl2 + (rl2 * pct);
			 rl2l = rl2 - (rl2 * pct);
			 rl3u = rl3 + (rl3 * pct);
			 rl3l = rl3 - (rl3 * pct);
			 sl1u = sl1 + (sl1 * pct);
			 sl1l = sl1 - (sl1 * pct);
			 sl2u = sl2 + (sl2 * pct);
			 sl2l = sl2 - (sl2 * pct);
			 sl3u = sl3 + (sl3 * pct);
			 sl3l = sl3 - (sl3 * pct);
			
			Print(pvt);
			Print(pvtu);
	
			
		
		
	    
		}
		
			
			/// Rule 1;  enter long if close above first bar high...;
			if (Bars.FirstBarOfSession)
			{ return;
			}
			else
			{ int barOne = Bars.BarsSinceSession;
				if (Close[0] > High[barOne])
				{
				

					
				  islong = true;
				  firstTime = true;
				EnterLong("Entry");
				}
			}
		/// rule 2; 
			
			
			
		
			
			
			
		
		
			
        }

        #region Properties
        [Description("")]
        [GridCategory("Parameters")]
        public double Pct
        {
            get { return pct; }
            set { pct = Math.Max(0.001, value); }
        }
        #endregion
    }
}

Reply With Quote
 
  #14 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


Tasker_182 View Post
Is the prior day close the settlement price?

I copy it from ninja indicator, if you think settlement price is different from this price then you have to enter it manually.

Reply With Quote
 
  #15 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


cory View Post
I copy it from ninja indicator, if you think settlement price is different from this price then you have to enter it manually.

That's kind of why i asked the question as the thread OP is using yesterdays close for his pivots but if he is calculating futures pivots then he would need the settlement price to have correct pivots.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #16 (permalink)
Elite Member
Walterboro, South Carolina
 
Futures Experience: Intermediate
Platform: ninjatrader, amibroker, thinkorswim
Favorite Futures: futures
 
Posts: 13 since Aug 2013
Thanks: 1 given, 5 received

right now I'm testing against stocks to see if the concept tests out. I'll figure out the futures after testing. You are right though, futures require the settlement price to be accurate.

Cheers

Ragdoll

Reply With Quote
The following user says Thank You to Ragdoll for this post:

Reply



futures io > > > > > OnStartUp error

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
help NinjaTrader error eryo NinjaTrader Programming 20 December 22nd, 2016 07:56 PM
NT error jsengxx2 NinjaTrader 10 May 6th, 2013 07:27 AM
Error traderdp NinjaTrader 2 January 30th, 2013 03:59 PM
DashStyle error Big Mike NinjaTrader Programming 5 August 4th, 2012 06:53 AM
New OnStartUp() method in NT7 B8 aslan NinjaTrader Programming 7 February 5th, 2010 10:47 AM


All times are GMT -4. The time now is 08:08 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-17 in 0.14 seconds with 19 queries on phoenix via your IP 54.145.16.43