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


Code for hour minutes and seconds
Started: by victorin Views / Replies:270 / 8
Last Reply: Attachments:1

Welcome to futures io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

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: 1,833 since Sep 2013
Thanks: 1,310 given, 2,756 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, 7 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: 1,833 since Sep 2013
Thanks: 1,310 given, 2,756 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

Futures Edge on FIO

What value do you place on the webinars on FIO?

 

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: 1,833 since Sep 2013
Thanks: 1,310 given, 2,756 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: 1,833 since Sep 2013
Thanks: 1,310 given, 2,756 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)
 

Spring Grains Outlook w/Sean Lusk @ Walsh Trading

Elite only

FIO Video Journal Challenge featuring NinjaTrader ($2,000+ of prizes)

April

Process above all else w/Anthony Crudele @ Futures Radio Show

Elite only

Machine Learning - Quantitative Trading w/Martin Froehler @ Quantiacs

Elite only

Market Dynamics w/Peter Davies @ Jigsaw Trading

Elite only

Ask Me Anything w/Patrick Rooney @ Trading Technologies

Apr 18

Ask Me Anything w/FuturesTrader71

Apr 19

Machine Learning w/Kris Longmore

Elite only

Market Analysis w/Dave Forss

Apr 25

Introducing iSystems with Stage 5 Trading

Apr 27
     

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 03:16 PM.

no new posts
Page generated 2017-03-29 in 0.13 seconds with 20 queries on phoenix via your IP 54.147.200.51