NexusFi: Find Your Edge


Home Menu

 





Strategy running in a chart?


Discussion in NinjaTrader

Updated
    1. trending_up 1,038 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,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,710

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?
Quantum physics & Trading dynamics
The Elite Circle
Brendt Skorupinsky
Trading Reviews and Vendors
Forcing plots to disappear/reappear?
NinjaTrader
Pivot Indicator based on Level2 data
NinjaTrader
Help re translation of ninjascript to EL
NinjaTrader
 
  #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,166 since Jan 2013
Thanks Given: 57,753
Thanks Received: 26,364



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,710


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