Trouble with multiple plots on an indicator - NinjaTrader Programming | futures io social day trading
futures io futures trading


Trouble with multiple plots on an indicator
Updated: Views / Replies:2,974 / 3
Created: by eddd 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
 

Trouble with multiple plots on an indicator

  #1 (permalink)
Trading Apprentice
St Louis, Missouri
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: futures - TF
 
Posts: 2 since May 2011
Thanks: 0 given, 0 received

Trouble with multiple plots on an indicator

All help is, of course, greatly appreciated.

I created the following indicator by copy and paste and modify an existing one and adding my own formulas. My goal is simply to make some calculations and show those in the data box on a daily chart. I don't have to show any plots but it's okay if that's necessary in order to show the values in the data box.

The problem I'm having is that I don't understand how to show the multiple values as plots. See the note shown as "(More Important Problem)" to see the error messages I get.

Here's the Indicaor code:

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

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Calculates Ed's custom ranges of a bar.
/// </summary>
[Description("Calculates the range of a bar.")]
public class RangesDailyEd : Indicator
{
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
private double DayRange = 0;
private double CloseOpenRange = 0;
private double CloseOpenPCTofDay = 0;
private double HighRange = 0;
private double LowRange = 0;

protected override void Initialize()
{
Add(new Plot(Color.Orange, PlotStyle.Hash, "DayRange"));
Add(new Plot(Color.Green, PlotStyle.Hash, "CloseOpenRange"));
Add(new Plot(Color.Red, PlotStyle.Hash, "CloseOpenPCTofDay"));
Add(new Plot(Color.Blue, PlotStyle.Hash, "HighR"));
Add(new Plot(Color.Violet, PlotStyle.Hash, "LowRange"));

Plots[0].Pen.DashStyle = DashStyle.Solid;
Plots[4].Pen.DashStyle = DashStyle.Dash;

CalculateOnBarClose = true;
AutoScale = true;
Overlay = false; // Does not plot the indicator on top of price
}

/// <summary>
/// NOTE: (Less Important Problem) Called on each bar update event (incoming tick) but I only need to calculate upon BarClose,
/// and close must be based on data series time frame, e.g. if bar ends at 4:15 pm ET then that's bar close
/// and calculated values should show in data box for the last bar on the chart which it isn't doing now
/// </summary>
protected override void OnBarUpdate()
{

/// Up Day or Close = Open

if (Close[0] >= Open[0])
{
DayRange = (High[0] - Low[0]);
CloseOpenRange = Close[0] - Open[0]; /// will be Positive for an Up day
CloseOpenPCTofDay = CloseOpenRange/DayRange * 100; /// express as positive % to indicate an Up day
HighRange = High[0] - Close[0];
LowRange = Open[0] - Low[0];
/// write the above values in the data box for an Up Day
}
/// Down Day
if (Open[0] > Close[0])
{
DayRange = (High[0] - Low[0]);
CloseOpenRange = Close[0] - Open[0]; /// will be Negative for a Down day
CloseOpenPCTofDay = CloseOpenRange/DayRange * 100; /// express as negative % to indicate a Down day
HighRange = High[0] - Open[0];
LowRange = Close[0] - Low[0];
/// write the above values in the data box for a Down Day
}
/// NOTE: (More Important Problem) How do I set the appropriate values for each variable? Right now it gives this error message
/// for each of the following:
/// 'double' does not contain a definition for 'Set' and no extension method 'Set' accepting a first argument of type 'double'
/// could be found (are you missing a using directive or assembly reference?)
DayRange.Set(DayRange);
CloseOpenRange.Set(CloseOpenRange);
CloseOpenPCTofDay.Set(CloseOpenPCTofDay);
HighRange.Set(HighRange);
LowRange.Set(LowRange);
}
}
}

#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 RangesDailyEd[] cacheRangesDailyEd = null;

private static RangesDailyEd checkRangesDailyEd = new RangesDailyEd();

