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

Simple Indicator Not Working

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

    Simple Indicator Not Working

    I'm trying to put in a new simple indicator, but I can't seem to get it to fire.

    My initialize function is as follows:

    Code:
            protected override void Initialize()
            {
                Overlay                = true;
                this.DrawOnPricePanel = true;
                
                this.GetData();
            }
    the "GetData" function simply looks up prices from a local database on my laptop and draws horizontal lines from it, like this:
    Code:
    //yearly pivot
    DrawHorizontalLine(pivotLevel, false, pivotPrice, Color.Black, DashStyle.Solid, 2);
    However, nothing happens at all. I put a System.Windows.Forms.MessageBox("Test"); call in my Initialize function, and no message box. Am I missing something simple?

    #2
    One note... I did add a reference to System.Data at

    C:\Windows\Microsoft.NET\assembly\GAC_32\System.Da ta\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll

    Maybe this is causing issues?

    Comment


      #3
      that appears to be the issue.

      I used

      C:\Windows\Microsoft.NET\Framework\v2.0.50727\Syst em.Data.dll

      instead and it works

      Comment


        #4
        Hello TradingZen,

        This is more C# related so unfortunately we are unable to support your database access. We support documented NinjaScript in the help guide and the reference samples on these forums.

        One of our members shared a code snippet for accessing a mysql database and this might be a good place to start.


        For a message box, you need the appropriate Using statement added to the indicators that use it. This is also outside our scope of support, but you should be able to use message boxes by first adding.

        using System.Windows.Forms;

        It's not advisable to call a message box from the indicators Initialize() method as Initialize is called for all scripts, not just one. If there's anything you want called only once for a particular indicator, you should use OnStartUp() method for this. This method is new for version 7.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          thanks - actually the messagebox is there just to test. I'm also noticing that exceptions are suppressed - is there a way to see the exceptions generated?

          Comment


            #6
            ...my reasoning is that I don't see any errors, it just stops running.

            for example:

            Code:
            for(int i = 0; i < this.m_dtPivotPrices.Rows.Count; i++)
            {
                 DataRow row = this.m_dtPivotPrices.Rows[i];
                                
                 string pivotLevel = row["PivotLevel"].ToString();
                 int pivotWeight = (int)row["PivotWeight"];
                 double pivotPrice = (double)(decimal)row["PivotPrice"];
                                
                 switch(pivotWeight)
                 {
                      case 1: //daily
                      {
                           Color colorToUse = Color.Black;
                           DashStyle dashStyleToUse = DashStyle.DashDot;
            
                           //..
                           DrawHorizontalLine(pivotLevel, false, pivotPrice, colorToUse, dashStyleToUse, 1);
                           System.Windows.Forms.MessageBox.Show("draw daily");
            I never get to the "draw daily" message, it fails on the DrawHorizontalLine call but I have no message as to why.

            Comment


              #7
              You should see exceptions noted on the log tab of the control center.

              You can work from this reference sample for help trying and catching exceptions.
              Using Try-Catch Blocks
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                perfect, thanks!!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Segwin, 05-07-2018, 02:15 PM
                10 responses
                1,768 views
                0 likes
                Last Post Leafcutter  
                Started by Rapine Heihei, 04-23-2024, 07:51 PM
                2 responses
                30 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by Shansen, 08-30-2019, 10:18 PM
                24 responses
                943 views
                0 likes
                Last Post spwizard  
                Started by Max238, Today, 01:28 AM
                0 responses
                9 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by rocketman7, Today, 01:00 AM
                0 responses
                7 views
                0 likes
                Last Post rocketman7  
                Working...
                X