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

What do I need to learn programming NinjaScript?

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

    #16
    tracoder, which CalculateOnBarClose do you use here for the script?
    BertrandNinjaTrader Customer Service

    Comment


      #17
      I've tried both true & false for CalculateOnBarClose but the situation is still the same.

      Comment


        #18
        It would need to be further isolated then, would you see the same if you close out any unneeded applications running in the background, as well as other workspaces / chart potentially run on COBC = false?

        Generally C# is a managed, yet powerful and performing language and we would run all your scripts in compiled state for highest runtime performance possible.
        BertrandNinjaTrader Customer Service

        Comment


          #19
          I tried all ways but could not improve the situation. Forget it. I will return to the problem when my programming already reaches a higher level.

          Thank you for your passionate help, Bertrand.

          Comment


            #20
            Originally posted by NinjaTrader_Bertrand View Post
            It would need to be further isolated then, would you see the same if you close out any unneeded applications running in the background, as well as other workspaces / chart potentially run on COBC = false?

            Generally C# is a managed, yet powerful and performing language and we would run all your scripts in compiled state for highest runtime performance possible.
            Hi Bertrand,

            It has been quite a long time since my last post. I have just figured out a way to track my mouse move real-time. However, I dont understand why the code just work fine when I start a new chart and attach the indicator to the chart. When it is working nicely, if I remove the indicator then re-add it, or if I change the instrument, the indicator stops working.

            Could you please let me know some reason? Thank you!

            Here is my code, which displays the X and Y coordinates of mouse location in real time:

            Code:
                #region Variables
                    // Wizard generated variables
                        private int myInput0 = 1; // Default setting for MyInput0
                    // User defined variables (add any user defined variables below)
            		private int X = 0, Y = 0;
                    #endregion
            		
                    protected override void Initialize() {
            			Overlay				= true;
            			CalculateOnBarClose = true;
            			
                    }
            		
            		protected override void OnStartUp() {
            			ChartControl.ChartPanel.Paint += new PaintEventHandler(MyPaint);
            			ChartControl.ChartPanel.MouseMove += new MouseEventHandler(OnMouseMove);
            		}
            		
            		void OnMouseMove(object sender, MouseEventArgs e) {
            			X = e.X;
            			Y = e.Y;
            			ChartControl.ChartPanel.Refresh();
            		}
            		
            		void MyPaint(object sender, PaintEventArgs e) {
            			DrawTextFixed("info", "X = " + X + "\nY = " + Y, TextPosition.BottomRight, Color.Red, new Font("Arial", 20f), Color.Black, Color.Yellow, 100 );
            		}
            		
            		
                    protected override void OnBarUpdate() {
            		}
            Last edited by tracoder; 12-02-2013, 10:17 PM.

            Comment


              #21
              Tracoder,

              Thank you for your reply.

              I tested out the code on my end and ran some print statements from the script. I noticed that when I removed the indicator from the chart the print statements were still being called. You would need to use the OnTerminationI() method to clean up the script.

              http://www.ninjatrader.com/support/h...ermination.htm
              Cal H.NinjaTrader Customer Service

              Comment


                #22
                Originally posted by NinjaTrader_Cal View Post
                Tracoder,

                Thank you for your reply.

                I tested out the code on my end and ran some print statements from the script. I noticed that when I removed the indicator from the chart the print statements were still being called. You would need to use the OnTerminationI() method to clean up the script.

                http://www.ninjatrader.com/support/h...ermination.htm

                Thank you for your test. I have just figured how to do this smoothly and stably.

                OnTermination is also a part of the changes. The most important thing is to use TriggerCustomEvent to call my actual handlers. Bypassing TriggerCustomEvent causes unpredictable outcomes.

                Thank you!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by smartromain, 03-13-2024, 01:42 AM
                5 responses
                92 views
                0 likes
                Last Post AndreiBig  
                Started by Noerclou, Today, 04:55 AM
                0 responses
                4 views
                0 likes
                Last Post Noerclou  
                Started by llanqui, Yesterday, 09:59 AM
                2 responses
                17 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by ThoriSten, Today, 03:56 AM
                0 responses
                6 views
                0 likes
                Last Post ThoriSten  
                Started by PhillT, 04-19-2024, 02:16 PM
                3 responses
                25 views
                0 likes
                Last Post mangel2000  
                Working...
                X