NexusFi: Find Your Edge


Home Menu

 





Time and ToTime in Ninja Trader


Discussion in NinjaTrader

Updated
    1. trending_up 1,772 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 3 attachments




 
Search this Thread

Time and ToTime in Ninja Trader

  #1 (permalink)
 
gfullmer's Avatar
 gfullmer 
Phoenix, AZ
 
Experience: Intermediate
Platform: Nijatrader, TradeStation
Broker: Interactive Brokers
Trading: Stocks, Options
Posts: 11 since Oct 2014
Thanks Given: 15
Thanks Received: 1

I am trying to code a system that is called "Filling the Gap":

Buy a stock when it opens more than 2% lower than the prior day close.
Sell at yesterday's closing price or a the close if yesterday's closing price is never hit.

Only downside to coding this is I want to Sell on the same day it is Bought. I was thinking about doing this with 5 minute bars and closing it at 3:55pm, but then I have to have the time of the Close of yesterday. I am using ToTime and Time, but not sure how to do it.

I guess I could do it daily and then close on the next day's Open.

Thanks,
Glen

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
 
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


Something like this?

What filters would you use to avoid shorting runaway gaps as shown on the chart?



Reply With Quote
Thanked by:
  #4 (permalink)
 
gfullmer's Avatar
 gfullmer 
Phoenix, AZ
 
Experience: Intermediate
Platform: Nijatrader, TradeStation
Broker: Interactive Brokers
Trading: Stocks, Options
Posts: 11 since Oct 2014
Thanks Given: 15
Thanks Received: 1

Thanks Fat Tails. Yes, that is what I was looking for. Have you back tested it? How does it look? Did you use the TIME and ToTime functions to do that or some other function?

As far as a filter, one could look at the size of the gap, but not sure if that is correlated.

Some other filters when that day before was down for the stock, or using QQQ to see if it gaped down as well, or just buying and not shorting.

Any other ideas?

Thanks,
Glen

Follow me on Twitter Started this thread Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


gfullmer View Post
Thanks Fat Tails. Yes, that is what I was looking for. Have you back tested it? How does it look? Did you use the TIME and ToTime functions to do that or some other function?

As far as a filter, one could look at the size of the gap, but not sure if that is correlated.

Some other filters when that day before was down for the stock, or using QQQ to see if it gaped down as well, or just buying and not shorting.

Any other ideas?

Thanks,
Glen


I do not use the ToTime function, but usually create a TimeSpan object which holds the value of the exit time. I then compare the hour and minute of the current time stamp with the TimeSpan object.

Reply With Quote
  #6 (permalink)
 
gfullmer's Avatar
 gfullmer 
Phoenix, AZ
 
Experience: Intermediate
Platform: Nijatrader, TradeStation
Broker: Interactive Brokers
Trading: Stocks, Options
Posts: 11 since Oct 2014
Thanks Given: 15
Thanks Received: 1


Fat Tails View Post
I do not use the ToTime function, but usually create a TimeSpan object which holds the value of the exit time. I then compare the hour and minute of the current time stamp with the TimeSpan object.

I had some issues with the ToTime and Time function so I found the Bars.GetDayBar(1) to get yesterday's close and also to close on today's close to be helpful for back testing. It probably wouldn't work for trading as it trades at close.

Also, I don't want to trade all day like your system does, but only daily and then only on the long side.

I have enclosed a simple example.

Thanks,
Glen

Attached Files
Elite Membership required to download: FillingTheGap.zip
Follow me on Twitter Started this thread Reply With Quote
  #7 (permalink)
 
gfullmer's Avatar
 gfullmer 
Phoenix, AZ
 
Experience: Intermediate
Platform: Nijatrader, TradeStation
Broker: Interactive Brokers
Trading: Stocks, Options
Posts: 11 since Oct 2014
Thanks Given: 15
Thanks Received: 1

Here is an updated version to the FillTheGap strategy.

Attached Files
Elite Membership required to download: FillingTheGap2.zip
Follow me on Twitter Started this thread Reply With Quote




Last Updated on February 8, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts