NexusFi: Find Your Edge


Home Menu

 





"Minimum bars"


Discussion in NinjaTrader

Updated
    1. trending_up 2,878 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
patbateman's Avatar
 patbateman 
NY, NY
 
Experience: None
Platform: T4, NinjaTrader
Trading: All!
Posts: 235 since Mar 2012
Thanks Given: 113
Thanks Received: 201

I know a strategy has an option to use the minimum bars, however NT7 only does this for the first open.

Is it possible to use some kind of indicator to prevent a strategy from trading before a certain number of bars has elapased?


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114


patbateman View Post
I know a strategy has an option to use the minimum bars, however NT7 only does this for the first open.

Is it possible to use some kind of indicator to prevent a strategy from trading before a certain number of bars has elapased?

I think the problem here is that you need an indicator training period, before you can rely on indicators to execute trades. You should therefore code your strategy in a way that

-> indicators are trained during the first N bars
-> and that trades are only executed once the training period has been completed

I typically use two start dates. The first start date for the indicators, and then the second start date for trade execution. I have serialized the start date allowing me to enter two dates in the dialogue box for the strategy.


Reply With Quote
Thanked by:
  #3 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,951 since Dec 2010
Thanks Given: 3,042
Thanks Received: 2,397



patbateman View Post
I know a strategy has an option to use the minimum bars, however NT7 only does this for the first open.

Is it possible to use some kind of indicator to prevent a strategy from trading before a certain number of bars has elapased?

I am not sure if this helps answer your question, but there is a variable "CurrentBar" built into NT7. This starts out as 0 and increases with each additional bar, so a simple test could be:

if (CurrentBar<50)
return;

Put this at the start of your OnBarUpdate() function and the first time the rest of the code will be executed is on the 51st bar.

Here is the NT7 reference page:
NinjaTrader Version 7


Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: [wiki=NT-Local-Order-Manager-LOM-Guide][/wiki]
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
patbateman's Avatar
 patbateman 
NY, NY
 
Experience: None
Platform: T4, NinjaTrader
Trading: All!
Posts: 235 since Mar 2012
Thanks Given: 113
Thanks Received: 201


NJAMC View Post
I am not sure if this helps answer your question, but there is a variable "CurrentBar" built into NT7. This starts out as 0 and increases with each additional bar, so a simple test could be:

if (CurrentBar<50)
return;

Put this at the start of your OnBarUpdate() function and the first time the rest of the code will be executed is on the 51st bar.

Here is the NT7 reference page:
NinjaTrader Version 7

Definitely what I was after, thanks for point me in the right direction ...I probably could of figured this out myself, but I've been exhausted this week!


Started this thread Reply With Quote
  #5 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,951 since Dec 2010
Thanks Given: 3,042
Thanks Received: 2,397


patbateman View Post
Definitely what I was after, thanks for point me in the right direction ...I probably could of figured this out myself, but I've been exhausted this week!

No problem, one of the reasons I like NexusFi (formerly BMT), it saves me LOTS of time while coding. Someone on here has almost always solved the problem before me. Good luck.


Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: [wiki=NT-Local-Order-Manager-LOM-Guide][/wiki]
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on March 25, 2012


© 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