/// <summary>
/// Calculates the range of a bar.
/// </summary>
/// <returns></returns>
public RangesDailyEd RangesDailyEd()
{
return RangesDailyEd(Input);
}

/// <summary>
/// Calculates the range of a bar.
/// </summary>
/// <returns></returns>
public RangesDailyEd RangesDailyEd(Data.IDataSeries input)
{
if (cacheRangesDailyEd != null)
for (int idx = 0; idx < cacheRangesDailyEd.Length; idx++)
if (cacheRangesDailyEd[idx].EqualsInput(input))
return cacheRangesDailyEd[idx];

lock (checkRangesDailyEd)
{
if (cacheRangesDailyEd != null)
for (int idx = 0; idx < cacheRangesDailyEd.Length; idx++)
if (cacheRangesDailyEd[idx].EqualsInput(input))
return cacheRangesDailyEd[idx];

RangesDailyEd indicator = new RangesDailyEd();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
Indicators.Add(indicator);
indicator.SetUp();

RangesDailyEd[] tmp = new RangesDailyEd[cacheRangesDailyEd == null ? 1 : cacheRangesDailyEd.Length + 1];
if (cacheRangesDailyEd != null)
cacheRangesDailyEd.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheRangesDailyEd = 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>
/// Calculates the range of a bar.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.RangesDailyEd RangesDailyEd()
{
return _indicator.RangesDailyEd(Input);
}

/// <summary>
/// Calculates the range of a bar.
/// </summary>
/// <returns></returns>
public Indicator.RangesDailyEd RangesDailyEd(Data.IDataSeries input)
{
return _indicator.RangesDailyEd(input);
}
}
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Calculates the range of a bar.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.RangesDailyEd RangesDailyEd()
{
return _indicator.RangesDailyEd(Input);
}

/// <summary>
/// Calculates the range of a bar.
/// </summary>
/// <returns></returns>
public Indicator.RangesDailyEd RangesDailyEd(Data.IDataSeries input)
{
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.RangesDailyEd(input);
}
}
}
#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
Orlando, Florida
 
Futures Experience: Advanced
Platform: NinjaTrader, TradeStation, MultiCharts, eSignal, MetaTrader
Favorite Futures: ES
 
Posts: 56 since Aug 2010
Thanks: 3 given, 66 received


Your first problem (less important problem) is controlled by the CalculateOnBarClose setting. In your code, it appears you have this defaulted to true, which means the code should only run on the close of a bar, not every single tick.

The other issue (more important problem) is a data type issue.

private double DayRange = 0;
private double CloseOpenRange = 0;
private double CloseOpenPCTofDay = 0;
private double HighRange = 0;
private double LowRange = 0;

Because this data is of type double, there is no .Set() method. To set the values for the plots, you can use the Values[] array:

Values[0].Set(DayRange);
Values[1].Set(CloseOpenRange);
etc...

Reply With Quote
The following user says Thank You to MooreTech for this post:
 
  #4 (permalink)
Trading Apprentice
St Louis, Missouri
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: futures - TF
 
Posts: 2 since May 2011
Thanks: 0 given, 0 received

MooreTech,
It works.
I really appreciate your assistance.
Ed

Reply With Quote

Reply



futures io > > > > > Trouble with multiple plots on an 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
Looking for indicator that plots Volume POC forrestang NinjaTrader 20 October 15th, 2015 02:45 AM
NT7 Elite Indicator Trouble. taylor NinjaTrader 10 August 11th, 2011 10:07 PM
Can GOMRecorder used to persist indicator plots? molecool NinjaTrader Programming 1 April 7th, 2011 04:33 PM
Ninjatrader indicators without plots jstnbrg NinjaTrader 6 March 2nd, 2011 02:14 AM
Null Plots kenz987 NinjaTrader Programming 7 May 10th, 2010 11:29 PM


All times are GMT -4. The time now is 07:42 PM.

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-17 in 0.11 seconds with 19 queries on phoenix via your IP 54.163.209.109