Code for hour minutes and seconds - NinjaTrader | futures io social day trading
futures io futures trading


Code for hour minutes and seconds
Updated: Views / Replies:419 / 8
Created: by victorin Attachments:1

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
 

Code for hour minutes and seconds

  #1 (permalink)
Trading Apprentice
España
 
Futures Experience: Beginner
Platform: ninjatrader
Favorite Futures: futures
 
victorin's Avatar
 
Posts: 14 since Jun 2016
Thanks: 2 given, 3 received

Code for hour minutes and seconds

Hi I have a strategy that I want you to make me a purchase at a specific minute and second hour.

Could you tell me what the correct code to insert into NinjaScript? If you are now 13:25:45 sec and you make me want to purchase at 13:38:14 sec, what would be the correct code?

Thanks and regards.

Reply With Quote
 
  #2 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,321 since Sep 2013
Thanks: 1,629 given, 3,429 received
Forum Reputation: Legendary

You can do it several ways

1. the most correct is with a on time event, that triggers exactly at that time

2. you can check on every incoming tick, if the time has arrived, the disadvantage
is in iliquid market, the order will be trigger after that time, after the first trade

regards,
Ron

Attached Files
Register to download File Type: zip ATimerWithCustomEventTest.zip (1.5 KB, 8 views)
Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #3 (permalink)
Trading Apprentice
España
 
Futures Experience: Beginner
Platform: ninjatrader
Favorite Futures: futures
 
victorin's Avatar
 
Posts: 14 since Jun 2016
Thanks: 2 given, 3 received



rleplae View Post
You can do it several ways

1. the most correct is with a on time event, that triggers exactly at that time

2. you can check on every incoming tick, if the time has arrived, the disadvantage
is in iliquid market, the order will be trigger after that time, after the first trade

regards,
Ron

Thanks Ron, for your help.
The truth is that the strategy makes you just need to run the second, for example at 12:21:17 sec

With the template you sent me I get no place think of it, could you tell me how it should be placed correctly with the data I have in my strategy? This is what I have.

protected override void Initialize()
{
MyTimeSpan = new TimeSpan(8, 0, 0);
CalculateOnBarClose = true;
SetStopLoss("", CalculationMode.Ticks, Stop, false);
SetProfitTarget("", CalculationMode.Ticks, Target);
//SetTrailStop("", CalculationMode.Ticks, Trail, false);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(Time[0].TimeOfDay == MyTimeSpan)
{
EnterLongStop(Close[0] + 5 * TickSize);
}

Reply With Quote
 
  #4 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,321 since Sep 2013
Thanks: 1,629 given, 3,429 received
Forum Reputation: Legendary


victorin View Post
Thanks Ron, for your help.
The truth is that the strategy makes you just need to run the second, for example at 12:21:17 sec

With the template you sent me I get no place think of it, could you tell me how it should be placed correctly with the data I have in my strategy? This is what I have.

protected override void Initialize()
{
MyTimeSpan = new TimeSpan(8, 0, 0);
CalculateOnBarClose = true;
SetStopLoss("", CalculationMode.Ticks, Stop, false);
SetProfitTarget("", CalculationMode.Ticks, Target);
//SetTrailStop("", CalculationMode.Ticks, Trail, false);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(Time[0].TimeOfDay == MyTimeSpan)
{
EnterLongStop(Close[0] + 5 * TickSize);
}

The problem with your code is that it will only check when a new bar is formed.
you are subscribing the even 'onBarUpdate'

You could alternatively also subscribe the onMarketUpdate, that means your
code would then be check for every change in the bid/ask or any trade, at that
moment, you simple check the current time and if necessary fired an order

Reply With Quote
 
  #5 (permalink)
Trading Apprentice
España
 
Futures Experience: Beginner
Platform: ninjatrader
Favorite Futures: futures
 
victorin's Avatar
 
Posts: 14 since Jun 2016
Thanks: 2 given, 3 received


rleplae View Post
The problem with your code is that it will only check when a new bar is formed.
you are subscribing the even 'onBarUpdate'

You could alternatively also subscribe the onMarketUpdate, that means your
code would then be check for every change in the bid/ask or any trade, at that
moment, you simple check the current time and if necessary fired an order



// [Description("trailing stop")]
// [GridCategory("Parameters")]
// public int Trail
// {
// get { return trail; }
// set { trail = Math.Max(1, value); }
// }
#endregion
}
}


