Go Back   NinjaTrader Support Forum > NinjaTrader 7 > 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 1 time in 1 post
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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 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_JoshP 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 1 time in 1 post
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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 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_JoshP 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 1 time in 1 post
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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 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_JoshP 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 1 time in 1 post
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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 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_JoshP 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 1 time in 1 post
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 1 time in 1 post
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: 118
Thanks: 2
Thanked 9 times in 4 posts
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, 83 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 1 time in 1 post
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: 118
Thanks: 2
Thanked 9 times in 4 posts
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 1 time in 1 post
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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 posts
Default

rtj4201,

You can use DrawText(). http://www.ninjatrader-support.com/H.../DrawText.html
NinjaTrader_JoshP 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 Platform Technical Support 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 Platform Technical Support 1 08-26-2008 10:34 AM


All times are GMT -6. The time now is 06:27 PM.

Futures, foreign currency and options 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.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.