NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-02-2008, 09:32 PM   #1
Faspomy
Senior Member
 
Join Date: Oct 2008
Location: US&A
Posts: 115
Thanks: 0
Thanked 1 time in 1 post
Default Indicator Attributes for Strategy Question

I am writing in reference to;
http://www.ninjatrader-support.com/v...ead.php?t=3228

I created the following Strategy as a Test for viewing Text in a Strategy based-on an indicator's color (somewhat common in MetaTrader EA's).



PHP Code:
protected override void Initialize()
        {
        
Add(HeikenAshi());
            
Color BarColor;
            
CalculateOnBarClose true;
        }

        
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        
protected override void OnBarUpdate()
        {
            
// Condition set 1
            
if (BarColor == Color.Red);
            {
                
DrawText("My text" CurrentBar"Color=Red"00Color.Black);
            }
            
             if (
BarColor == Color.Lime);
            {
                
DrawText("My text" CurrentBar"Color=Green"00Color.Black); 
How do I get an accurate reading ? As-is, the bars are not being counted and tracked properly.

Thanks.
Last edited by Faspomy; 10-03-2008 at 03:02 AM.
Faspomy is offline  
Reply With Quote
Old 10-03-2008, 07:42 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

Please remove Color BarColor in you intialization and test it.
NinjaTrader_Ben is offline  
Reply With Quote
Old 10-03-2008, 10:16 AM   #3
Faspomy
Senior Member
 
Join Date: Oct 2008
Location: US&A
Posts: 115
Thanks: 0
Thanked 1 time in 1 post
Default

Thanks Ben.

I did that and it still does not track at all properly. I also changed 'Red' and
'Lime' to BarUp and BarDown from the Indicator (shown below).

This Strategy shows that it simply alternates-- every other bar indicates green or red. The Strategy does not seem to be correctly importing the data from the indicator.

What else can I do to accurately track the color changes ? Or, is my NT simply not configured properly ?


PHP Code:
         protected override void Initialize()
        {
        
Add(HeikenAshi());
            
CalculateOnBarClose true;
        }

        
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        
protected override void OnBarUpdate()
        {
            
// Condition set 1
            
if (BarColor == HeikenAshi().BarColorDown);
            {
                
DrawText("My text" CurrentBar"Color=Red"00Color.Black);
            }
            
             if (
BarColor == HeikenAshi().BarColorUp);
            {
                
DrawText("My text" CurrentBar"Color=Red"00Color.Black);
            }
        } 
Last edited by Faspomy; 10-03-2008 at 10:50 AM.
Faspomy is offline  
Reply With Quote
Old 10-03-2008, 10:40 AM   #4
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,


Probably the easiest way to do what you want is would be to build a bool series or string series within the HA indicator then access that series from your strategy. The HA is for visualization only in its current state.

So add code to the HA that will set string values like "green" and "red" then access these via your strategy to build your logic. This link will help:

http://www.ninjatrader-support.com/H...riesClass.html

Give it a try and post your code if you get stuck.
NinjaTrader_Ben is offline  
Reply With Quote
Old 10-03-2008, 11:54 AM   #5
Faspomy
Senior Member
 
Join Date: Oct 2008
Location: US&A
Posts: 115
Thanks: 0
Thanked 1 time in 1 post
Default

Thanks Ben.

are any example files readily available to accompany the information in the link above ?
Faspomy is offline  
Reply With Quote
Old 10-03-2008, 12:05 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

This is the closest we have. Replace the BoolSeries with the StringSeries.
http://www.ninjatrader-support.com/v...ead.php?t=4991

Hope that help.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-03-2008, 12:39 PM   #7
Faspomy
Senior Member
 
Join Date: Oct 2008
Location: US&A
Posts: 115
Thanks: 0
Thanked 1 time in 1 post
Default

Thank you Ben and Josh.
Faspomy is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
custom indicator question kuroro13 General Programming 1 07-29-2008 08:38 AM
Custom indicator question phineas General Programming 4 05-12-2008 10:29 AM
Indicator Question For ninja t Ray prostyle NinjaScript File Sharing Discussion 1 09-19-2007 02:03 PM
Indicator value set and get question (n00b) Wataizo General Programming 3 09-02-2007 05:22 PM
Indicator Titling Question Greg1 Charting 1 04-05-2007 11:57 PM


All times are GMT -6. The time now is 11:43 PM.