Last edited by victorin; July 28th, 2016 at 07:55 AM.
Reply With Quote
 
  #6 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,321 since Sep 2013
Thanks: 1,629 given, 3,429 received
Forum Reputation: Legendary

I think what you want to do is something like this :
(i didn't debug the code, sorry if typos)

 
Code
		protected override void OnMarketData (MarketDataEventArgs e)
		{

                        if (e.MarketDataType == MarketDataType.Last)
                       {
                          if (String.Compare(e.Time.ToString("HHmm"),"0800") >0)
                                EnterLongStop(e.Price + 5 * TickSize);
                        }
                 }

Reply With Quote
 
  #7 (permalink)
Trading Apprentice
España
 
Futures Experience: Beginner
Platform: ninjatrader
Favorite Futures: futures
 
victorin's Avatar
 
Posts: 14 since Jun 2016
Thanks: 2 given, 3 received


rleplae View Post
I think what you want to do is something like this :
(i didn't debug the code, sorry if typos)

 
Code
		protected override void OnMarketData (MarketDataEventArgs e)
		{

                        if (e.MarketDataType == MarketDataType.Last)
                       {
                          if (String.Compare(e.Time.ToString("HHmm"),"0800") >0)
                                EnterLongStop(e.Price + 5 * TickSize);
                        }
                 }

Ok thanks Ron,
but then My TimeSpan is the time I will introduce, where I have to tell the program if MyTimeSpan time = current time to do my operation?

Greetings.


----------------------------------------------------------------------------

protected override void Initialize()
{
MyTimeSpan = new TimeSpan(8, 0, 0);
CalculateOnBarClose = false;
SetStopLoss("", CalculationMode.Ticks, Stop, false);
SetProfitTarget("", CalculationMode.Ticks, Target);
//SetTrailStop("", CalculationMode.Ticks, Trail, false);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(Time[0].TimeOfDay == MyTimeSpan)
{
EnterLongStop(Close[0] + 5 * TickSize);
}

Reply With Quote
 
  #8 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,321 since Sep 2013
Thanks: 1,629 given, 3,429 received
Forum Reputation: Legendary

It is possible to check for a time (like 15 min before and after oil report on Wednesday)
Or you can check for duration since entry of the trade (too slow trade kill it

Both logic you can see in a BOT that i have published in the past for educational purposes:

https://futures.io/elite-automated-trading/32559-ron-s-alpha-trade-method-ninjat...t-bot-22.html#post548753

Reply With Quote
 
  #9 (permalink)
Trading Apprentice
España
 
Futures Experience: Beginner
Platform: ninjatrader
Favorite Futures: futures
 
victorin's Avatar
 
Posts: 14 since Jun 2016
Thanks: 2 given, 3 received


rleplae View Post
It is possible to check for a time (like 15 min before and after oil report on Wednesday)
Or you can check for duration since entry of the trade (too slow trade kill it

Both logic you can see in a BOT that i have published in the past for educational purposes:

https://futures.io/elite-automated-trading/32559-ron-s-alpha-trade-method-ninjat...t-bot-22.html#post548753


Sorry I do not understand what you mean,
thank you.

Reply With Quote

Reply



futures io > > > > Code for hour minutes and seconds

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

FuturesTrader71: TBA

Elite only

Al Brooks: TBA

Elite only

Jigsaw Trading: TBA

Oct 19

RandBots: TBA

Oct 24
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Time wildcard for minutes? (e.g. run at every hour *:44 mins?) Jayswiss NinjaTrader Programming 2 July 16th, 2016 02:31 PM
Posts reloading with #0 every few seconds gregid Tech Support 1 March 31st, 2015 09:40 AM
RangeBarTime indicator does not return seconds, only minutes. Suggestions? MBAGearhead Open E Cry 0 January 27th, 2015 03:42 PM
Best optimization period for 15 minutes and 5 minutes blessedone Elite Automated Trading 1 November 22nd, 2014 10:43 AM
Adding minutes to an hour in easylanguage onava TradeStation 3 March 6th, 2013 05:15 PM


All times are GMT -4. The time now is 07:50 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-09-23 in 0.12 seconds with 20 queries on phoenix via your IP 54.158.21.160