Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

A indicator in 100 tick chart use data from 1 tick chart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    A indicator in 100 tick chart use data from 1 tick chart

    I would like to programming a indicator which always get volume info and price inform from 1 tick chart.

    For example, my indicator would like to count total volume of trade at "ask" price and "bid" price in different time frame. ( 1m, 5m, 15m, 1h, 4h, 1 day...)

    Is it possible? is there any reference indicator? Thanks

    #2
    Hello LadGta2018,

    Welcome to the forums!

    There are a couple ways this could be accomplished. One is by creating a multi series NinjaScript that tracks the volume of an added Ask and Bid series and keeps a running total until another data series bar closes for your desired interval.

    Another approach is to use OnMarketDepth() to accumulate volume changes for Ask and Bid. These accumulated values can then be collected and then reset back to 0 using a bar iteration from an additional data series, or they can be collected and reset back to 0 using a timer.

    The code provided below will print out the Bid and Ask volume changes as OnMarketDepth() iterates.

    Code:
    protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate)
    {
        // Print some data to the Output window
        if (marketDepthUpdate.MarketDataType == MarketDataType.Ask && marketDepthUpdate.Operation == Operation.Update)
            Print(string.Format("The most recent ask change is {0} ", marketDepthUpdate.Volume));
    	
    	if (marketDepthUpdate.MarketDataType == MarketDataType.Bid && marketDepthUpdate.Operation == Operation.Update)
            Print(string.Format("The most recent bid change is {0} ",  marketDepthUpdate.Volume));
    }
    For taking the Multi Series approach, I would recommend reviewing the openly available Mutli Series NinjaScript documentation found here for a complete walkthrough for creating and using a multi series script - https://ninjatrader.com/support/help...nstruments.htm

    For taking the OnMarketDepth() approach, I may suggest reviewing the OnMarketDepth() documentation and referencing the SampleCustomEvents example that demonstrates using a timer as well as this method.

    OnMarketDepth() - https://ninjatrader.com/support/help...arketdepth.htm

    SampleCustomEvents - https://ninjatrader.com/support/foru...ead.php?t=5965

    Please let us know if we can be of additional help.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by thanajo, 05-04-2021, 02:11 AM
    3 responses
    467 views
    0 likes
    Last Post tradingnasdaqprueba  
    Started by Christopher_R, Today, 12:29 AM
    0 responses
    10 views
    0 likes
    Last Post Christopher_R  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    166 responses
    2,235 views
    0 likes
    Last Post sidlercom80  
    Started by thread, Yesterday, 11:58 PM
    0 responses
    4 views
    0 likes
    Last Post thread
    by thread
     
    Started by jclose, Yesterday, 09:37 PM
    0 responses
    9 views
    0 likes
    Last Post jclose
    by jclose
     
    Working...
    X