NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-21-2012, 02:24 PM   #1
dsraider
Senior Member
 
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
Default Variable Sum

I have an indicator which grabs all the trades at ask. It looks like this:

PHP Code:
protected override void OnMarketData(MarketDataEventArgs e)
{
if (
e.MarketDataType == MarketDataType.Ask)
            {
                
askPrice e.Price;
                return;
            }

long    askVolume    e.Volume;
if (
price >= askPrice)
Ask.Set (askVolume);

I then draw Ask on my chart. It plots each trade correctly but simply plots the latest one. I'd like it to keep a running total per bar but am running into trouble. Any tips? Arrays? For loops? Have tried my hand at each but have come up short.
Last edited by dsraider; 01-21-2012 at 02:26 PM.
dsraider is offline  
Reply With Quote
Old 01-22-2012, 04:36 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

dsraider,

This looks like its meant to plot volume. Do you mean its meant to display the total volume at the ask price? What is the "price" variable in this example? Is Ask the data series you are attempting to plot:?

Please keep in mind OnMarketData() is updated every new tick, so your data series Ask will be quite large.

I look forward to helping you resolve your issue.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 01-23-2012, 05:30 AM   #3
dsraider
Senior Member
 
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
Default

Hi Adam,

At second glance, it looks as if I can simply customize the BuySellVolume indicator to suit my needs. One question for clarification, though: does that indicator plot ONLY trades that have actually gone through or is it collecting all Bids and all Asks? I can't do the math that quickly in my head.

Thanks,
DS
dsraider is offline  
Reply With Quote
Old 01-23-2012, 07:11 AM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

dsraider,

It looks like its getting the bid and ask volume depending. Its adding the volume between the last tick and the current tick, assigning it to buy volume or sell volume depending on if there was a buy or sell during that volume quote.

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 01-23-2012, 07:27 AM   #5
dsraider
Senior Member
 
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
Default

Sounds like what I'm looking for.

Thanks for your help
dsraider 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
Sum of indicator no111 Strategy Development 5 01-20-2011 12:30 PM
SUM indicator frankduc Charting 3 08-05-2010 07:32 AM
SUM() but not from position [0] tinkerz General Programming 2 02-09-2010 03:36 PM
Summation (SUM) jcash General Programming 29 07-27-2009 07:10 AM
How to sum 2 time variables pmaglio General Programming 10 02-11-2009 10:29 AM


All times are GMT -6. The time now is 06:57 AM.