NexusFi: Find Your Edge


Home Menu

 





Strategy running in a chart?


Discussion in NinjaTrader

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




 
Search this Thread

Strategy running in a chart?

  #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,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

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 Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 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,168 since Jan 2013
Thanks Given: 57,452
Thanks Received: 26,278



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,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709


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 Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:




Last Updated on August 24, 2015


© 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