Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with indicator

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

    Help with indicator

    Hi all, im completely new to scripting or programming but i decided to take a shot and create a bar counter i needed. I was able to do hammer it tru and its working for what i need BUT its making the drawings really slow. Whenever i try to edit a line for example or change a text, it takes quite a bit. Is there is something i can do to fix this? Here is the code

    namespace NinjaTrader.NinjaScript.Indicators

    {

    public class JSRDTBarCounter : Indicator

    {



    private int MyCounter;

    NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12) { Size = 8, Bold = false };

    protected override void OnStateChange()

    {



    if (State == State.SetDefaults)

    {

    Description = @"Numeros debajo de cada barra";

    Name = "JSRDTBarCounter";

    Calculate = Calculate.OnBarClose;

    IsOverlay = true;

    DisplayInDataBox = true;

    DrawOnPricePanel = true;

    DrawHorizontalGridLines = true;

    DrawVerticalGridLines = true;

    PaintPriceMarkers = true;

    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;

    //Disable this property if your indicator requires custom values that cumulate with each new market data event.

    //See Help Guide for additional information.

    IsSuspendedWhileInactive = true;




    }

    else if (State == State.Transition)

    {

    }

    }




    protected override void OnBarUpdate()

    {

    if ( CurrentBar >=0)

    { if (Bars.IsFirstBarOfSession)

    {

    MyCounter = 1;

    Draw.Text(this, "Tag"+CurrentBar, false, MyCounter.ToString(), 0, Low[0]-0.7, 5, Brushes.Black, myFont, TextAlignment.Center, Brushes.Transparent, null, 1);

    }

    else

    Draw.Text(this,"Tag"+CurrentBar, false, MyCounter.ToString(),0, Low[0]-0.7,5, Brushes.Black, myFont, TextAlignment.Center, Brushes.Transparent, null, 1);

    MyCounter = MyCounter + 1;

    }




    }

    }

    }

    #2
    Hello jsrdaytrader,
    Thanks for your post.

    It looks like you are drawing your text on every single bar. Is that your intent or are you trying to mimic the "BarTimer" indicator that is built in to NinjaTrader?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh. Yes, im drawing a number on each bar of the session. Since it starts until it ends so i can identify each bar and share info among coworkers on specific bars

      Comment


        #4
        jsrdaytrader,

        I expect that something else other than this code is causing the sluggishness on your platform. If this is the only indicator running in your workspace do you still the same same sluggishness?

        If it is still sluggish, can you take a screenshot of your NinjaScript Utilization Monitor?
        https://ninjatrader.com/support/help...izationMonitor

        To take a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.
        Click here for instructions

        Alternatively to take a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image.
        Click here for detailed instruction
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Im not really sure if im doing something wrong, but when i right click on the Output window i dont see any option to display the utilization monitor

          Comment


            #6
            jsrdaytrader,

            Please check the version of NinjaTrader you are running from Control Center>>Help>>About
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              8.0.15.1 64-bit

              Comment


                #8
                jsrdaytrader,

                That version(8.0.15.1) is from about 9 months ago and there have been several updates since then. Please go ahead and upgrade to the current version (8.0.17.2) before troubleshooting further. Upgrading is simple and can be accomplished by following these steps.
                Note: Following these steps will not affect your data, settings, configuration, Indicators, Strategies, Workspaces, etc.
                • First, save your license key to a document
                • You can locate your license key by going to Help> License Key
                • Now exit NinjaTrader and uninstall it within Windows Control Center
                • Once uninstalled you can redownload NinjaTrader from the link below
                http://ninjatrader.com/PlatformDirect
                • Paste your license key
                • Select Submit
                • Download and then run the installer

                Once you upgrade go back and test for the same performance issues. If you still see the same thing, check the NS Utilization Monitor and report back here.
                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you. Ive done it and here is the SS of the utilization with a couple of mins
                  Attached Files

                  Comment


                    #10
                    jsrdaytrader,

                    Is this in a workspace with only your indicator running? It looks like there may be an Addon running on your charts tool bar.
                    Josh G.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh i removed everything and left only my script. One thing to notice is that as soon as i remove my script everything works ok
                      Attached Files

                      Comment


                        #12
                        jrsdaytrader,

                        I went back and ran the script you posted and was not able to reproduce this issue. How much data are you loading onto the chart? (ie. how many days/bars)
                        Josh G.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by stafe, Today, 10:43 AM
                        0 responses
                        8 views
                        0 likes
                        Last Post stafe
                        by stafe
                         
                        Started by UltraNIX, Today, 09:13 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Started by Tuxstuff215, Today, 06:32 AM
                        1 response
                        15 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Started by carlot, Today, 08:10 AM
                        1 response
                        21 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Started by KirkHammett, Yesterday, 11:15 PM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Working...
                        X