how does ninja see another indicator - NinjaTrader Programming | futures io social day trading
futures io futures trading


how does ninja see another indicator
Updated: Views / Replies:1,892 / 4
Created: by mcteague Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

how does ninja see another indicator

  #1 (permalink)
Elite Member
New York NY USA
 
Futures Experience: Beginner
Platform: esignal, ninjatrader,
Favorite Futures: Stocks
 
Posts: 110 since Oct 2012
Thanks: 54 given, 29 received

how does ninja see another indicator

Hi. First baby steps in indicator creation.

There is an indicator called macd-cross. Which simply checks for crosses of the macd and average line.
I am trying to modify that script to use it with an other indicator. Specifically and indicator called "ergodic" Which basically appears to be a macd style indicator, but based on the TSI. It just seems to give slightly earlier signals than macd.

In any event, in the macd-cross script I do not see how the original MACD indcator is called. It has all the settings for the MACD, but not the code for it, or reference to another script. So I wonder if ninja just automatically executes some other indicator if it is referenced in a script.

I thought that since MACD and ergodic look similar on the the chart that modifying the macd-cross script would be a simple case of swapping variable and a few minor edits.

Can anyone explain how one ninja script calls another? Or I am I just driving down the wrong road.

Thank you.

----
here is the code for macd-cross for reference.


#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
[Description("Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.")]
public class MACDCrossCheck : Indicator
{
#region Variables
// Wizard generated variables
private int fast = 12; // Default setting for Fast
private int slow = 26; // Default setting for Slow
private int smooth = 9; // Default setting for Smooth
// User defined variables (add any user defined variables below)
#endregion


/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Transparent), PlotStyle.Line, "CrossedMarker"));
Overlay = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
if (CrossAbove(MACD(Fast,Slow,Smooth).Default,MACD(Fast,Slow,Smooth).Avg,1) ||
CrossBelow(MACD(Fast,Slow,Smooth).Default,MACD(Fast,Slow,Smooth).Avg,1) )
CrossedMarker.Set(1);
else
CrossedMarker.Set(0);

}

#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries CrossedMarker
{
get { return Values[0]; }
}

[Description("")]
[GridCategory("Parameters")]
public int Fast
{
get { return fast; }
set { fast = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int Slow
{
get { return slow; }
set { slow = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int Smooth
{
get { return smooth; }
set { smooth = Math.Max(1, value); }
}
#endregion
}
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
public partial class Indicator : IndicatorBase
{
private MACDCrossCheck[] cacheMACDCrossCheck = null;

private static MACDCrossCheck checkMACDCrossCheck = new MACDCrossCheck();

/// <summary>
/// Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.
/// </summary>
/// <returns></returns>
public MACDCrossCheck MACDCrossCheck(int fast, int slow, int smooth)
{
return MACDCrossCheck(Input, fast, slow, smooth);
}

/// <summary>
/// Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.
/// </summary>
/// <returns></returns>
public MACDCrossCheck MACDCrossCheck(Data.IDataSeries input, int fast, int slow, int smooth)
{
if (cacheMACDCrossCheck != null)
for (int idx = 0; idx < cacheMACDCrossCheck.Length; idx++)
if (cacheMACDCrossCheck[idx].Fast == fast && cacheMACDCrossCheck[idx].Slow == slow && cacheMACDCrossCheck[idx].Smooth == smooth && cacheMACDCrossCheck[idx].EqualsInput(input))
return cacheMACDCrossCheck[idx];

lock (checkMACDCrossCheck)
{
checkMACDCrossCheck.Fast = fast;
fast = checkMACDCrossCheck.Fast;
checkMACDCrossCheck.Slow = slow;
slow = checkMACDCrossCheck.Slow;
checkMACDCrossCheck.Smooth = smooth;
smooth = checkMACDCrossCheck.Smooth;

if (cacheMACDCrossCheck != null)
for (int idx = 0; idx < cacheMACDCrossCheck.Length; idx++)
if (cacheMACDCrossCheck[idx].Fast == fast && cacheMACDCrossCheck[idx].Slow == slow && cacheMACDCrossCheck[idx].Smooth == smooth && cacheMACDCrossCheck[idx].EqualsInput(input))
return cacheMACDCrossCheck[idx];

MACDCrossCheck indicator = new MACDCrossCheck();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
indicator.Fast = fast;
indicator.Slow = slow;
indicator.Smooth = smooth;
Indicators.Add(indicator);
indicator.SetUp();

MACDCrossCheck[] tmp = new MACDCrossCheck[cacheMACDCrossCheck == null ? 1 : cacheMACDCrossCheck.Length + 1];
if (cacheMACDCrossCheck != null)
cacheMACDCrossCheck.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheMACDCrossCheck = tmp;
return indicator;
}
}
}
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
/// <summary>
/// Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MACDCrossCheck MACDCrossCheck(int fast, int slow, int smooth)
{
return _indicator.MACDCrossCheck(Input, fast, slow, smooth);
}

/// <summary>
/// Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.
/// </summary>
/// <returns></returns>
public Indicator.MACDCrossCheck MACDCrossCheck(Data.IDataSeries input, int fast, int slow, int smooth)
{
return _indicator.MACDCrossCheck(input, fast, slow, smooth);
}
}
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MACDCrossCheck MACDCrossCheck(int fast, int slow, int smooth)
{
return _indicator.MACDCrossCheck(Input, fast, slow, smooth);
}

/// <summary>
/// Check to see if the MACD has crossed either above or below the Avg line and set the plot to 1.
/// </summary>
/// <returns></returns>
public Indicator.MACDCrossCheck MACDCrossCheck(Data.IDataSeries input, int fast, int slow, int smooth)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

return _indicator.MACDCrossCheck(input, fast, slow, smooth);
}
}
}
#endregion

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
NC, USA
 
