Plot() with timer - NinjaTrader Programming | futures io social day trading
futures io futures trading


Plot() with timer
Updated: Views / Replies:1,022 / 10
Created: by ToMerK 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
 

Plot() with timer

  #1 (permalink)
Elite Member
Tel Aviv Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Futures
 
Posts: 21 since Feb 2015
Thanks: 30 given, 12 received

Plot() with timer

Hi all,
After reading that the refreshing frequency of the drawn objects depends on a few events and the chart properties Display Update Interval I came across the option to override the Plot() method and calling it with a timer iterval.

I am trying to call the Plot() method as overridden in costumePlotSample indicator, that comes with NT7, but one thing I do not understand, how do I call the it from the timer event? Plot() didn't work because it needs 4 parameters.

How should I call Plot?

I would also appreciate it if you can tell me how the refresh will work after I use a 100ms interval. Will Plot() be called again from other events?

 
Code
        protected override void OnBarUpdate()
        {
			if (!initTimer && !Historical)
			{
				myTimerClock.Tick += new EventHandler(DoTime);
				myTimerClock.Interval = 100;
				myTimerClock.Start();
							
				initTimer    = true;
			}			
        }
        #region Timer Methods
	private void OnTimerTick(object sender, EventArgs e)
	{
		TriggerCustomEvent(UpdateTime, 0, myTimerClock.Interval);
	}

	private void DoTime(Object myObject, EventArgs myEventArgs)
	{
		TriggerCustomEvent(UpdateTime, 0, myTimerClock.Interval);
	}		

	private void UpdateTime(object state)
	{
		Plot();
		//ChartControl.Refresh();
	}
        #endregion


Last edited by ToMerK; July 18th, 2015 at 08:38 PM.
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received



ToMerK View Post
How should I call Plot?

I would also appreciate it if you can tell me how the refresh will work after I use a 100ms interval. Will Plot() be called again from other events?

In a nutshell you don't, and you don't want to be doing that anyway, trust me I'm a doctor.

The Plot parameters are generated with a validated graphics context from system update and paint events, you can't store or generate them yourself and there is no need to.

The way to change Plot frequency is in the Chart Properties, much less than 400ms is pointless as you are not going to see it anyway.

It will always get called by other events in any case, usually when price/values have moved or objects have been drawn and it's longer than the last time interval for display update.

Plot will always get called if there is a visible change required on the screen, you don't need to attempt a redirect or build a new refresh approach.

You can however call ChartControl.Refresh() if you absolutely want to create guaranteed screen paints independent of price moves, for example if you are showing a bar timer or such like. I do this myself at certain times in a couple of charts with a one second timer.

NB For simple things I find using Windows.Forms.Timers easier as they are running synchronously in the main event loop anyway, less accurate but less to handle.

Cheers

Travel Well

Last edited by ratfink; July 19th, 2015 at 05:43 AM.
Reply With Quote
The following 2 users say Thank You to ratfink for this post:
 
  #4 (permalink)
Elite Member
Tel Aviv Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Futures
 
Posts: 21 since Feb 2015
Thanks: 30 given, 12 received

Thanks for the quick reply!

The problem I had before was that I used Draw commands in OnMarketData events that were updated only once in a few seconds even though my display update interval was set to 0.1 seconds. I did output to the data as well to the output window and saw that I have many events within this interval.

Doesn't this contradicts what you said that any change will be plotted as it arrives?

And another question, what is the difference between the Invalidate method to the refresh?


Last edited by ToMerK; July 19th, 2015 at 08:55 AM. Reason: Another question
Reply With Quote
The following user says Thank You to ToMerK for this post:
 
  #5 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


ToMerK View Post
Thanks for the quick reply!

The problem I had before was that I used Draw commands in OnMarketData events that were updated only once in a few seconds even though my display update interval was set to 0.1 seconds. I did output to the data as well to the output window and saw that I have many events within this interval.

Doesn't this contradicts what you said that any change will be plotted as it arrives?

And another question, what is the difference between the Invalidate method to the refresh?

The changes will get output on your display update interval if price has moved, they may not become visible otherwise unless you have called Invalidate or Refresh. Normally I only draw using NT routines in OnBarUpdate or use low level graphics calls in Plot. I do use OnMarketData but have not used graphics from inside there so can't comment on that.

Little difference between Invalidate and Refresh, the former generates a queued paint event until all current processing is done then the Paint event will trigger, Refresh just triggers a Paint immediately.

