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 funk10101, Today, 12:02 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by GLFX005, Today, 03:23 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by nandhumca, Yesterday, 03:41 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by The_Sec, Yesterday, 03:37 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by vecnopus, Today, 06:15 AM
    0 responses
    1 view
    0 likes
    Last Post vecnopus  
    Working...
    X