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

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-11-2009, 12:37 PM   #1
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default Trix

I am new to writing the script code. I would like to put buy and sell indicatiors on Plot 1 or the price chart when the moving average crosses the signal line.

Can anyone get me started.
rtj4201 is offline  
Reply With Quote
Old 03-11-2009, 12:44 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 163 times in 82 posts
Default

rtj4201,

Indicators are placed on a certain plot on startup. After that we do not support moving the indicator to a different plot programmatically.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-11-2009, 12:51 PM   #3
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

What I meant was when the Trix Indicator in Plot 2 indicates a buy or sell based on the signal line crossing the trix line, can I ploy an buy or sell arrow on the price chart?
rtj4201 is offline  
Reply With Quote
Old 03-11-2009, 12:53 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 163 times in 82 posts
Default

In your indicator, use DrawArrowUp(). http://www.ninjatrader-support.com/H...awArrowUp.html

Then be sure to use DrawOnPricePanel = true;
http://www.ninjatrader-support.com/H...ceOnPanel.html
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-11-2009, 01:00 PM   #5
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

Can I take the basic indicator and add this script.
rtj4201 is offline  
Reply With Quote
Old 03-11-2009, 01:06 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 163 times in 82 posts
Default

You can modify any indicator you have. If it is a system indicator you will have to rename it to a different name. Right click -> Save As.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-12-2009, 02:59 PM   #7
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

How do I tell it to do this when the TRIX MA line crosses the signal line?



// Initialize method of a custom indicator
protected override void Initialize()
{
Add(new Plot(Color.Orange, "tag1"));
DrawOnPricePanel = true; // Draw objects now paint on the indicator panel itself
// Paints a red down arrow on the current bar 1 tick below the low
DrawArrowUp("tag1", true, 0, Low[0] - TickSize, Color.Red);
rtj4201 is offline  
Reply With Quote
Old 03-12-2009, 03:02 PM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 163 times in 82 posts
Default

rtj4201,

You should not place such logic in Initialize(). Please move your DrawArrow line of code into the OnBarUpdate() method. From there you can code an if-statement to draw the arrow.

Untested code.
Code:
if (CrossAbove(TRIX(20, 3).Default, TRIX(20, 3).Signal, 1))
     DrawArrowUp(...);
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-12-2009, 06:17 PM   #9
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

if (CrossAbove(TRIX(20, 3).Default, TRIX(20, 3).Signal, 1))
DrawArrowUp("tag1", true, 0, Low[0] - TickSize, Color.Red);
rtj4201 is offline  
Reply With Quote
Old 03-12-2009, 06:23 PM   #10
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

What about the other lines of code?

{
if (CrossAbove(TRIX(20, 3).Default, TRIX(20, 3).Signal, 1))
Add(new Plot(Color.Orange, "tag1"));

DrawOnPricePanel = true;
DrawArrowUp("tag1", true, 0, Low[0] - TickSize, Color.Red);
}
rtj4201 is offline  
Reply With Quote
Old 03-12-2009, 08:33 PM   #11
nkhoi
Senior Member
 
Join Date: Nov 2004
Location: , ,
Posts: 110
Thanks: 1
Thanked 1 time in 1 post
Default trix with arrow

note: you can safely comment out plot1, plot0 color codes, they don't do anything.
Attached Files
File Type: zip TRIXc.zip (5.7 KB, 78 views)
nkhoi is offline  
Reply With Quote
Old 03-12-2009, 09:31 PM   #12
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

Can you update it so that it gives a down arrow when TRIX crosses below the signal line?
rtj4201 is offline  
Reply With Quote
Old 03-12-2009, 09:44 PM   #13
nkhoi
Senior Member
 
Join Date: Nov 2004
Location: , ,
Posts: 110
Thanks: 1
Thanked 1 time in 1 post
Default

Quote:
Originally Posted by rtj4201 View Post
Can you update it so that it gives a down arrow when TRIX crosses below the signal line?
the code for down arrow is already in there


// if (CrossBelow(TRIX(period, signalPeriod).Default, 0,1))
if (CrossBelow(TRIX(period, signalPeriod).Default, TRIX(period, signalPeriod).Signal, 1))
DrawArrowDown("MyArrowDown"+CurrentBar, 0, High[0]+2* TickSize, Color.Orange);

// if (CrossAbove(TRIX(period, signalPeriod).Default, 0,1))
if (CrossAbove(TRIX(period, signalPeriod).Default, TRIX(period, signalPeriod).Signal, 1))
DrawArrowUp("MyArrowUp"+CurrentBar, 0, Low[0] -2* TickSize, Color.Red);
nkhoi is offline  
Reply With Quote
Old 03-13-2009, 08:23 AM   #14
rtj4201
Senior Member
 
Join Date: Jan 2009
Posts: 347
Thanks: 0
Thanked 0 times in 0 posts
Default

Thx, it works

How would I write BUY or SELL above or below on the price chart above or below the signal?
rtj4201 is offline  
Reply With Quote
Old 03-13-2009, 08:30 AM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 163 times in 82 posts
Default

rtj4201,

You can use DrawText(). http://www.ninjatrader-support.com/H.../DrawText.html
NinjaTrader_Josh 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
Trix Histogram T2020 Indicator Development 0 03-03-2009 10:08 AM
Drawing lines on Trix indie - broken? 5iver Charting 17 01-09-2009 01:20 PM
adding a couple features to the trix jaybird151 Indicator Development 1 10-26-2008 05:13 PM
Using the TRIX Stainless2000 ATM Strategies (Discretionary Trading) 1 08-26-2008 10:34 AM


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

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.