NexusFi: Find Your Edge


Home Menu

 





"Minimum bars"


Discussion in NinjaTrader

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




 
Search this Thread

"Minimum bars"

  #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: 200

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?
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


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
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395



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: NT-Local-Order-Manager-LOM-Guide
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: 200


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
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395


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 futures.io (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: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on March 25, 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