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 Big Mike with 1 posts (1 thanks)
    3. looks_3 redratsal with 1 posts (0 thanks)
    4. looks_4 trader1512 with 1 posts (0 thanks)
    1. trending_up 5,988 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
May 26 Deadline Dies at 7.5% as US Strikes Iran During C …
Prediction Markets & Event Contracts
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #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,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577

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




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 X 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,216
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


© 2026 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 - Downloads - Top
no new posts