![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
|
About OnmarketData ,Help Guide Says: This method is not called on historical data.
i'm codifying an indicator about deltas , actually is quite simple but enough to my needs. It use OnMarketData but only gets data for the last bar, even that are lost when reload ninjascript. I can see as indicators like Volume Foot prints has different behavior from NT 6,5 to 7. Now a days can fill whole the chart from several bars ago and I am wondering if there is a new way in NT 7 to get historical prints as well as the bid/ask positions Thanks |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Hi Ramon, the OnMarketData() workings in NT7 would still be for realtime use only - what we've added in NT7 is multiseries indicator support, so you could for example add a bid / last series and then access their historical values in your code.
http://www.ninjatrader.com/support/h...s/nt7/add3.htm http://www.ninjatrader.com/support/h...rical_data.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Bertrand for this post: |
|
|
|
#3 |
|
Member
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
|
It sounds fantastic. I'll try it (if i know how to)
|
|
|
|
|
|
#4 |
|
Member
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
|
I don't know if i understand the correct use of multiseries.
I'm trying something like the next: Code:
protected override void Initialize()
{
CalculateOnBarClose = false;
Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);
Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
BarsRequired = 2;
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
if (FirstTickOfBar)
{
dLastPrice = 0;
dAskPrice = 0;
dBidPrice = 0;
lBidVolume=0;
lAskVolume=0;
lDeltas=0;
}
}
if (Historical)
{
HistoricalBranch();
}
}
protected override void OnMarketData(MarketDataEventArgs e)
{
if (BarsInProgress == 0)
{
CalcDeltas( e.MarketDataType, e.Price, e.Volume);
}
private void HistoricalBranch()
{
if (CurrentBars[0] <= BarsRequired) return;
if (BarsInProgress == 0)
{
}
else if (BarsInProgress == 1)
{
DataType=MarketDataType.Last;
}
else if (BarsInProgress ==2)
{
DataType=MarketDataType.Bid;
}
else if (BarsInProgress == 3)
{
DataType=MarketDataType.Ask;
}
CalcDeltas( DataType, Close[0], (long) Volume[0]);
}
private void CalcDeltas(MarketDataType DataType, double dPrice, long lVolume)
{
if (DataType == MarketDataType.Last)
{
if ((dPrice > dBidPrice ) && (dPrice >= dAskPrice))
// ASK => BUY
{
lAskVolume += lVolume;
lDeltas += lVolume;
}
else
// BID => SELL
{
lBidVolume += lVolume;
lDeltas -= lVolume;
}
// Do things like draw text , diamonds, etc.
DrawThings(dPrice,lAskVolume,lBidVolume,lDeltas);
}
else if (DataType == MarketDataType.Ask)
dAskPrice = dPrice;
else if (DataType == MarketDataType.Bid)
dBidPrice = dPrice;
}
After uncountable variations i've got into a deep rut Any suggestion? |
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Could you please contact me at support at ninjatrader dot com Attn Bertrand with a script I could run here to understand better?
The BIP call is OnMarketData() is meant for distinguishing between different instruments, it would return BIP0 for all series if you only deal with one instrument.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Member
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
|
done.
Thanks in advance Ramon |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Thanks, I received the script and will take a look shortly.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| My chart prints an error from mbtrading.... | XXtrem | Automated Trading | 6 | 01-24-2011 09:02 AM |
| T&S HOD/LOD prints | smeagol | Miscellaneous Support | 1 | 09-28-2010 09:49 AM |
| Cumulative Tape (Prints) | tradercrm | SuperDOM and other Order Entry Windows | 8 | 05-12-2010 06:15 AM |
| Printer Friendly Chart prints? | Turtle Trader | Charting | 3 | 05-01-2010 10:30 AM |
| Different prints for same value? | Burga1 | General Programming | 1 | 12-05-2007 10:45 PM |