PDA

View Full Version : Start/End of day plot


Mexie
10-21-2007, 05:33 PM
Hi, does anyone know how to program an indicator that plots the day's trading period from open till close on 24 hour data chart?

NinjaTrader_Josh
10-21-2007, 06:02 PM
Could you please elaborate on what you mean exactly. By default it will plot all of the days data. This means if data starts coming in at midnight (00:00) it will start plotting there and if the data ends for the day in 24 hrs (24:00) it will stop that days data there and start a new days data at 00:00. Does that make sense?

By default it will not truncate any of the data from being displayed.

Mexie
10-21-2007, 08:56 PM
What I meant is I need a way to mark the day's session in a 24 hour data chart.
If I set up a 24 hour chart, the day's break happens as 12:00am. I need to also mark the 9:30am to 4:15pm period.

Thanks,

Pablo

NinjaTrader_Josh
10-21-2007, 09:03 PM
Perhaps what you could do is something like this
if (ToTime(Time[0]) == 93000 || ToTime(Time[0]) == 161500)
DrawVerticalLine("Market Session" + CurrentBar, 0, Color.Black, DashStyle.Dash, 2);http://www.ninjatrader-support.com/HelpGuideV6/ToTime.html
http://www.ninjatrader-support.com/HelpGuideV6/Time.html
http://www.ninjatrader-support.com/HelpGuideV6/DrawVerticalLine.html

NinjaTrader_Ray
10-22-2007, 06:44 AM
NT 6.5 due out shortly supports sessions that span across midnight and will mark the "session break" and not "day break" like the current production version of NinjaTrader.

Mexie
10-22-2007, 07:22 AM
Great to know Ray, thanks!

KBJ
10-22-2007, 12:43 PM
You might try my TimeScale indicator, which displays the time and date by a red vertical line every hour, and gives the screen a slight background tint during trading hours.

I hadn't posted this before because it needs work for certain intervals. But here it is in case anyone finds it useful.

I put it up when I'm trying to look over a lot of backtest data and can't find which day is which, and it does that pretty well.

You might have to turn off the hourly bars, as sometimes they display the times over what you're looking at, and this is done by setting "DateOnly".

Hope this helps.

KBJ

Mexie
10-22-2007, 09:34 PM
That worked great, thanks!

duck_CA
07-19-2008, 11:23 AM
That indicator works very nice...

Can you tell me if a red line can be plotted every 30min?

thank you

NinjaTrader_Josh
07-19-2008, 12:58 PM
Sure you can but you will need to program it. Use an incremental time filter to draw a red line in the time intervals you want.

motownlucas
06-29-2011, 06:00 PM
I know this is an old thread, but for others that are searching: Below is some simple code to draw something at a given time of day, everyday.

if (Bars.FirstBarOfSession == true)
{
DateTime myTime = DateTime.Parse((Time[0]).ToString("d") + " 9:30 AM");
DrawVerticalLine("myTime" + CurrentBar, myTime, Color.Blue, DashStyle.Dash, 2);
Print(myTime);
}

Just replace " 9:30 AM" with whatever time you want to draw the object, making sure to include a space before the hour numeral.

The print output should look like this: 6/28/2011 9:30:00 AM

NinjaTrader_Matthew
06-29-2011, 06:04 PM
motownlucas,

Thanks for sharing!

ij001
07-02-2011, 06:53 PM
I know this is an old thread, but for others that are searching: Below is some simple code to draw something at a given time of day, everyday.

if (Bars.FirstBarOfSession == true)
{
DateTime myTime = DateTime.Parse((Time[0]).ToString("d") + " 9:30 AM");
DrawVerticalLine("myTime" + CurrentBar, myTime, Color.Blue, DashStyle.Dash, 2);
Print(myTime);
}

Just replace " 9:30 AM" with whatever time you want to draw the object, making sure to include a space before the hour numeral.

The print output should look like this: 6/28/2011 9:30:00 AM

I want to use 10 AM to draw fibonacci line. In this case would I still leave

(Bars.FirstBarOfSession == true) or something different as the IF() statement?

NinjaTrader_Bertrand
07-03-2011, 12:45 AM
You could change the time the draw object would be placed at of course, but the timing when this call would be done is tied to the first bar of the session unless you change the if () condition.

koganam
07-03-2011, 07:22 AM
If you want the drawing to be placed when the session starts, yes.

luxurious_04
07-29-2011, 01:54 AM
I just want to ask about the time filter. I have set a strategy to starts at 8:30 am and ends at 2:15pm and the other strategy is being set to starts at 8:30am also but it will ends at 3:30 pm. Now, I am just confused because when strategy 1 shuts off at 2:15pm and what will happen is that the strategy 2 will also shuts off at 2:15 while I have set it to shut off at 3:30. Any idea on this? Thanks in advance.

NinjaTrader_Bertrand
07-29-2011, 02:01 AM
luxurious_04, what methods are you using to 'shut' the strategies off then? Custom code inside the strategy OnBarUpdate()? This would only be used for the individual strategy instance then and should not influence another running strategy.

luxurious_04
07-29-2011, 02:08 AM
I placed the code like this:

if(Time[0] >= startTime)
{
Print("do something");
}
else if(Time[0] <= endTime )
{
print("-------------------------------------------");
print("strategy 1");
print("time:" +Time[0]);
print("-------------------------------------------");
return;
}

that is inside in the onbarupdate() and the strategy 2 is also the same code.

if(Time[0] >= startTime)
{
Print("do something");
}
else if(Time[0] <= endTime )
{
print("-------------------------------------------");
print("strategy 2");
print("time:" +Time[0]);
print("-------------------------------------------");
return;
}

NinjaTrader_Matthew
07-29-2011, 07:30 AM
Hello,

I'm not sure if that code alone will completely filter for the trading times you had set. I'd suggest putting the conditions that the strategy is running in side a time filter/wrapper so that these conditions are only true between your start time and end time.

For an example of this, please see our SampleTimeFilter reference:

http://www.ninjatrader.com/support/forum/showthread.php?t=3226

luxurious_04
08-04-2011, 09:14 PM
Hello I just want to know the overall function of Disable(); code. If I have two strategies running or enabled and my 1st strategy have the Disable(); code at 2:15 pm. Does the Disable(); code will disable all my enabled strategies at 2:15 pm? Or it will only disable the 1st strategy which have the Disable(); code.

NinjaTrader_RyanM
08-04-2011, 09:24 PM
Hello luxurious_04,

Disable() is not a supported method. If you plan to use, will have to test thoroughly on your end.

We do have a sample available on halting strategy after definable conditions for best practice here:
http://www.ninjatrader.com/support/forum/showthread.php?t=4804