NexusFi: Find Your Edge


Home Menu

 





foreach BarsInProgress?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ShruggedAtlas with 6 posts (1 thanks)
    2. looks_two vvhg with 2 posts (0 thanks)
    3. looks_3 bukkan with 1 posts (1 thanks)
    4. looks_4 Fat Tails with 1 posts (1 thanks)
      Best Posters
    1. looks_one bukkan with 1 thanks per post
    2. looks_two Fat Tails with 1 thanks per post
    3. looks_3 jeremytang with 1 thanks per post
    4. looks_4 ShruggedAtlas with 0.2 thanks per post
    1. trending_up 4,107 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

foreach BarsInProgress?

  #11 (permalink)
 
ShruggedAtlas's Avatar
 ShruggedAtlas 
Bloomington
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Stocks
Posts: 191 since Apr 2011
Thanks Given: 78
Thanks Received: 75


jeremytang View Post
Hi ShruggedAtlas,

In the code you've provided, the for loop is redundant... so you can get the exact same effect with it removed.

My question is do you:

1) Want to perform your code on ALL time frames all the time (ie: whenever ANY of the timeframes are updated)

or

2) Only perform your code for the timeframe that is currently being updated

If you fall into category 1, then you need a for loop, and you'll have to reference all the closing prices, highs and lows etc by: Closes[x][0], Highs[x][0] etc. (note the plural).

Otherwise, if you're category 2 you can omit the for loop and access your data using Close[0], High[0] (etc) <-- no plural.

OnBarUpdate is called for each BarsInProgress in turn, and the Close, High (etc) DataSeries are changed to reflect the current BarsInProgress.

I assume you're more likely category 2, because you are referencing SMA, EMA and regressionChannel on the main timeframe (BarsInProgres == 0), am I right? Or do you intend to check the regressionChannel on every timeframe?

Jeremy

Actually I need to reference the indicators for all time frames. What I ended up doing was getting rid of the for loop and accessing the other DataSeries only from within the primary bars update if(BarsInProgress == 0)

it works pretty well overall that way.

"I've missed more than 9,000 shots in my career. I've lost almost 300 games. 26 times, I've been trusted to take the game-winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed."
- Michael Jordan, 5-Time NBA Most Valuable Player, 6-Time NBA Champion
Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
 
  #12 (permalink)
 
ShruggedAtlas's Avatar
 ShruggedAtlas 
Bloomington
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Stocks
Posts: 191 since Apr 2011
Thanks Given: 78
Thanks Received: 75

@Fat Tails

thanks FT - You've given me some new info that help a lot. I realize now that i was causing a lot more work for my cpu than necessary. I got rid of the for loop and it works fine. It is still updating on each tick for every conditions on all time frames so I need to spend some time optimizing the algorithm so it doesn't update the longer time frames needlessly. this will go a long way to increasing the performance...still working on that aspect of it.

"I've missed more than 9,000 shots in my career. I've lost almost 300 games. 26 times, I've been trusted to take the game-winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed."
- Michael Jordan, 5-Time NBA Most Valuable Player, 6-Time NBA Champion
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:




Last Updated on February 17, 2012


© 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