NexusFi: Find Your Edge


Home Menu

 





how to count in nt7 the number of bars that have closed?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one anniebee321 with 5 posts (0 thanks)
    2. looks_two trader1512 with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Xeno with 1 posts (0 thanks)
    1. trending_up 5,138 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

how to count in nt7 the number of bars that have closed?

  #1 (permalink)
 anniebee321 
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
Posts: 138 since Nov 2009
Thanks Given: 64
Thanks Received: 44

i would like my indicator to start recalculating after every 180 bars -- any ideas how i would count the number of bars? many thanks in advance

i had it coded to reset and restart calculating at 7am each day using
if (ResetDaily && ToTime(Time[0]) >= ResetTime*100 && ToTime(Time[1]) < ResetTime*100)

but it does not work :-)

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
What broker to use for trading palladium futures
Commodities
About a successful futures trader who didnt know anythin …
Psychology and Money Management
ZombieSqueeze
Platforms and Indicators
 
  #3 (permalink)
 Xeno 
UK
 
Experience: Intermediate
Platform: Ninja
Broker: Mirus/Zen
Trading: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks Given: 70
Thanks Received: 274


The variable CurrentBar tells you the number of the current bar. It either starts from the start of a strategy, or from the start of the session (can't remember which). In any case,

CurrentBar % 180 == 0

will be true every 180 bars.

Reply With Quote
  #4 (permalink)
 anniebee321 
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
Posts: 138 since Nov 2009
Thanks Given: 64
Thanks Received: 44

thanks xeno

will try and give that - a bash it was written for me so i hope i can amend it - will try today

Started this thread Reply With Quote
  #5 (permalink)
 anniebee321 
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
Posts: 138 since Nov 2009
Thanks Given: 64
Thanks Received: 44

hi xeno,

it doesn't quite work perhaps because i have missing bars during some hours of some days it overlaps days
but thanks for your help on this

Started this thread Reply With Quote
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,465 since Jun 2009
Thanks Given: 33,242
Thanks Received: 101,665

I am rusty, but try Bars.FirstBarOfSession to get that bar number, then compare to CurrentBar.

Something like

 
Code
                            
bool mySignal = ((CurrentBar Bars.FirstBarOfSession) >= 180
If you don't need to start at zero with each new session, then just set a flag every 180 bars (like Xeno showed).

Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
 anniebee321 
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
Posts: 138 since Nov 2009
Thanks Given: 64
Thanks Received: 44

thanks very much mike - that might be it, it looks logical - though my programming is limited
will give it a try

Started this thread Reply With Quote
  #8 (permalink)
 anniebee321 
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
Posts: 138 since Nov 2009
Thanks Given: 64
Thanks Received: 44

woohoo! that works thanks mike

Started this thread Reply With Quote
  #9 (permalink)
 trader1512 
west chester
 
Experience: Intermediate
Platform: NT
Posts: 48 since Oct 2009
Thanks Given: 1
Thanks Received: 55

is there an indicator that will number bars in nt7. the bar numbering indicator that i downloaded starts the first bar at zero and i have not been able to fix it.

thanks

Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090



trader1512 View Post
is there an indicator that will number bars in nt7. the bar numbering indicator that i downloaded starts the first bar at zero and i have not been able to fix it.

thanks

Hi,

Try this one you will get OHLCV as well

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on April 26, 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