Futures Experience: None
Platform: None Yet
Favorite Futures: Guitar
 
MrYou's Avatar
 
Posts: 403 since Jun 2011
Thanks: 618 given, 193 received


Its in the OnBarUpdate(). I've added some formatting to make it a little easier to read:

 
Code
if (
   CrossAbove(MACD(Fast,Slow,Smooth).Default,MACD(Fast,Slow,Smooth).Avg,1) 
   ||
   CrossBelow(MACD(Fast,Slow,Smooth).Default,MACD(Fast,Slow,Smooth).Avg,1) 
   )
   CrossedMarker.Set(1);
else
   CrossedMarker.Set(0);
CrossAbove() and CrossBelow() are calling the MACD() indicator for the MACD().Default value and MACD().Avg value, 1 bar back.

See the manual for more info.

Reply With Quote
 
  #4 (permalink)
Elite Member
las vegas
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 836 received

The easiest way to figure how NT "sees" other indicators is to use the strategy wizard and add it to a simple strategy and then unlock the code to see and copy what it did.

Reply With Quote
The following user says Thank You to vegasfoster for this post:
 
  #5 (permalink)
Elite Member
New York NY USA
 
Futures Experience: Beginner
Platform: esignal, ninjatrader,
Favorite Futures: Stocks
 
Posts: 110 since Oct 2012
Thanks: 54 given, 29 received


MrYou View Post
Its in the OnBarUpdate(). I've added some formatting to make it a little easier to read:

 
Code
if (
   CrossAbove(MACD(Fast,Slow,Smooth).Default,MACD(Fast,Slow,Smooth).Avg,1) 
   ||
   CrossBelow(MACD(Fast,Slow,Smooth).Default,MACD(Fast,Slow,Smooth).Avg,1) 
   )
   CrossedMarker.Set(1);
else
   CrossedMarker.Set(0);
CrossAbove() and CrossBelow() are calling the MACD() indicator for the MACD().Default value and MACD().Avg value, 1 bar back.

See the manual for more info.


Thanks.
I seemed to me from looking at the code that a new indicator could use output from an different indicator without including the code of that second indicator. So for example, if I (for some bazaar reason) wrote indicator that simply adds up the value of stochastic, RSI, MACD and ATR, and then averages them that indicator would not have to include the formula or code for those indicators. I would simply point to (or call) those indicators and do the adding and dividing in my new indicator. I was not sure if that was correct. It seems to be.

I am beginning to realize that I am going to need to read a book on C# or find some ninjascript tutorial to get what I want out of this application. There are many things I want it to do that it can, but not out of the box.

Thanks again

Reply With Quote

Reply



futures io > > > > > how does ninja see another indicator

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ninja Indicator to Ninja Strategy emini_Holy_Grail NinjaTrader Programming 10 March 10th, 2013 12:23 AM
Ninja Indicator Interference- Need Help currencychick NinjaTrader Programming 1 July 10th, 2012 09:52 PM
Toggle Indicator Painting in Ninja? drmartell NinjaTrader 16 July 1st, 2012 10:43 PM
jtSwCz Indicator for Ninja 7 Markus NinjaTrader Programming 6 July 1st, 2011 05:37 AM
MetaTrader4 Indicator to a Ninja emini_Holy_Grail NinjaTrader Programming 1 December 18th, 2009 07:48 PM


All times are GMT -4. The time now is 06:22 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.13 seconds with 19 queries on phoenix via your IP 54.160.245.121