Certain times excluded from trading - NinjaTrader Programming | futures io social day trading
futures io futures trading


Certain times excluded from trading
Updated: Views / Replies:2,265 / 10
Created: by vast 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
 

Certain times excluded from trading

  #1 (permalink)
Elite Member
Australia
 
Futures Experience: Intermediate
Platform: Ninja
 
vast's Avatar
 
Posts: 167 since Jun 2009
Thanks: 154 given, 59 received

Certain times excluded from trading

I am in need again of help. Sorry
I am trying to blank out certain times that I want the strategy to ignore.
The code seems to be ok, but it isn't enforcing it. I have debugged it and the sessions are correct, but for some reason it is not enforcing it on the condition set.
Is there a way of enforcing an open position to exit at 30sec before the session time? I found something on the NInja chat, but couldn't get it to work either.
Any ideas please?

{
// Condition set 1



if (ToTime(Time[0]) >= 083000 && ToTime(Time[0]) < 085700 || (ToTime(Time[0]) >= 090200 && ToTime(Time[0]) <= 092800 ||
(ToTime(Time[0]) >= 093200 && ToTime(Time[0]) < 095800 || (ToTime(Time[0]) >= 100200 && ToTime(Time[0]) <= 102800 ||
(ToTime(Time[0]) >= 103200 && ToTime(Time[0]) < 105800 || (ToTime(Time[0]) >= 110200 && ToTime(Time[0]) <= 115800 ||
(ToTime(Time[0]) >= 120200 && ToTime(Time[0]) <= 125800)))))))
DrawVerticalLine("tag1"+CurrentBar,0,Color.Blue,DashStyle.Dot,3);

{
if (CrossAbove(ECO2NEW(7, 5, 21).Main, EMA(7, 5, 21).Signal, 1)
&& Close[0] > EMA(144)[0]
&& HMA2[0] > HMA2[1]);
{
EnterLong(DefaultQuantity, "LongCross");
}
}

Reply With Quote
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received

I like to write my code so it's easy to follow. I suggest doing that and taking it one step at a time to find the logic error.

 
Code
                            
// do not trade before 4:30am or after 2:30pm
if (ToTime(Time[0]) <= 043000 || ToTime(Time[0]) >= 143000)
return;

// do not trade between 11:30am and 12:30pm
if (ToTime(Time[0]) >= 113000 && ToTime(Time[0]) <= 123000)
return;

// do not trade on Wednesday between 9:25am and 10:15am
if (Time[0].DayOfWeek == DayOfWeek.Friday)
  if (
ToTime(Time[0]) >= 092500 && ToTime(Time[0]) <= 101500)
     return; 
Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #3 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received


ToTime works on your PC time, right?

Reply With Quote
 
  #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received


MXASJ View Post
ToTime works on your PC time, right?

ToTime is just a converter to make it easy to test against using a numbers like 080000 for 08:00:00am (hours:minutes:seconds).

Time[0] is the time of bar 0. So it works for historical data (backtesting) as it's tested against the bar time, not against the current PC clock time. In other words, in real live trading, Time[0] will be based on the time of the last close of the bar, and it's the same for historical.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #5 (permalink)
Elite Member
Australia
 
Futures Experience: Intermediate
Platform: Ninja
 
vast's Avatar
 
Posts: 167 since Jun 2009
Thanks: 154 given, 59 received

Hi Mike
Thanks for the guide. I should do this as it tells me what my code is talking about.
My times seem to be valid. I run the script and the "draw vert lines after the time code draws the lines in all the correct places. What doesn't seem to be happening is the enforcing of it, to the place a trade signal. ie, trades are still being taken in times that I have deemed to be out of bounds.
Any ideas?

Reply With Quote
 
  #6 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received


vast View Post
Hi Mike
Thanks for the guide. I should do this as it tells me what my code is talking about.
My times seem to be valid. I run the script and the "draw vert lines after the time code draws the lines in all the correct places. What doesn't seem to be happening is the enforcing of it, to the place a trade signal. ie, trades are still being taken in times that I have deemed to be out of bounds.
Any ideas?

You have no code telling it not to trade in these times... your code simply draws a plot...

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #7 (permalink)
Elite Member
Australia
 
Futures Experience: Intermediate
Platform: Ninja
 
vast's Avatar
 
Posts: 167 since Jun 2009
Thanks: 154 given, 59 received

Ok. Well I am giving up.
I thought that using the totime sets the parameters and that the trade entry requirements after it will only execute if the totime parameters are met.
Just goes to show how much I understand C# and the Ninja guides.
Oh well. Another idea wasted. I am wasting so much time trying to get a strategy to work.
I am better to go back to my old ways of manually backtesting. I realise that this is a backwards move, but the wizard and Ninja guides are frustrating me.
Thanks Mike for trying to help.

Reply With Quote
 
  #8 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received


vast View Post
Ok. Well I am giving up.
I thought that using the totime sets the parameters and that the trade entry requirements after it will only execute if the totime parameters are met.
Just goes to show how much I understand C# and the Ninja guides.
Oh well. Another idea wasted. I am wasting so much time trying to get a strategy to work.
I am better to go back to my old ways of manually backtesting. I realise that this is a backwards move, but the wizard and Ninja guides are frustrating me.
Thanks Mike for trying to help.

Backtesting can be the wrong path. I've blogged about that.

But, if you are giving up because of ToTime() then you are 99.9% there, in this post I already provided an example specifically showing how not to trade. It's called "return;". You can { Drawyourlines(); return; } and that will prevent the script from continuing further and thereby not executing your Enter() command.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #9 (permalink)
Elite Member
Australia
 
Futures Experience: Intermediate
Platform: Ninja
 
vast's Avatar
 
Posts: 167 since Jun 2009
Thanks: 154 given, 59 received

Thank you Mike. I can't believe that all my problem was a "return;" missing. Aghhh

I promise that I will no longer look at C# programming
I promise that I will no longer look at C# programming
I promise that I will no longer look at C# programming
I promise that I will no longer look at C# programming

Reply With Quote
 
  #10 (permalink)
Member
California
 
Futures Experience: Beginner
Platform: NinjaTrader
 
Posts: 87 since Jun 2009
Thanks: 5 given, 119 received



Big Mike View Post
ToTime is just a converter to make it easy to test against using a numbers like 080000 for 08:00:00am (hours:minutes:seconds).

Time[0] is the time of bar 0. So it works for historical data (backtesting) as it's tested against the bar time, not against the current PC clock time. In other words, in real live trading, Time[0] will be based on the time of the last close of the bar, and it's the same for historical.

Mike

You can also use DateTime.TimeOfDay:

DateTime timeNow = Time[0].TimeOfDay;
TimeSpan timeStart = new TimeSpan (4,30,0);
TimeSpan timeEnd = new TimeSpan (14,30,0);
if (timeNow <= timeStart || timeNow >= timeEnd)
....

Reply With Quote

Reply



futures io > > > > > Certain times excluded from trading

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
Trading Times Indicator Doppio NinjaTrader 7 May 20th, 2016 02:11 PM
LA Times: "Foreign currency trading is easy — an easy way to lose money" shodson News and Current Events 7 April 4th, 2011 10:20 AM
Volatility filtered trading times ZTR Elite Automated Trading 10 September 26th, 2010 11:20 AM
CL trading times inventories impact markets tony2604 Commodities Futures Trading 22 August 15th, 2010 02:02 PM
Eurozone (at Financial Times) Quick Summary News and Current Events 0 May 23rd, 2010 02:10 PM


All times are GMT -4. The time now is 11:37 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-15 in 0.13 seconds with 19 queries on phoenix via your IP 54.163.210.170