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

Dynamically Adjust Data Series

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

    Dynamically Adjust Data Series

    I'm trying to make my strategy dynamically adjust the data series being analyzed based on the volume that is being traded. Right now I add two data series, then call two indicators for each data series. I know how to make this work using a static number for the two data series, however, I would like to change the data series so that data series 1 is equal to the volume traded in the last bar, and data series 2 is half of that. That way my strategy would automatically adjust throughout the day.

    For example I want to be able to do
    AddDataSeries("ES 06-16", Data.BarsPeriodType.Volume, currentVolume, Data.MarketDataType.Last);
    AddDataSeries("ES 06-16", Data.BarsPeriodType.Volume, currentVolume / 2, Data.MarketDataType.Last);

    I have tried to set currentVolume = BarsArray[0].GetVolume(CurrentBar); and then set State = State.Configure; and then call OnStateChange();. But this does not seem to change anything.

    Any ideas on how to dynamically change data series? I can provide better example code if it would help you understand what I am trying to do.

    #2
    Hello,

    Thank you for the question.

    Yes something this dynamic would not be able to work using the AddDataSeries specifically as you would then need to then remove and re add the script to allow for that change to complete. Unfortunately I do not really see a way for this to be possible using AddDataSeries specifically.

    There is a sample that NinjaTrader_ChelseaB created that utilizes an Addon to perform a BarsRequest on an arbitrary instrument, this is likely the path you would need to follow to do a BarsRequest while the script is enabled.

    The sample is an Indicator, but could be moved into a strategy as well.




    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by guillembm, Yesterday, 11:25 AM
    2 responses
    9 views
    0 likes
    Last Post guillembm  
    Started by junkone, 04-21-2024, 07:17 AM
    9 responses
    68 views
    0 likes
    Last Post jeronymite  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    4 responses
    20 views
    0 likes
    Last Post trilliantrader  
    Started by mgco4you, Yesterday, 09:46 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by wzgy0920, Yesterday, 09:53 PM
    0 responses
    10 views
    0 likes
    Last Post wzgy0920  
    Working...
    X