Time of day? - NinjaTrader | futures io social day trading
futures io futures trading


Time of day?
Updated: Views / Replies:4,330 / 20
Created: by patbateman Attachments:2

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
 2  
 
Thread Tools Search this Thread
 

Time of day?

  #11 (permalink)
Elite Member
NY, NY
 
Futures Experience: None
Platform: T4, NinjaTrader
Favorite Futures: All!
 
patbateman's Avatar
 
Posts: 235 since Mar 2012
Thanks: 113 given, 193 received


NinjaTrader View Post
As it currently stands, it seems that bug is not in NinjaTrader but in your code.

Your thread here - Time of day? - NinjaTrader Support Forum

No it wasn't... that error was in a sample code, and I mentinoed the fix in the post before.

I was going to make another post on your forum (NT support), but I gave up. However here is what I found, and I think it strongly supports a bug in NT:
  • Using the format if (time xxx) { if (strategy / time) { order } } is the only way it will function
  • It will correctly execute the time on some contracts, and not others. Why is this? Bug in the ninjascript?
  • On the contracts where the time clause does not function, it only ignores the <= timeofday clause. In other words, it starts trades at the beginning of the time period, and goes to the close - not the end of the time period.



"A Jedi's strength flows from the force."
-Yoda
Reply With Quote
 
  #12 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received


patbateman View Post
No it wasn't... that error was in a sample code, and I mentinoed the fix in the post before.

I was going to make another post on your forum (NT support), but I gave up. However here is what I found, and I think it strongly supports a bug in NT:
  • Using the format if (time xxx) { if (strategy / time) { order } } is the only way it will function
  • It will correctly execute the time on some contracts, and not others. Why is this? Bug in the ninjascript?
  • On the contracts where the time clause does not function, it only ignores the <= timeofday clause. In other words, it starts trades at the beginning of the time period, and goes to the close - not the end of the time period.


I see, thanks for clarifying. I have since re-read the thread. Two issues I see here. One is your comments on how to evaluate time which is independent from the second issue about orders submitting on some contracts and not on others.

