NexusFi: Find Your Edge


Home Menu

 





Strategy running in a chart?


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,971 since Jun 2009
Thanks Given: 534
Thanks Received: 3,711

A strategy I wrote worked fine for me in a live market but my partner running it in his system had problems. I later realized I was running the strategy in a chart and he was just running it from the "Strategies" tab in Control Center without having added it to any chart. This was causing it to break because something I was doing (adjusting BarsArray[0].BarsData.To) assumes it is running in a chart.

So I wrote this little helper property to help me. Maybe it'll help some of you...

 
Code
bool RunningInAChart
{
  get
  {
    return ChartControl != null && ChartControl.BarsArray != null && ChartControl.BarsArray[0] != null && ChartControl.BarsArray[0].BarsData != null;
  }
}


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
$12M Ceasefire Contract Goes Disputed as Bandar Abbas St …
Prediction Markets & Event Contracts
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
Iran Airspace Contract Surges to 33.5% as Project Freedo …
Prediction Markets & Event Contracts
NinjaTrader Parent Payward Acquires Bitnomial for $550M …
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
20 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
5 thanks
  #3 (permalink)
 
bobwest's Avatar
 bobwest 
Western Florida
Site Moderator
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES, YM
Frequency: Several times daily
Duration: Minutes
Posts: 8,174 since Jan 2013
Thanks Given: 57,989
Thanks Received: 26,406



Quoting 
return ChartControl != null && ChartControl.BarsArray != null && ChartControl.BarsArray[0] != null && ChartControl.BarsArray[0].BarsData != null;

Ah, I have seen the test for ChartControll != null, etc., but was never sure of the point of it. Now I can see it, for something that may not be run on a chart.

Correct me if I'm wrong, but I don't think there is any point to this test in an indicator, which must be run on a chart, right? (I don't usually write strategies.)

Anyway, thanks for this!

Bob.


Reply With Quote
  #4 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,971 since Jun 2009
Thanks Given: 534
Thanks Received: 3,711


bobwest View Post
Ah, I have seen the test for ChartControll != null, etc., but was never sure of the point of it. Now I can see it, for something that may not be run on a chart.

Correct me if I'm wrong, but I don't think there is any point to this test in an indicator, which must be run on a chart, right? (I don't usually write strategies.)

Anyway, thanks for this!

Bob.

If you run a strategy that uses your indicator and the strategy isn't added to a chart the indicator might fail, depending on what you're trying to do.


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:




Last Updated on August 24, 2015


© 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