Also in my experience the TriggerCustomEvent route is only necessary if NT bar indexes and such like are involved.

Cheers

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #6 (permalink)
Elite Member
Tel Aviv Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Futures
 
Posts: 21 since Feb 2015
Thanks: 30 given, 12 received

Is there a real difference between drawing in OnMarketDepth last events and in OnBarUpdate (if CalculateOnBarClose = false)?

Reply With Quote
The following user says Thank You to ToMerK for this post:
 
  #7 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


ToMerK View Post
Is there a real difference between drawing in OnMarketDepth last events and in OnBarUpdate (if CalculateOnBarClose = false)?

I don't know, I've just never tried it. I agree it is likely to be similar (and is in the same event loop) but you can get lots of OMD events (e.g. bid/ask/vol) without getting a price-moving OBU event.

Maybe email NT support to get clarification if you really need it. Alternatively you can just process data in OMD into a saved/active area and output NT gfx from OMD or a timer routine (adding an Invalidate or Refresh as needed if you are drawing something that can change without price or other indicator Values changing), or use low level gfx from Plot.

It's always worth thinking about when CPU work actually needs to be done for the brain to see something useful. More thinking along delayed processing lines would have lead to a lot less inefficient indicator code than NT7 has been typically been saddled with.

Cheers

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #8 (permalink)
Elite Member
Tel Aviv Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Futures
 
Posts: 21 since Feb 2015
Thanks: 30 given, 12 received

Thanks again!

A few more questions about the chartControl. The intellisense gives me many things to work with, is there a guide for this that someone wrote? If not can you please specify what are the methods you work with? And what is the chartPanel within the chartControl?

Reply With Quote
The following user says Thank You to ToMerK for this post:
 
  #9 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


ToMerK View Post
Thanks again!

A few more questions about the chartControl. The intellisense gives me many things to work with, is there a guide for this that someone wrote? If not can you please specify what are the methods you work with? And what is the chartPanel within the chartControl?

No guides available as it's all unsupported NT stuff although it does tend to behave fairly well. Best approach is to learn a bit about general Windows Forms Controls, fastest way is just to Google "C# <subject>". You will also find lots of existing code on futures.io (formerly BMT) and in the NT support forum areas.

The ChartPanel is the graphics subpane of the Window, so without borders.

Best other learning route is simple Prints on the variables, I have not found use for that many of the methods and prefer to avoid close coupled hooks if I can.

Final caveat is that NT8 uses a completely different foundation layer (WPF) instead of Forms, so maybe don't invest too heavily unless you are happy to do so. Personally I think Forms and NT7 will be still around for a long time but it will be interesting to see if the next generation does have better documented APIs.

Cheers

Travel Well
Reply With Quote
The following 2 users say Thank You to ratfink for this post:
 
  #10 (permalink)
Market Wizard
Sarasota FL
 
Futures Experience: Intermediate
Platform: NinjaTrader, Sierra Chart
Favorite Futures: ES
 
Posts: 3,634 since Jan 2013
Thanks: 26,747 given, 11,110 received
Forum Reputation: Legendary



ratfink View Post
Final caveat is that NT8 uses a completely different foundation layer (WPF) instead of Forms, so maybe don't invest too heavily unless you are happy to do so. Personally I think Forms and NT7 will be still around for a long time but it will be interesting to see if the next generation does have better documented APIs.

Won't it? Couldn't have much worse. (API documentation, that is.)

I don't want to barge in, but with NT8 presumably getting near to its release (anyone have any word on that??), I was going to say that getting too deeply into NT7, or perhaps doing very much with it at all, except purely surface stuff, may not be a great idea.

That said, I have stayed away from the NT8 beta project, not wanting more complication right now, and so I don't really know how NT8 will turn out. Are you in it, or do you otherwise have an idea?

Bob.

Reply With Quote

Reply



futures io > > > > > Plot() with timer

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
Bar Timer ? Babool Sierra Chart 1 December 15th, 2014 12:26 PM
Bar Timer Indie trs3042 NinjaTrader 9 May 8th, 2012 09:31 PM
Trade Timer DennisA The Elite Circle 8 February 14th, 2012 05:36 AM
Tick Bar Timer lawtan NinjaTrader 2 December 7th, 2010 07:51 AM
Please, I need help with timer on WoodiesCCIpanel George NinjaTrader Programming 9 September 16th, 2010 06:32 AM


All times are GMT -4. The time now is 11:23 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-13 in 0.15 seconds with 19 queries on phoenix via your IP 54.227.51.103