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

BarRequest Volumetric

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

    BarRequest Volumetric

    hello its my first atempt understanding volumetric bar.
    from sampleAddon i call it like this and im not even sure im rigth

    barsRequest.BarsPeriod = new NinjaTrader.Data.BarsPeriod { BarsPeriodType = BarsPeriodType.Volumetric,VolumetricDeltaType = VolumetricDeltaType.BidAsk,BaseBarsPeriodValue = 5 , MarketDataType = MarketDataType.Bid};


    the probleme is i dont know what to do in callback it print like 5 minutes standard candles

    private void PrintBarsRequest(NinjaTrader.Data.BarsRequest bars)
    {
    outputBox.Text = "REQUESTED BARS: " + bars.Bars.Count + " type" + bars.Bars.BarsType;

    // Process returned bars here. Note: The last returned bar may be a currently in-progress bar
    for (int i = 0; i < bars.Bars.Count; i++)
    {
    // Do whatever you want with the bars
    outputBox.AppendText(string.Format("{0}Time: {1}{0}Open: {2}{0}High: {3}{0}Low: {4}{0}Close: {5}{0}Volume: {6}{0}",
    Environment.NewLine,
    bars.Bars.GetTime(i),
    bars.Bars.GetOpen(i),
    bars.Bars.GetHigh(i),
    bars.Bars.GetLow(i),
    bars.Bars.GetClose(i),
    bars.Bars.GetVolume(i)));

    }
    }

    how i access all the methode of volumetric bar like in ninjascript example?

    #2
    Hello zwan06,

    Welcome to the NinjaTrader forums!

    Code:
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = bars.Bars.BarsSeries.BarsType as
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    
    if (barsType == null)
    return;
    
    try
    {
    for (int barIndex = 0; barIndex < bars.Bars.Count; barIndex++)
    {
    double price;
    NinjaTrader.Code.Output.Process("================= ================================================== ======", PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Bar: " + barIndex, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Trades: " + barsType.Volumes[barIndex].Trades, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Total Volume: " + barsType.Volumes[barIndex].TotalVolume, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Total Buying Volume: " + barsType.Volumes[barIndex].TotalBuyingVolume, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Total Selling Volume: " + barsType.Volumes[barIndex].TotalSellingVolume, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Delta for bar: " + barsType.Volumes[barIndex].BarDelta, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Delta for bar (%): " + barsType.Volumes[barIndex].GetDeltaPercent(), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Delta for Close: " + barsType.Volumes[barIndex].GetDeltaForPrice(bars.Bars.GetClose(barIndex)), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Ask for Close: " + barsType.Volumes[barIndex].GetAskVolumeForPrice(bars.Bars.GetClose(barIndex) ), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Bid for Close: " + barsType.Volumes[barIndex].GetBidVolumeForPrice(bars.Bars.GetClose(barIndex) ), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Volume for Close: " + barsType.Volumes[barIndex].GetTotalVolumeForPrice(bars.Bars.GetClose(barInde x)), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Maximum Ask: " + barsType.Volumes[barIndex].GetMaximumVolume(true, out price) + " at price: " + price, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Maximum Bid: " + barsType.Volumes[barIndex].GetMaximumVolume(false, out price) + " at price: " + price, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Maximum Combined: " + barsType.Volumes[barIndex].GetMaximumVolume(null, out price) + " at price: " + price, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Maximum Positive Delta: " + barsType.Volumes[barIndex].GetMaximumPositiveDelta(), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Maximum Negative Delta: " + barsType.Volumes[barIndex].GetMaximumNegativeDelta(), PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Max seen delta (bar): " + barsType.Volumes[barIndex].MaxSeenDelta, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Min seen delta (bar): " + barsType.Volumes[barIndex].MinSeenDelta, PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("Cumulative delta (bar): " + barsType.Volumes[barIndex].CumulativeDelta, PrintTo.OutputTab1);
    }
    }
    catch { }
    Attached is an example.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea its what i dont understand this code will run for an indicator i guess but in an addon barTypes is not referenced under NinjaTrader.NinjaScript namespace.
      Does the original sample miss a reference? or the code for an addon is different?

      Click image for larger version

Name:	2021-02-01 12_12_30-ZwanDOM - Microsoft Visual Studio.png
Views:	187
Size:	67.1 KB
ID:	1139183

      Comment


        #4
        Hello zwan06,

        Anything that will work in an addon, like the working example I have provided you, will work in an indicator.

        The working example I have provided you exported without any compile errors. Have you modified this example? (Please re-import the original example)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          i copied the first line in addonSample barrequest like the pics show NinjaTrader.NinjaScript.BarTypes doesnt exist.
          i cant go after ..
          not sure why

          Comment


            #6
            Hello zwan06,

            To confirm, you are not using the script I have provided you?

            Try testing this first and confirm this works.

            Then you start to check what is different between your custom script and the one I have provided you.

            Check the using statements are the same first.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              ok i found out needed reference to ninjatrader.vendor.dll

              Comment


                #8
                Hello zwan06,

                The NinjaTrader.Vendor.dll is a necessary component of NinjaTrader and there are many areas this is necessary for.

                If this reference was missing, you have a broken installation.

                Please run the repair from the NinjaTrader installer. This will replace the system replace the system references with the original locations.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  @chelsa i use the sample addon provided by documentation.

                  its usefull but i don't find it friendly enough it not reference all the needed dll like ( ninja editor will do)
                  for example when i open it in visual studio all the xaml design is broken .
                  i dont found yet why but i supose i have again to find the needed dll.
                  see here when i open a sample app i like everything working as expected but here its not the case so i have to search what going on and why the sample cant resovle textinput.background etc.


                  Comment


                    #10
                    Hello zwan06,

                    Below is a link to a post that demonstrates including xaml files in the project and then loading xaml files in the visual designer.


                    Note, NinjaTrader Controls are not designed to load in the visual designer.


                    I am not aware of any dll references that need to be modified for the AddOn Framework NinjaScript Basic.

                    May I confirm you have run the repair from the NinjaTrader installer?
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by jclose, Today, 09:37 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post jclose
                    by jclose
                     
                    Started by WeyldFalcon, 08-07-2020, 06:13 AM
                    10 responses
                    1,413 views
                    0 likes
                    Last Post Traderontheroad  
                    Started by firefoxforum12, Today, 08:53 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post firefoxforum12  
                    Started by stafe, Today, 08:34 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post stafe
                    by stafe
                     
                    Started by sastrades, 01-31-2024, 10:19 PM
                    11 responses
                    169 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X