Nube question. What am i doing wrong? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Nube question. What am i doing wrong?
Updated: Views / Replies:682 / 4
Created: by Ragdoll 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
 

Nube question. What am i doing wrong?

  #1 (permalink)
Elite Member
Walterboro, South Carolina
 
Futures Experience: Intermediate
Platform: ninjatrader, amibroker, thinkorswim
Favorite Futures: futures
 
Posts: 13 since Aug 2013
Thanks: 1 given, 5 received

Nube question. What am i doing wrong?

Ok. I'm familiar with basic coding concepts and I decided to dip my toe into ninjascript. Nothing fancy just an indicator to plot the current ask volume and the current bid volume. I found the appropriate calls and got the code to compile. The problem is with the bid line. Instead of a line it shows up as a tab on the right side of the chart pointing to the value of the ask line.


Thanks in advance,

Ragdoll


Here is the code, I've bolded the lines I think are relevant:


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("Enter the description of your new custom indicator here")]
public class bidaskvol : Indicator
{
#region Variables
// Wizard generated variables
// 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.Red), PlotStyle.Line, "Ask"));
Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "Bid"));
Overlay = false;


}

/// <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.
long askVolume=GetCurrentAskVolume();
long bidVolume=GetCurrentBidVolume();


Plot0.Set(askVolume);
Plot1.Set(bidVolume);
}

#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 Plot0
{
get { return Values[0]; }
}

[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 Plot1
{
get { return Values[1]; }
}

#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 bidaskvol[] cachebidaskvol = null;

private static bidaskvol checkbidaskvol = new bidaskvol();

/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public bidaskvol bidaskvol()
{
return bidaskvol(Input);
}

/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public bidaskvol bidaskvol(Data.IDataSeries input)
{
if (cachebidaskvol != null)
for (int idx = 0; idx < cachebidaskvol.Length; idx++)
if (cachebidaskvol[idx].EqualsInput(input))
return cachebidaskvol[idx];

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

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

bidaskvol[] tmp = new bidaskvol[cachebidaskvol == null ? 1 : cachebidaskvol.Length + 1];
if (cachebidaskvol != null)
cachebidaskvol.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cachebidaskvol = 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>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.bidaskvol bidaskvol()
{
return _indicator.bidaskvol(Input);
}

/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.bidaskvol bidaskvol(Data.IDataSeries input)
{
return _indicator.bidaskvol(input);
}
}
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.bidaskvol bidaskvol()
{
return _indicator.bidaskvol(Input);
}

/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.bidaskvol bidaskvol(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.bidaskvol(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
NC, USA
 
Futures Experience: None
Platform: None Yet
Favorite Futures: Guitar
 
MrYou's Avatar
 
Posts: 403 since Jun 2011
Thanks: 618 given, 193 received


I haven't tried using your code yet, but from looking at it no error is standing out.

Have you tried removing the indicator from your chart and re-adding it? Sometimes I think the drawing options get "stuck" when you've changed something, and you're just reloading (F5) the NinjaScript in the chart.

Reply With Quote
 
  #4 (permalink)
Market Wizard
Sarasota FL
 
Futures Experience: Intermediate
Platform: NinjaTrader, Sierra Chart
Favorite Futures: ES
 
Posts: 3,635 since Jan 2013
Thanks: 26,755 given, 11,114 received
Forum Reputation: Legendary


Ragdoll View Post
Ok. I'm familiar with basic coding concepts and I decided to dip my toe into ninjascript. Nothing fancy just an indicator to plot the current ask volume and the current bid volume. I found the appropriate calls and got the code to compile. The problem is with the bid line. Instead of a line it shows up as a tab on the right side of the chart pointing to the value of the ask line.
...

I'm afraid you're running into a limitation of Ninja Trader 7. It doesn't have the bid/ask data for historical data -- that is, you can get it for the current bar only, which means that you have to accumulate it yourself in real time with your PC left on all the time.... No, I'm not kidding.

This will be changed in NT8, but its release date is still not out.

Here's a note in the Help file for both GetCurrentAskVolume() and GetCurrentBidVolume() :

"Note: When accessed during a historical backtest, the volume of the evaluated bar is substituted."

What that means is that you are plotting the same value for both bid and ask, one plot on top of each other, and it's actually just the total volume. You can check this by going into the Properties dialog for the indicator, and changing the plot of, say, the bid line from Dash Style "Solid" to "Dot" and Width to 3. You will see that you actually have 2 plots with the same values, overlying each other.

If you add the "VOL" indicator to the chart, and set its panel to the same panel number as your bidaskvol indicator and the Scale Justification to the same, you'll see that the volume bars exactly match the bidaskvol plot.

Sorry, man.

To get what you're looking for in NT7, you can look into the Gomi indicator threads here on futures.io (formerly BMT). Try starting here and following the links: https://futures.io/wiki/trading-wiki/GOMRecorder . (You do not want to code this yourself.)

The Gomi package records the tick data and allows plotting of bid/ask data; there are also threads here where people have made backfill data available for download so you don't have to build it up. The Gomi stuff is complex, but you can get a lot of help in the threads.

There is also a Gomi option to use up/downtick data, which is pretty accurate and does work with normal historical data. I suggest reading the threads and using Search a lot.

Or, you can wait for NT8.

Reply With Quote
 
  #5 (permalink)
Elite Member
Walterboro, South Carolina
 
Futures Experience: Intermediate
Platform: ninjatrader, amibroker, thinkorswim
Favorite Futures: futures
 
Posts: 13 since Aug 2013
Thanks: 1 given, 5 received

thanks for the reply. I put a couple of print statements in and you are confirming what I suspected. I am just starting to get a feel for ninjascript and it was driving me nuts.

thanks again for the explanation,

Ragdoll

Reply With Quote

Reply



futures io > > > > > Nube question. What am i doing wrong?

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
Wrong Target Fill steveh3167 NinjaTrader 5 March 26th, 2013 12:21 AM
Everything You Remember About The 1990s Is Wrong kbit News and Current Events 0 June 10th, 2012 02:54 PM
Wrong gift kbit Jokes 1 February 15th, 2012 06:26 PM
Odds Are, It's Wrong kbit Off-Topic 24 November 18th, 2011 04:28 PM
Where white man went wrong kbit Jokes 0 May 29th, 2011 11:56 AM


All times are GMT -4. The time now is 09:00 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-14 in 0.14 seconds with 19 queries on phoenix via your IP 54.221.73.186