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

CotReportField.DeralerIntermediaryNet is wrong

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

    CotReportField.DeralerIntermediaryNet is wrong

    I'm trying to create a derivative index of COT data. I noticed when trying to call the CotReportField.DeralerIntermediaryNet it just duplicates the Asset Managers. Everything else is fine.

    Code:
    else if (State == State.DataLoaded)
                {
    
                    cot1 = COT(4);
                    cot1.CotReport1.ReportType    = CotReportType.Futures;
                    cot1.CotReport1.Field        = CotReportField.CommercialNet;
                    cot1.CotReport2.ReportType    = CotReportType.Futures;
                    cot1.CotReport2.Field        = CotReportField.NoncommercialNet;
                    cot1.CotReport3.ReportType    = CotReportType.Futures;
                    cot1.CotReport3.Field        = CotReportField.AssetManagerInstitutionalNet;
                    cot1.CotReport4.ReportType    = CotReportType.Futures;
                    cot1.CotReport4.Field        = CotReportField.DealerIntermediaryNet;
    
                }
            }
    
            protected override void OnBarUpdate()
            {    
                // cot1.Cot1[0] is CommNet, cot1.Cot2[0] is SpecsNet, cot1.Cot3[0] is AssetManagersNet, and cot1.Cot4[0] is DealersNet
    
                if (DoComms)
                {
                    value1            = cot1.Cot1[0] - MIN(cot1.Cot1, Lkbk)[0];
                    value2            = MAX(cot1.Cot1, Lkbk)[0] - MIN(cot1.Cot1, Lkbk)[0];
    
                    COTCommIdx[0]    = (value2 != 0) ? 100.0 * (value1 / value2) : 1;
    
                    if (COTCommIdx[0] > OB || COTCommIdx[0] < OS)
                        PlotBrushes[0][0] = ExtremeClr;
                }
    
                if (DoSpecs)
                {
                    value1            = cot1.Cot2[0] - MIN(cot1.Cot2, Lkbk)[0];
                    value2            = MAX(cot1.Cot2, Lkbk)[0] - MIN(cot1.Cot2, Lkbk)[0];
    
                    COTSpecsIdx[0]    = (value2 != 0) ? 100.0 * (value1 / value2) : 1;
    
                    if (COTSpecsIdx[0] > OB || COTSpecsIdx[0] < OS)
                        PlotBrushes[1][0] = ExtremeClr;
                }
    
                if (DoAssetMan)
                {
                    value1            = cot1.Cot3[0] - MIN(cot1.Cot3, Lkbk)[0];
                    value2            = MAX(cot1.Cot3, Lkbk)[0] - MIN(cot1.Cot3, Lkbk)[0];
    
                    COTAMIdx[0]    = (value2 != 0) ? 100.0 * (value1 / value2) : 1;
    
                    if (COTAMIdx[0] > OB || COTAMIdx[0] < OS)
                        PlotBrushes[2][0] = ExtremeClr;
                }
    
                if (DoDealers)
                {
                    value1            = cot1.Cot4[0] - MIN(cot1.Cot4, Lkbk)[0];
                    value2            = MAX(cot1.Cot4, Lkbk)[0] - MIN(cot1.Cot4, Lkbk)[0];
    
                    COTDlrIdx[0]    = (value2 != 0) ? 100.0 * (value1 / value2) : 1;
    
                    if (COTDlrIdx[0] > OB || COTDlrIdx[0] < OS)
                        PlotBrushes[3][0] = ExtremeClr;
                }
    
            }​

    #2
    Hello Lance El Camino,

    Thank you for your post.

    To see the available combinations of CotReportType and CotReportField, I suggest adding a COT indicator to a chart and seeing the options available when you change between each report type. For example, DealerIntermediaryNet is only an option when you have the report type of Financial futures - futures or Financial futures - combined selected. Programmatically, CotReportField.DealerIntermediaryNet won't have a valid value unless you select CotReportType.FinancialFuturesFutures or CotReportType.FinancialFuturesCombined.

    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      I had the wrong ReportType! Thanks!

      Comment


        #4
        Can I have multiple COT indicators nested into one indicator? This way I can see multiple reports at once?

        Code:
        else if (State == State.DataLoaded)
                    {
                        cot1 = COT(Closes[1], 4);
                        cot1.CotReport1.ReportType    = CotReportType.Futures;
                        cot1.CotReport1.Field        = CotReportField.CommercialNet;
                        cot1.CotReport2.ReportType    = CotReportType.Futures;
                        cot1.CotReport2.Field        = CotReportField.CommercialLong;
                        cot1.CotReport3.ReportType    = CotReportType.Futures;
                        cot1.CotReport3.Field        = CotReportField.CommercialShort;
                        cot1.CotReport4.ReportType    = CotReportType.Futures;
                        cot1.CotReport4.Field        = CotReportField.OpenInterest;
        
                        cot2 = COT(Closes[1], 3);
                        cot2.CotReport1.ReportType    = CotReportType.Futures;
                        cot2.CotReport1.Field        = CotReportField.NoncommercialNet;
                        cot2.CotReport2.ReportType    = CotReportType.Futures;
                        cot2.CotReport2.Field        = CotReportField.NoncommercialLong;
                        cot2.CotReport3.ReportType    = CotReportType.Futures;
                        cot2.CotReport3.Field        = CotReportField.NoncommercialShort;
        
                        cot3 = COT(Closes[1], 3);
                        cot3.CotReport1.ReportType    = CotReportType.FinancialFuturesFutures;
                        cot3.CotReport1.Field        = CotReportField.AssetManagerInstitutionalNet;
                        cot3.CotReport2.ReportType    = CotReportType.FinancialFuturesFutures;
                        cot3.CotReport2.Field        = CotReportField.AssetManagerInstitutionalLong;
                        cot3.CotReport3.ReportType    = CotReportType.FinancialFuturesFutures;
                        cot3.CotReport3.Field        = CotReportField.AssetManagerInstitutionalShort;
        
                        cot4 = COT(Closes[1], 3);
                        cot4.CotReport1.ReportType    = CotReportType.FinancialFuturesFutures;
                        cot4.CotReport1.Field        = CotReportField.DealerIntermediaryNet;
                        cot4.CotReport2.ReportType    = CotReportType.FinancialFuturesFutures;
                        cot4.CotReport2.Field        = CotReportField.DealerIntermediaryLong;
                        cot4.CotReport3.ReportType    = CotReportType.FinancialFuturesFutures;
                        cot4.CotReport3.Field        = CotReportField.DealerIntermediaryShort;
        
                    }​

        Comment


          #5
          Originally posted by Lance El Camino View Post
          Can I have multiple COT indicators nested into one indicator? This way I can see multiple reports at once?

          Code:
          else if (State == State.DataLoaded)
          {
          cot1 = COT(Closes[1], 4);
          cot1.CotReport1.ReportType = CotReportType.Futures;
          cot1.CotReport1.Field = CotReportField.CommercialNet;
          cot1.CotReport2.ReportType = CotReportType.Futures;
          cot1.CotReport2.Field = CotReportField.CommercialLong;
          cot1.CotReport3.ReportType = CotReportType.Futures;
          cot1.CotReport3.Field = CotReportField.CommercialShort;
          cot1.CotReport4.ReportType = CotReportType.Futures;
          cot1.CotReport4.Field = CotReportField.OpenInterest;
          
          cot2 = COT(Closes[1], 3);
          cot2.CotReport1.ReportType = CotReportType.Futures;
          cot2.CotReport1.Field = CotReportField.NoncommercialNet;
          cot2.CotReport2.ReportType = CotReportType.Futures;
          cot2.CotReport2.Field = CotReportField.NoncommercialLong;
          cot2.CotReport3.ReportType = CotReportType.Futures;
          cot2.CotReport3.Field = CotReportField.NoncommercialShort;
          
          cot3 = COT(Closes[1], 3);
          cot3.CotReport1.ReportType = CotReportType.FinancialFuturesFutures;
          cot3.CotReport1.Field = CotReportField.AssetManagerInstitutionalNet;
          cot3.CotReport2.ReportType = CotReportType.FinancialFuturesFutures;
          cot3.CotReport2.Field = CotReportField.AssetManagerInstitutionalLong;
          cot3.CotReport3.ReportType = CotReportType.FinancialFuturesFutures;
          cot3.CotReport3.Field = CotReportField.AssetManagerInstitutionalShort;
          
          cot4 = COT(Closes[1], 3);
          cot4.CotReport1.ReportType = CotReportType.FinancialFuturesFutures;
          cot4.CotReport1.Field = CotReportField.DealerIntermediaryNet;
          cot4.CotReport2.ReportType = CotReportType.FinancialFuturesFutures;
          cot4.CotReport2.Field = CotReportField.DealerIntermediaryLong;
          cot4.CotReport3.ReportType = CotReportType.FinancialFuturesFutures;
          cot4.CotReport3.Field = CotReportField.DealerIntermediaryShort;
          
          }​
          Sure, this could be done and you shouldn't receive any error messages. You would simply need to declare each COT variable at the class level. This could even be done in one line as follows:
          Code:
          private COT cot1, cot2, cot3, cot4;
          Please let us know if we may be of further assistance.
          Emily C.NinjaTrader Customer Service

          Comment


            #6
            When I do this I get the wrong data for cot2, why? See my Print statement. It produces the cot4 data instead.

            Code:
            private COT        cot1, cot2, cot3, cot4;
                    private bool    BullishC, BearishC, BullTransitionC, BearTransitionC, OIrising, OIfalling, BullishS, BearishS, BullTransitionS, BearTransitionS, BullishA, BearishA, BullTransitionA, BearTransitionA,
                                    BullishD, BearishD, BullTransitionD, BearTransitionD;
            
                    protected override void OnStateChange()
                    {
                        if (State == State.SetDefaults)
                        {
                            Description        = @"";
                            Name            = "COT Position Trend";
                            Calculate        = Calculate.OnBarClose;
                            IsOverlay        = false;
            
                            DoComms            = true;
                            DoSpecs            = false;
                            DoAM            = false;
                            DoDlr            = false;
                            DoOI            = true;
            
                            AddPlot(new Stroke(Brushes.Red, 4), PlotStyle.Bar, "CommPosTrend");
                            AddPlot(new Stroke(Brushes.Green, 4), PlotStyle.Bar, "SpecsPosTrend");
                            AddPlot(new Stroke(Brushes.Blue, 4), PlotStyle.Bar, "AssetManPosTrend");
                            AddPlot(new Stroke(Brushes.Orange, 4), PlotStyle.Bar, "DealerPosTrend");
                            AddPlot(new Stroke(Brushes.Purple, 4), PlotStyle.Line, "OItrend");
                            AddLine(new Stroke(Brushes.Black, DashStyleHelper.Dash, 2), 0, "Zero");
                        }
                        else if (State == State.Configure)
                        {
                            AddDataSeries(this.Instrument.FullName, BarsPeriodType.Week, 1);
                        }
                        else if (State == State.DataLoaded)
                        {
                            cot1 = COT(Closes[1], 4);
                            cot1.CotReport1.ReportType    = CotReportType.Futures;
                            cot1.CotReport1.Field        = CotReportField.CommercialNet;
                            cot1.CotReport2.ReportType    = CotReportType.Futures;
                            cot1.CotReport2.Field        = CotReportField.CommercialLong;
                            cot1.CotReport3.ReportType    = CotReportType.Futures;
                            cot1.CotReport3.Field        = CotReportField.CommercialShort;
                            cot1.CotReport4.ReportType    = CotReportType.Futures;
                            cot1.CotReport4.Field        = CotReportField.OpenInterest;
            
                            cot2 = COT(Closes[1], 3);
                            cot2.CotReport1.ReportType    = CotReportType.Futures;
                            cot2.CotReport1.Field        = CotReportField.NoncommercialNet;
                            cot2.CotReport2.ReportType    = CotReportType.Futures;
                            cot2.CotReport2.Field        = CotReportField.NoncommercialLong;
                            cot2.CotReport3.ReportType    = CotReportType.Futures;
                            cot2.CotReport3.Field        = CotReportField.NoncommercialShort;
            
                            cot3 = COT(Closes[1], 3);
                            cot3.CotReport1.ReportType    = CotReportType.FinancialFuturesFutures;
                            cot3.CotReport1.Field        = CotReportField.AssetManagerInstitutionalNet;
                            cot3.CotReport2.ReportType    = CotReportType.FinancialFuturesFutures;
                            cot3.CotReport2.Field        = CotReportField.AssetManagerInstitutionalLong;
                            cot3.CotReport3.ReportType    = CotReportType.FinancialFuturesFutures;
                            cot3.CotReport3.Field        = CotReportField.AssetManagerInstitutionalShort;
            
                            cot4 = COT(Closes[1], 3);
                            cot4.CotReport1.ReportType    = CotReportType.FinancialFuturesFutures;
                            cot4.CotReport1.Field        = CotReportField.DealerIntermediaryNet;
                            cot4.CotReport2.ReportType    = CotReportType.FinancialFuturesFutures;
                            cot4.CotReport2.Field        = CotReportField.DealerIntermediaryLong;
                            cot4.CotReport3.ReportType    = CotReportType.FinancialFuturesFutures;
                            cot4.CotReport3.Field        = CotReportField.DealerIntermediaryShort;
            
                        }
                    }
            
                    protected override void OnBarUpdate()
                    {    
                        // cot1.Cot1[0] is CommNet, cot1.Cot2[0] is SpecsNet
            
                        if (CurrentBars[1] < 2)
                            return;
            
                        if (DoComms)
                        {
                            BullishC            = cot1.Cot2[0] < cot1.Cot2[1] && cot1.Cot3[0] > cot1.Cot3[1];
                            BullTransitionC     = cot1.Cot1[0] < 0 && cot1.Cot2[0] > cot1.Cot2[1] && cot1.Cot3[0] > cot1.Cot3[1];
                            BearishC            = cot1.Cot2[0] > cot1.Cot2[1] && cot1.Cot3[0] < cot1.Cot3[1];
                            BearTransitionC     = cot1.Cot1[0] > 0 && cot1.Cot2[0] > cot1.Cot2[1] && cot1.Cot3[0] > cot1.Cot3[1];
            
                            CommPosTrend[0]    = BullishC ? 2 : BearishC ? -2 : BullTransitionC ? 1 : BearTransitionC ? -1 : 0;
                        }
            
                        if (DoSpecs)
                        {
                            BullishS            = cot2.Cot2[0] > cot2.Cot2[1] && cot2.Cot3[0] < cot2.Cot3[1];
                            BullTransitionS     = cot2.Cot1[0] > 0 && cot2.Cot2[0] > cot2.Cot2[1] && cot2.Cot3[0] > cot2.Cot3[1];
                            BearishS            = cot2.Cot2[0] < cot2.Cot2[1] && cot2.Cot3[0] > cot2.Cot3[1];
                            BearTransitionS     = cot2.Cot1[0] < 0 && cot2.Cot2[0] > cot2.Cot2[1] && cot2.Cot3[0] > cot2.Cot3[1];
            
                            SpecsPosTrend[0]    = BullishS ? 2 : BearishS ? -2 : BullTransitionS ? 1 : BearTransitionS ? -1 : 0;
                            Print(cot2.Cot2[0] + "  " + cot2.Cot2[1] + "  " + Time[0]);
                        }
            
                        if (DoOI)    
                        {
                            OIrising        = cot1.Cot4[0] > cot1.Cot4[1];
                            OIfalling        = cot1.Cot4[0] < cot1.Cot4[1];
            
                            OItrend[0]        = OIrising ? 1 : OIfalling ? -1 : 0;
                        }
            
                        if(Time[0].DayOfWeek == DayOfWeek.Friday)
                            BackBrush = Brushes.LightGray;
            
                        if (DoAM)
                        {
                            BullishA            = cot3.Cot2[0] > cot3.Cot2[1] && cot3.Cot3[0] < cot3.Cot3[1];
                            BullTransitionA     = cot3.Cot1[0] > 0 && cot3.Cot2[0] > cot3.Cot2[1] && cot3.Cot3[0] > cot3.Cot3[1];
                            BearishA        = cot3.Cot2[0] < cot3.Cot2[1] && cot3.Cot3[0] > cot3.Cot3[1];
                            BearTransitionA     = cot3.Cot1[0] < 0 && cot3.Cot2[0] > cot3.Cot2[1] && cot3.Cot3[0] > cot3.Cot3[1];
            
                            AMPosTrend[0]    = BullishA ? 2 : BearishA ? -2 : BullTransitionA ? 1 : BearTransitionA ? -1 : 0;
                        }
                        if (DoDlr)
                        {
                            BullishD            = cot4.Cot2[0] < cot4.Cot2[1] && cot4.Cot3[0] > cot4.Cot3[1];
                            BullTransitionD     = cot4.Cot1[0] < 0 && cot4.Cot2[0] > cot4.Cot2[1] && cot4.Cot3[0] > cot4.Cot3[1];
                            BearishD            = cot4.Cot2[0] > cot4.Cot2[1] && cot4.Cot3[0] < cot4.Cot3[1];
                            BearTransitionD        = cot4.Cot1[0] > 0 && cot4.Cot2[0] > cot4.Cot2[1] && cot4.Cot3[0] > cot4.Cot3[1];
            
                            DlrPosTrend[0]    = BullishD ? 2 : BearishD ? -2 : BullTransitionD ? 1 : BearTransitionD ? -1 : 0;
                        }
                    }​

            Comment


              #7
              Hello Lance El Camino,

              Thank you for your reply.

              I was able to reproduce this by attempting to add multiple COT indicators to a chart. It seems that if you try to modify the COT reports or fields for the second COT, it also changes it for the first COT. I suspect this may actually be a default behavior for the COT indicator and as a workaround you could create copies of the COT indicator in order to add multiple COTs programmatically (or manually to a chart). For example, please see the COTTest indicator I have attached here that is a copy of COT with the necessary parts of the script re-named to prevent errors.

              With this new insight, you would not be able to add multiple instances of COT to one script, though you could add duplicated versions of the indicator to a script such as the following:
              Code:
              private COT cot1;
              private COTTest cot2;
              Thank you for your time and patience.
              Attached Files
              Emily C.NinjaTrader Customer Service

              Comment


                #8
                Thanks! This is what I suspected and is an easy workaround.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DJ888, Today, 10:57 PM
                0 responses
                2 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by MacDad, 02-25-2024, 11:48 PM
                7 responses
                158 views
                0 likes
                Last Post loganjarosz123  
                Started by Belfortbucks, Today, 09:29 PM
                0 responses
                7 views
                0 likes
                Last Post Belfortbucks  
                Started by zstheorist, Today, 07:52 PM
                0 responses
                7 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                151 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Working...
                X