|
Jim Dean
 Sage
       Posts: 3433
Joined: 3/13/2006
Location: L'ville, GA
User Profile |
The attached code is an example that helps illustrate and explain several things that are outside of Nirvana's current documentation ... since it uses some native Visual Basic functions.
Don't let that scare you away.
This example illustrates two very useful things for use with intraday plotting:
1. How to limit your plot to a particular day
2. How to PricePlot a series of separate segments of intraday bars within that day, WITHOUT those segments being connected to one another, OR to a comparable time-segment from the prior day.
The function allows you to input all-zeros to specify that the plots are to occur for the CURRENT day ... and it automatically compensates for plots that you might be doing on Saturday or Sunday ... in that case, it plots the previous Friday.
It also allows you to specify a particular YYYY MM DD during which the plot should be done.
It also (and this is sorta cool) allows you to do the plot on a specified number of weekdays BEFORE the current day. If you span a weekend or two (or whatever) in the process, it automatically compensates for the Sat & Sun's in the calendar that are not trading days. That is, you input the number of TRADING days ago.
There's one gotcha ... I did not build in the (messy) code that would be needed to auto-skip any trading holidays that occur M-F ... you need to input one extra day-ago for any of those.
The example arbitrarily draws some lines above and below the price bars to show how they can be turned "on" and "off". The trick is to name each segment differently. This is ALL you have to do if you are working with daily bars ... but with intraday bars, you ALSO need the extra code to isolate what day you want to plot.
This could be readily expanded to permit plotting over a range of calendar days. Theoretically, any trading holidays that are known ahead of time could be hard-coded as well.
CAVEATS:
The arbitrary choice of plotting five separated segments per day to illustrate this procedure IS based on a 390-minute day. There are situations where a trading-day's intraday-data might have MORE OR LESS than 390 minutes ... it could include pre- and post-market data; futures/forex is different; partial-holidays are different. However, none of these issues relate to the two main things illustrated by this code:
1. How to focus plotting (or calcs) on a particular day, and
2. How to plotprice individual segments within a day
I hope this code is helpful to many people ... the programming of intraday stuff is sort of trick-sey, as Gollum would say ...


[Edited by Jim Dean on 3/28/2015 7:22 AM]
Attached file : IntradayBarSegPlot - ScreenSnap.png (44KB - 1204 downloads)
Attached file : aJDndIntradayBarSegPlot.rtf (5KB - 924 downloads)
Attached file : IntradayBarSegPlot - CodeSnap.png (97KB - 1153 downloads)
|
|
JB
 Legend
     Posts: 434
Joined: 6/6/2006
User Profile |
Jim you seem to have put that together in no time at all; fabulous. If I can get my head around it it will be a fantasic help to me.
So as ever Thank you Jim
|
|
Jim Dean
 Sage
       Posts: 3433
Joined: 3/13/2006
Location: L'ville, GA
User Profile |
Here is another installment that helps document what the various date and time options are, and how the "bar-based" values differ from the "computer-clock" based values.
NOTE: THIS EXAMPLE IS PRINTED OUT ON A MONDAY MORNING BEFORE MARKET OPEN. There was a ToDo update done which captured all available data before these snapshots were taken.
The "debugmsg" output is used as the quickest way to test and document all the features. However, DON'T MISS the Plot commands and the Return commands ... these show how the values might be used in actual code.



[Edited by Jim Dean on 3/28/2015 7:21 AM]
Attached file : aJDndTimeInfoEOD - debugout.png (110KB - 1119 downloads)
Attached file : aJDndTimeInfoEOD - codesnap.png (44KB - 1086 downloads)
Attached file : aJDndTimeInfoEOD - screen&FL.png (30KB - 1051 downloads)
Attached file : aJDndTimeInfoEOD.rtf (2KB - 746 downloads)
|
|
Jim Dean
 Sage
       Posts: 3433
Joined: 3/13/2006
Location: L'ville, GA
User Profile |
Additional notes for the prior post:
Full info re dotNET date and time stuff is avail at:
http://msdn.microsoft.com/en-us/library/system.datetime_members.aspx
ALSO, here are a couple of examples of additional possibly useful functions you can play with, which I failed to include originally ... the URL indicates many others ...
debugmsg("==== time-math ====")
debugmsg("Add 24.5h= "&now.addhours(24.5))
debugmsg("DST? = "&now.isdaylightsavingtime())
|