- Time evaluation is simple to isolate, take the order submission out of the "If time condition" and place Print() statements. If you get print statements on bars that you should not be included in the time condition then there must be something wrong with the time condition. We have run tests here on our ToTime() and Time[] (which returns a .NET DateTime structure (not our code) and it works as expected.

Once the time conditions are created and working as expected (without any order submission code) then you can add back in order submission methods. If this is now not working as expected, then likely it has something to do with your strategy order handling settings? That is the first place I would like and I would also enable TraceOrders = true since this will print out any reason why an order submission method is ignored to the NinjaScript Output window.

Reply With Quote
 
  #13 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary



patbateman View Post
No it wasn't... that error was in a sample code, and I mentinoed the fix in the post before.

I was going to make another post on your forum (NT support), but I gave up. However here is what I found, and I think it strongly supports a bug in NT:
  • Using the format if (time xxx) { if (strategy / time) { order } } is the only way it will function
  • It will correctly execute the time on some contracts, and not others. Why is this? Bug in the ninjascript?
  • On the contracts where the time clause does not function, it only ignores the <= timeofday clause. In other words, it starts trades at the beginning of the time period, and goes to the close - not the end of the time period.

@patbateman:

You have written a dirty piece of code with a few bugs and you are complaining about NinjaTrader by making a lot of noise. Did you realize that ?

Actually all those commands are not NinjaScript, but C#, and it would be enough to have a look at the MSDN Library, where these commands are explained. See below

MSDN Library

NinjaTrader may have a few little bugs (all software packages that I know have them), but they are more subtle and will not affect any simple strategies.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #14 (permalink)
Elite Member
NY, NY
 
Futures Experience: None
Platform: T4, NinjaTrader
Favorite Futures: All!
 
patbateman's Avatar
 
Posts: 235 since Mar 2012
Thanks: 113 given, 193 received


Fat Tails View Post
@patbateman:

You have written a dirty piece of code with a few bugs and you are complaining about NinjaTrader by making a lot of noise. Did you realize that ?

Actually all those commands are not NinjaScript, but C#, and it would be enough to have a look at the MSDN Library, where these commands are explained. See below

MSDN Library

NinjaTrader may have a few little bugs (all software packages that I know have them), but they are more subtle and will not affect any simple strategies.

I've been a supporter of Ninjatrader, and have persuaded friends to go with it over other retail platforms... there is a bug in this however. Let me know which code is dirty - unless if you're referring to the cursory example I put in the bullet list, I obviously did not write the whole thing for the sake of time and continuity. I hope it's also obvious to you what my point is (wrapping the ToTime in one if statement versus individual if statements).

I think it's generally well accepted around the board that NT has many bugs, most of them little (such as this apparent one... see my bullet list before attacking me on this) but some of them quite large. I often get the impression that working for NT is stressful, with poor team development and a management that brings the hammer down on them when things don't go their way. A few posts around here have mentioned the performance of strategy development in NT versus how many developers work there. Just my opinion, though.

I still think it's the best retail platform out there for retailers, especially considering the limitations with Easy-Language, and oft-cited poor performance with IB and some other products out there. I'm really looking forward to NT8 - even though they don't have the slightest idea of when it will be ready, and even though it probably won't be around until next year, even if they are planning on it sooner. Software is tough - if Apple has problems with Final Cut and can't get Lion out without big stress on employees (friends)...

"A Jedi's strength flows from the force."
-Yoda

Last edited by patbateman; April 20th, 2012 at 08:42 PM. Reason: IB
Reply With Quote
The following user says Thank You to patbateman for this post:
 
  #15 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


patbateman View Post
I've been a supporter of Ninjatrader, and have persuaded friends to go with it over other retail platforms... there is a bug in this however. Let me know which code is dirty - unless if you're referring to the cursory example I put in the bullet list, I obviously did not write the whole thing for the sake of time and continuity. I hope it's also obvious to you what my point is (wrapping the ToTime in one if statement versus individual if statements).

@patbateman: If a strategy does not work, best you export it and attach it here, then it is more easy to see, where the problem lies. This is what you have published on the NinjaTrader forum:

 
Code
if (SMA(14)[0] > EMA(14)[0]
 && ToTime(Time[0]) >= ToTime(17, 33, 19)
 && ToTime(Time[0]) >= ToTime(18, 33, 19))
 {
 EnterLong(1, "Buy test14");
 }
 if (SMA(14)[0] < EMA(14)[0]
 && ToTime(Time[0]) >= ToTime(17, 33, 19)
 && ToTime(Time[0]) <= ToTime(18, 33, 19))
 {
 ExitLong("Sell test14", "Buy test14");
 }
Just a few comments. Line 1 is already false, as this would normally trigger a long entry with each single bar, if one moving average is above the other, the correct code for a cross entry would be

 
Code
if (SMA(14)[0] > EMA(14)[0] && SMA(14)[1] <= EMA(14)[1]
You were just luckky that NinjaTrader did only take one entry per direction. Maybe you specified this somewhere in the Intialize section, which you did not post. Anyhow the code is not correct.

There is a bug in line 3, as you used ">=" instead of "<="

Line 7 is false in the same way as is line 1.

The whole logic used is false. If you enter a position, if there is a long cross during the specified time interval, and you exit a position for a short cross in that same time interval, then you will end up with a long position, if the last cross was a long cross, and that long position will be held until the close - unless you have disabled ExitOnClose, in that case the position will be held until the next working day.

Two logical errors and a bug, that strategy for sure cannot work correctly.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #16 (permalink)
Elite Member
NY, NY
 
Futures Experience: None
Platform: T4, NinjaTrader
Favorite Futures: All!
 
patbateman's Avatar
 
Posts: 235 since Mar 2012
Thanks: 113 given, 193 received


Fat Tails View Post
@patbateman: If a strategy does not work, best you export it and attach it here, then it is more easy to see, where the problem lies. This is what you have published on the NinjaTrader forum:

 
Code
if (SMA(14)[0] > EMA(14)[0]
 && ToTime(Time[0]) >= ToTime(17, 33, 19)
 && ToTime(Time[0]) >= ToTime(18, 33, 19))
 {
 EnterLong(1, "Buy test14");
 }
 if (SMA(14)[0] < EMA(14)[0]
 && ToTime(Time[0]) >= ToTime(17, 33, 19)
 && ToTime(Time[0]) <= ToTime(18, 33, 19))
 {
 ExitLong("Sell test14", "Buy test14");
 }
Just a few comments. Line 1 is already false, as this would normally trigger a long entry with each single bar, if one moving average is above the other, the correct code for a cross entry would be

 
Code
if (SMA(14)[0] > EMA(14)[0] && SMA(14)[1] <= EMA(14)[1]
You were just luckky that NinjaTrader did only take one entry per direction. Maybe you specified this somewhere in the Intialize section, which you did not post. Anyhow the code is not correct.

There is a bug in line 3, as you used ">=" instead of "<="

Line 7 is false in the same way as is line 1.

The whole logic used is false. If you enter a position, if there is a long cross during the specified time interval, and you exit a position for a short cross in that same time interval, then you will end up with a long position, if the last cross was a long cross, and that long position will be held until the close - unless you have disabled ExitOnClose, in that case the position will be held until the next working day.

Two logical errors and a bug, that strategy for sure cannot work correctly.

I had picked up on that error (this code is sample code I wrote for NT btw) two days ago here - NinjaTrader Support Forum - View Single Post - Time of day?

I also posted two other strategies (one here) that are uploaded and do not work in NT. No bugs in them!

You probably missed my post which is fine, so now you know. The reality however is the bug is prevalent and I'm still working on trying to possibly rid it myself. I will reset the instruments, then reinstall today to see what happens. My bullet list above outlines exactly what happens.

Btw, you don't have to, but since you're going over my code, make your own sample strategy to see how NT functions to this (if you have not already).

"A Jedi's strength flows from the force."
-Yoda
Reply With Quote
 
  #17 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


patbateman View Post
I also posted two other strategies (one here) that are uploaded and do not work in NT. No bugs in them!


The strategy which I found under the link, also has a few bugs. Your code:

 
Code
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (JMA(N, Ph)[0] > JMA2(N, Ph)[1]
				&& ToTime(Time[0]) > 80000
				&& ToTime(Time[0]) < 12000)
            {
                EnterLong(Q, "Buy");
            }

            if (JMA(N, Ph)[0] < JMA2(N, Ph)[1]
				&& ToTime(Time[0]) > 80000
				&& ToTime(Time[0]) < 120000)
            {
                EnterShort(Q, "Short");
            }
		 	if (JMA(N, Ph)[0] > JMA2(N, Ph)[1]
				&& ToTime(Time[0]) > 80000
				&& ToTime(Time[0]) < 120000)
            {
                ExitShort("Cover", "Short");
            }

            if (JMA(N, Ph)[0] < JMA2(N, Ph)[1]
				&& ToTime(Time[0]) > 80000
				&& ToTime(Time[0]) < 120000)
            {
                ExitLong("Sell", "Short");
            }
        }


(1) If you enter a long position via EnterLong(), NinjaTrader will close out short positions.

So you do not need and should not use ExitShort(). This may result in an overfill. Just scrap the ExitLong() and ExitShort() commands.


(2) In one line you used 12,000 instead of 120,000 for the time filter.

Reply With Quote
 
  #18 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


patbateman View Post
I had picked up on that error (this code is sample code I wrote for NT btw) two days ago here - NinjaTrader Support Forum - View Single Post - Time of day?

I also posted two other strategies (one here) that are uploaded and do not work in NT. No bugs in them!

You probably missed my post which is fine, so now you know. The reality however is the bug is prevalent and I'm still working on trying to possibly rid it myself. I will reset the instruments, then reinstall today to see what happens. My bullet list above outlines exactly what happens.

Btw, you don't have to, but since you're going over my code, make your own sample strategy to see how NT functions to this (if you have not already).

Here's an example

namespace NinjaTrader.Strategy
{
public class a0test : Strategy
{
#region Variables
#endregion

protected override void Initialize() {
CalculateOnBarClose = true;
}

protected override void OnBarUpdate() {
//### Only trade between 8am and 12noon
if (ToTime(Time[0]) >= 080000 && ToTime(Time[0]) < 120000) {

DrawText("Hour"+CurrentBar, Time[0].Hour+"", 0, High[0]+(20*TickSize), Color.Blue);
//###
//### Put your order execution code below
//###
}
}

#region Properties
#endregion
}
}

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following 2 users say Thank You to monpere for this post:
 
  #19 (permalink)
Elite Member
NY, NY
 
Futures Experience: None
Platform: T4, NinjaTrader
Favorite Futures: All!
 
patbateman's Avatar
 
Posts: 235 since Mar 2012
Thanks: 113 given, 193 received


monpere View Post
Here's an example

namespace NinjaTrader.Strategy
{
public class a0test : Strategy
{
#region Variables
#endregion

protected override void Initialize() {
CalculateOnBarClose = true;
}

protected override void OnBarUpdate() {
//### Only trade between 8am and 12noon
if (ToTime(Time[0]) >= 080000 && ToTime(Time[0]) < 120000) {

DrawText("Hour"+CurrentBar, Time[0].Hour+"", 0, High[0]+(20*TickSize), Color.Blue);
//###
//### Put your order execution code below
//###
}
}

#region Properties
#endregion
}
}

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

I'll try that right now, thanks allot for sharing -

are the print statements required? I have not been using them, but maybe it's required and that's what I've been missing all along...

"A Jedi's strength flows from the force."
-Yoda
Reply With Quote
 
  #20 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


Print statements are not required.

Print statements can be used for debugging.

If you want to know, which value a specific variable took, while the indicator was running, you can print those values to the NinjaTrader output window.

Just open that window and watch how the values are being printed.

Reply With Quote

Reply



futures io > > > > Time of day?

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
passing the time of day ? profitably euroventure Trading Journals 9 March 30th, 2012 11:52 PM
This Forum's Time of Day Cashish Tech Support 6 November 10th, 2011 12:39 AM
Time of day,and possible time frame sycronization phasganon The Elite Circle 1 September 24th, 2011 12:53 AM
time of day / trend timing TomBear The Elite Circle 1 May 14th, 2010 10:57 AM
Time of day trading TomBear The Elite Circle 5 September 8th, 2009 08:16 AM


All times are GMT -4. The time now is 03:10 PM.

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.17 seconds with 20 queries on phoenix via your IP 54.163.209.109