NexusFi: Find Your Edge


Home Menu

 





Calculate GAP (Close of Prior Day, Open of Current Day)


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one bluemele with 8 posts (0 thanks)
    2. looks_two Fat Tails with 5 posts (1 thanks)
    3. looks_3 sam028 with 1 posts (0 thanks)
    4. looks_4 trendisyourfriend with 1 posts (0 thanks)
    1. trending_up 13,017 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 16 posts
    2. attach_file 2 attachments




 
Search this Thread

Calculate GAP (Close of Prior Day, Open of Current Day)

  #1 (permalink)
 
bluemele's Avatar
 bluemele 
Honolulu, Hawaii
 
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842

How to best calculate prior day close in Ninja? What is the most detailed method as when I find 'last close' it doesn't seem to match w/ Tradestation?

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Ninja Trader 8 Drawing Tools Wanted
NinjaTrader
Looking for an MQL4 MetaTrader programmer/coder
The Elite Circle
NexusFi Journal Challenge - May 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
52 thanks
NexusFi site changelog and issues/problem reporting
46 thanks
Battlestations: Show us your trading desks!
34 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
20 thanks

  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,823
Thanks Received: 4,629


Try in testing Bars.FirstBarOfSession.
If you are in this bar, then Close[1] is the close of the previous day, so you can check if you have a gap or not.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #4 (permalink)
 
bluemele's Avatar
 bluemele 
Honolulu, Hawaii
 
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842


sam028 View Post
Try in testing Bars.FirstBarOfSession.
If you are in this bar, then Close[1] is the close of the previous day, so you can check if you have a gap or not.

Yes, I can do that in an indicator. I was curious if there was already one or if it was built into Ninja at all anywhere?

I will give it a try.

Visit my NexusFi Trade Journal 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,102


bluemele View Post
How to best calculate prior day close in Ninja? What is the most detailed method as when I find 'last close' it doesn't seem to match w/ Tradestation?

Before you do this, three decisions to be taken:

(1) Do you want to display a 24 hour chart including night session or do you only want to display the day session?
(2) Do you want to use last or settlement for yesterday's close?
(3) Do you want to display ETH or RTH open?

Assumption: I assume that you want to

(1) display a 24 hour chart
(2) use the settlement price
(3) use the RTH open

Settlement can only be collected from daily data, RTH open can be only collected from intraday data by using an appropriate session template. So you need

(a) to set up an appropriate session template
(b) to connect to a daily data provider who was the settlement (for example Kinetick EOD)
(c) to code an indicator who does the trick.

(a) Session template for ES is attached.
(b) Data provider ?
(c) Indicator needs to be coded, but just to check you can use the SessionPivots indicator in DailyBars mode (default setting) as it will display yesterday's settlement, and the OpeningRange indicator in RTH mode / second (default setting), which will display today's open. If I merge the indicators and scrap the unwanted rest, they can jointly do what you are looking for. Chart is attached.

Attached Thumbnails
Click image for larger version

Name:	Session Template.PNG
Views:	325
Size:	21.3 KB
ID:	28720   Click image for larger version

Name:	GAP.jpg
Views:	438
Size:	120.4 KB
ID:	28721  
Reply With Quote
The following user says Thank You to Fat Tails for this post:
  #6 (permalink)
 
bluemele's Avatar
 bluemele 
Honolulu, Hawaii
 
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842


Fat Tails View Post
Before you do this, three decisions to be taken:

(1) Do you want to display a 24 hour chart including night session or do you only want to display the day session?
(2) Do you want to use last or settlement for yesterday's close?
(3) Do you want to display ETH or RTH open?

Assumption: I assume that you want to

(1) display a 24 hour chart
(2) use the settlement price
(3) use the RTH open

Settlement can only be collected from daily data, RTH open can be only collected from intraday data by using an appropriate session template. So you need

(a) to set up an appropriate session template
(b) to connect to a daily data provider who was the settlement (for example Kinetick EOD)
(c) to code an indicator who does the trick.

(a) Session template for ES is attached.
(b) Data provider ?
(c) Indicator needs to be coded, but just to check you can use the SessionPivots indicator in DailyBars mode (default setting) as it will display yesterday's settlement, and the OpeningRange indicator in RTH mode / second (default setting), which will display today's open. If I merge the indicators and scrap the unwanted rest, they can jointly do what you are looking for. Chart is attached.

FatTails,

You are right 100%. That is exactly what I want. Let me go through this and give me some time to digest. My C# skills are not great compared to perl or other script based languages, so it would be a long haul for me to create this.

The Instruments I would like to calculate are ES, TF, CL, 6E, GC etc...

With TradeStation it shows it in the Time & Sales window (yesterdays settlement, so I can just calculate it).

Let me go over what you posted and give it some more thought. At the end of the day if I just had yesterdays settlement price in NinjaTrader, then it would be best. I guess I would pull that off a daily chart via EOD data feed from what you are saying.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (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,102


bluemele View Post
FatTails,

You are right 100%. That is exactly what I want. Let me go through this and give me some time to digest. My C# skills are not great compared to perl or other script based languages, so it would be a long haul for me to create this.

The Instruments I would like to calculate are ES, TF, CL, 6E, GC etc...

With TradeStation it shows it in the Time & Sales window (yesterdays settlement, so I can just calculate it).

Let me go over what you posted and give it some more thought. At the end of the day if I just had yesterdays settlement price in NinjaTrader, then it would be best. I guess I would pull that off a daily chart via EOD data feed from what you are saying.

This is the way I pull it:

I use Kinetick EOD (has the settlement price) and Interactive Brokers. I first-connect to Kinetick, so daily data is loaded from Kinetick, and then second-connect to Interactive Brokers, and my intraday-data comes from Interactive Brokers.

Nota: If you do this in SIM-Trading, you cannot execute orders, but it works in real trading or with the simulation account of Interactive Brokers.

Now the pivot indicator collects daily data -> you can look at the NinjaTrader default Pivots indicator how to do that and simply copy the code into your new indicator

For the RTH open you need to divide you trading day into 2 sessions. The open of the first bar of the second session is the value that you look for! So the logic goes as

if <new trading day> then do nothing (this is the Globex open)....
if (Bars.FirstBarOfSession), but not <new trading day>, then collect the open of the current bar....

The new trading day can be checked with Bars.GetTradingDayFromLocal(Time[0]), you need to check the date of the current bar against the date of the previous bar

Have a look at the opening range indicator, it does follow this logic.

Reply With Quote
  #8 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


bluemele View Post
FatTails,

You are right 100%. That is exactly what I want. Let me go through this and give me some time to digest. My C# skills are not great compared to perl or other script based languages, so it would be a long haul for me to create this.

The Instruments I would like to calculate are ES, TF, CL, 6E, GC etc...

With TradeStation it shows it in the Time & Sales window (yesterdays settlement, so I can just calculate it).

Let me go over what you posted and give it some more thought. At the end of the day if I just had yesterdays settlement price in NinjaTrader, then it would be best. I guess I would pull that off a daily chart via EOD data feed from what you are saying.

or go to my pivots look up contracts you interest in
Daily Notes - Metrics for Day Traders

Reply With Quote
  #9 (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,102


cory View Post
or go to my pivots look up contracts you interest in
Daily Notes - Metrics for Day Traders

But then every day you need to enter the values manually...

Reply With Quote
  #10 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,526 since Oct 2009
Thanks Given: 4,167
Thanks Received: 6,018



Fat Tails View Post
But then every day you need to enter the values manually...

He might uses this new indicator too to plot the daily pivots or any other levels:

Reply With Quote





Last Updated on January 19, 2011


© 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