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

cannot implicitly convert 'System.DateTime' to 'double' (CS0029)

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

    #31
    Hi Jim,

    Thanks a lot for the directions and what to look for next.

    I'm not sure how to formulate the expPriorDate.PriorDate[0].ToString() print,
    but I'll look in the documentation and posts for the way to get it printed.

    I'll be back tomorrow.

    Have a good day!

    Be well!

    Comment


      #32
      Originally posted by NinjaTrader_Jim View Post
      Hello Cormick,

      Within the MarketAnalyzerColumn that is not displaying the date when you assign it to CurrentText, does the value have meaningful information before you assign it to CurrentText? I.E. if you print expPriorDate.PriorDate[0].ToString() before assigning to CurrentText, do you see a meaningful result in the output window?

      If you change the datatype to string, does this help?

      Market Analyzer DataType - https://ninjatrader.com/support/help...8/datatype.htm

      We look forward to hearing from you.
      Hi Jim,

      I tested setting the DataType to typeof(string),
      and printing the [I]expPriorDate.PriorDate[0].ToString() value before assigning it to CurrentText.

      Demo Video:

      I set the DataType to typeof(string); in the State.SetDefault section.

      It's not returning the missing dates on the Market Analyzer window.


      I printed next the [I]expPriorDate.PriorDate[0].ToString() value before assigning it to CurrentText.

      It does print in the Output Window

      timestamp: 0:54

      but without the related instruments. So I can't see which instrument-s it's printing the dates for.

      timestamp: 0:54


      I tried adding the foreach() / Print(i.FullName); loop, but it's returning errors.

      timestamps:
      1:09 (CS0103)
      1:50 (CS0103)
      2:28 (CS0030 & CS1061)
      2:53
      3:29 (CS0030 & CS1061)


      How can I add each instrument symbol to the [I]expPriorDate.PriorDate[0].ToString() value before assigning it to CurrentText?

      The Full code:

      Comment


        #33
        he Hi Cormick, thanks for your reply.

        It is expected those writing NinjaScript are at least at intermediate level of C# programming and are able to resolve compilation issues. Unfortunately, the support team will not be able to review or debug code for compiling errors. i.FullName is not within scope of the OnMarketData method, please see this publicly available page on the scope of variables in C#:

        A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.


        If you would like one on one assistance with making this script, please consider a NinjaScript consultant from the NinjaTrader Ecosystem.

        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #34
          Hi Chris,

          Thanks for the scope hint.

          I corrected the code, but errors CS0030 (no doc) and CS1061 (only typos examples) remain:

          protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
          {
          foreach (Instrument i in Instruments)
          {
          Print(i.FullName);
          }

          if (marketDataUpdate.MarketDataType == MarketDataType.Last)
          CurrentText = expPriorDate.PriorDate[0].ToString(CultureInfo.InvariantCulture);
          }

          Click image for larger version  Name:	chrome_gs7iPGXlIP.png Views:	0 Size:	585.1 KB ID:	1166103

          CS0030 Cannot convert type 'NinjaTrader.Cbi.Instrument' to 'NinjaTrader.NinjaScript.MarketAnalyzerColumns.Ins trument'


          CS1061 'NinjaTrader.NinjaScript.MarketAnalyzerColumns.Ins trument' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'NinjaTrader.NinjaScript.MarketAnalyzerColumns.Ins trument' could be found (you are missing a using directive or an assembly reference?)
          In post #28 (https://ninjatrader.com/support/foru...07#post1165507)


          I got the instruments symbols return with the i.FullName variable within the foreach loop scope. Is that the block level error you referred to?
          If so, why does it work for the indicator script (as in post #28 result), but not for the MarketAnalyzerColumns script?



          The documentation link you shared in post #26 (https://ninjatrader.com/support/foru...69#post1165369) also shows the code usage within the foreach/block scope, not the State.DataLoaded/method scope.


          For lack of a MarketAnalyzerColumns example, why then is it returning errors CS0030 and CS1061?



          I also tested as set in the documentation example


          else if (State == State.DataLoaded)
          {
          expPriorDate = myDailyBarsPriorOHLC();

          foreach (Instrument i in Instruments)
          {
          Print(i.FullName);
          }

          Print("PriorDate " + expPriorDate.PriorDate[0].ToString());
          }
          }

          but that too returns errors CS0030 and CS1061:

          Click image for larger version  Name:	chrome_noe87jr70U.png Views:	0 Size:	594.6 KB ID:	1166102




          For lack of a MarketAnalyzerColumns example, why then is it returning errors CS0030 and CS1061 there too?

          Do you have Ninjatrader 8 documentation reference that explain the solution to these errors?

          If no current NT8 documentation is available, what is your solution?

          If you don't know other solution than the scope error you mention, and if the scope update I made is correct, can you please ask a colleague around who might answer this MarketAnalyzerColumn problem.

          Thank you.
          Attached Files
          Last edited by Cormick; 08-02-2021, 11:06 AM.

          Comment


            #35
            Hi Chris,

            I found some more documentation and a working Print example for instruments display from the MarketAnalyzerColumns script.

            The foreach loop works only for the indicator script (c.f. #28 (https://ninjatrader.com/support/foru...07#post1165507)).

            For the MarketAnalyzerColumns script we must use:

            Print(String.Format("{0} is being used as the input series", Instrument.FullName));

            Click image for larger version  Name:	chrome_JH8FRS0xYo.png Views:	0 Size:	410.3 KB ID:	1166108


            Thanks a lot for your help! You rock!

            Attached Files

            Comment


              #36
              Originally posted by NinjaTrader_Jim View Post
              Hello Cormick,

              Within the MarketAnalyzerColumn that is not displaying the date when you assign it to CurrentText, does the value have meaningful information before you assign it to CurrentText? I.E. if you print expPriorDate.PriorDate[0].ToString() before assigning to CurrentText, do you see a meaningful result in the output window?

              If you change the datatype to string, does this help?

              Market Analyzer DataType - https://ninjatrader.com/support/help...8/datatype.htm

              We look forward to hearing from you.

              I got some new results.

              Full code:


              The Output windows Prints do return the Symbols that are already displaying in the Market Analyzer window only.

              I search the copied prints for RTY but did not find it in the prints.

              The Prints .txt:



              Click image for larger version  Name:	NVIDIA_Share_837goSXLbw.png Views:	0 Size:	1.00 MB ID:	1166128

              Click image for larger version  Name:	NVIDIA_Share_XKobUFou7p.png Views:	0 Size:	1.52 MB ID:	1166130

              The prints tell us the symbols are not returned before assigning expPriorDate.PriorDate[0].ToString() to CurrentText.
              Ok. But why?
              What's preventing the missing symbols to display? since the non-missing symbols do display, what's causing the latter to display?

              How could the prints let us know?

              What's required to do next to establish what's preventing the missing symbols to display in the MarketAnalyzerColumns Column?

              Once that established, how to make it display the missing symbols in the MarketAnalyzerColumns Colum?
              Attached Files
              Last edited by Cormick; 08-02-2021, 01:29 PM.

              Comment


                #37
                Hi Cormick,

                Do you see any errors in the log tab of the Control Center? If you do, please share those with me. If not the logic of the script is causing this to happen, in which case the script must be reduced and debugged.

                Kind regards,
                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment


                  #38
                  Hi Chris,

                  Thanks for the log suggestion.

                  The log returns orange errors:

                  2021-08-03 07:37:38:929|2|4|Session Break (Version 8.0.24.2)
                  2021-08-03 07:37:40:257|1|4|Verifying license at primary server...
                  2021-08-03 07:37:40:445|1|4|Type=Simulation State=Verified Start Date=01/01/2005 End Date=01/12/2099
                  2021-08-03 07:37:41:835|1|4|Global simulation mode enabled
                  2021-08-03 07:37:42:463|1|4|Vendor assembly 'XXX' version='1.0.0.1' loaded.
                  2021-08-03 07:37:44:304|1|2|Using IS (is-us-nt-005.ninjatrader.com/XXX)
                  2021-08-03 07:37:44:304|1|4|Automated trading disabled
                  2021-08-03 07:37:44:320|1|4|Auto connecting 'My Interactive Brokers'...
                  2021-08-03 07:37:44:353|1|2|My Interactive Brokers: Primary connection=Connecting, Price feed=Connecting
                  2021-08-03 07:37:44:461|1|32|Order entry hot keys disabled
                  2021-08-03 07:37:44:461|1|4|Auto close enabled=False
                  2021-08-03 07:37:45:710|1|4|Restoring workspace 'TestMarketAnalyzer'...
                  2021-08-03 07:37:46:476|0|2|My Interactive Brokers: Unable to connect to IB TraderWorkstation instance. Please check that TWS is running and that it is configured properly to accept API clients. (Logon failed)
                  2021-08-03 07:37:46:476|1|2|My Interactive Brokers: Primary connection=Disconnected, Price feed=Disconnected
                  2021-08-03 07:38:09:941|1|2|My Continuum: Primary connection=Connecting, Price feed=Connecting
                  2021-08-03 07:38:21:976|1|2|My Continuum: Primary connection=Connected, Price feed=Connected
                  2021-08-03 07:38:22:121|1|2|Time to auto close position='00:00:00', Enabled=False
                  2021-08-03 07:38:22:122|1|2|Using HDS (hds-us-nt-001.ninjatrader.com/XXX)
                  2021-08-03 07:38:22:801|3|4|Failed to resolve instrument for market data: RTYU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:824|3|4|Failed to resolve instrument for market data: RU6U21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: CPEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: MGCQ21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: DDU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: OJEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: PAEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: PLEV21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:825|3|4|Failed to resolve instrument for market data: SBEV21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:826|3|4|Failed to resolve instrument for market data: KCEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:826|3|4|Failed to resolve instrument for market data: KWEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:22:826|3|4|Failed to resolve instrument for market data: GNFN21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:060|3|4|Failed to resolve instrument for market data: CCEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:060|3|4|Failed to resolve instrument for market data: CTEZ21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:060|3|4|Failed to resolve instrument for market data: GDCN21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:060|3|4|Failed to resolve instrument for market data: EMDU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:061|3|4|Failed to resolve instrument for market data: BR6Q21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:061|3|4|Failed to resolve instrument for market data: MX6U21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:061|3|4|Failed to resolve instrument for market data: NE6U21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:061|3|4|Failed to resolve instrument for market data: SA6U21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:061|3|4|Failed to resolve instrument for market data: RBEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:061|3|4|Failed to resolve instrument for market data: ZMEU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:062|3|4|Failed to resolve instrument for market data: FVAU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:375|3|4|Failed to resolve instrument for market data: ULAU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:375|3|4|Failed to resolve instrument for market data: TNAU21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:38:23:376|3|4|Failed to resolve instrument for market data: F.US.M6C.Z20 could not be resolved.
                  2021-08-03 07:38:23:376|3|4|Failed to resolve instrument for market data: F.US.M6S.Z20 could not be resolved.
                  2021-08-03 07:38:23:376|3|4|Failed to resolve instrument for market data: QWV21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:39:02:787|3|4|Failed to resolve instrument for market data: BR6U21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:39:02:944|3|4|Failed to resolve instrument for market data: CCEZ21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:39:02:944|3|4|Failed to resolve instrument for market data: GDCQ21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:39:02:944|3|4|Failed to resolve instrument for market data: GNFQ21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:39:02:944|3|4|Failed to resolve instrument for market data: MGCZ21 is not enabled for real-time quotes and trading.
                  2021-08-03 07:39:04:917|3|4|Failed to resolve instrument for market data: CCEU21 is not enabled for real-time quotes and trading.


                  Click image for larger version  Name:	vmplayer_D3j93FgCx6.png Views:	0 Size:	938.6 KB ID:	1166176


                  The missing dates sorted symbols in the log:


                  BR6Q21
                  BR6U21
                  CCEU21
                  CCEU21
                  CCEZ21
                  CPEU21
                  CTEZ21
                  DDU21
                  EMDU21
                  F.US.M6C.Z20
                  F.US.M6S.Z20
                  FVAU21
                  GDCN21
                  GDCQ21
                  GNFN21
                  GNFQ21
                  KCEU21
                  KWEU21
                  MGCQ21
                  MGCZ21
                  MX6U21
                  NE6U21
                  OJEU21
                  PAEU21
                  PLEV21
                  QWV21
                  RBEU21
                  RTYU21
                  RU6U21
                  SA6U21
                  SBEV21
                  TNAU21
                  ULAU21
                  ZMEU21


                  The missing dates sorted symbols on the Market Analyzer Column:


                  Click image for larger version  Name:	vmplayer_mP64eoMRWn.png Views:	0 Size:	706.8 KB ID:	1166179


                  Why are the given symbols not enabled for real-time? since all of them but GNS M6C M6S and W do return Prior day OHLC values?

                  Click image for larger version  Name:	vmplayer_GNceaZ99H9.png Views:	0 Size:	901.4 KB ID:	1166178

                  How to either enable them, or get them to return their prior dates?
                  Attached Files
                  Last edited by Cormick; 08-03-2021, 01:10 AM.

                  Comment


                    #39
                    Hi Cormick,

                    The Interactive Brokers connection does not have real-time enablements for these instruments. You will need to have real time, non-delayed data for the instruments you are requesting in the Market analyzer. Please contact the Interactive Brokers support team to ensure you have all of these instruments enabled.

                    Kind regards,
                    -ChrisL
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #40
                      Originally posted by NinjaTrader_ChrisL View Post
                      Hi Cormick,

                      The Interactive Brokers connection does not have real-time enablements for these instruments. You will need to have real time, non-delayed data for the instruments you are requesting in the Market analyzer. Please contact the Interactive Brokers support team to ensure you have all of these instruments enabled.

                      Kind regards,
                      -ChrisL
                      Hi Chris,

                      Thanks for the Interactive Brokers info.

                      The IB print reference is the auto-connection I did not use for the test.

                      I tested from the Continuum sim101 account and the results gotten are from this other connection, as you can tell from the symbols names.
                      How to get the symbols on continuum sim 101?

                      Comment


                        #41
                        Hi Cormick, my apologies, I did not see the Continuum connection below the IB connection.

                        The symbols are not enabled on your account. Please write into brokeragesupport at ninjatrader.com to request these instruments.

                        Kind regards,
                        -ChrisL
                        Chris L.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by JoMoon2024, Today, 06:56 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post JoMoon2024  
                        Started by Haiasi, 04-25-2024, 06:53 PM
                        2 responses
                        17 views
                        0 likes
                        Last Post Massinisa  
                        Started by Creamers, Today, 05:32 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post Creamers  
                        Started by Segwin, 05-07-2018, 02:15 PM
                        12 responses
                        1,786 views
                        0 likes
                        Last Post Leafcutter  
                        Started by poplagelu, Today, 05:00 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post poplagelu  
                        Working...
                        X