NexusFi: Find Your Edge


Home Menu

 





"Minimum bars"


Discussion in NinjaTrader

Updated
    1. trending_up 3,048 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: 202

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?
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
Datafeed for Atas
Platforms and Indicators
Would a node-based workflow for automated trading be useful?
Traders Hideout
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
FootPrintV2 Chart for NT8
1 thanks
BERN ALGOS algo trading journal
1 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Legendary 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,117


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,959 since Dec 2010
Thanks Given: 3,053
Thanks Received: 2,412



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: 202


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,959 since Dec 2010
Thanks Given: 3,053
Thanks Received: 2,412


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