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

Please explain how OnBarUpdate related to Plot method

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

    Please explain how OnBarUpdate related to Plot method

    I have a chart. Set at 1 tick. Line on close.

    There are 2-3 prints in T&S screen in between chart drwaings.

    I printed Close[0] price from OnBarUpdate and from Plot.

    It seems to me that NT calls:

    1. Plot every time 'chart tick' has been drawn.
    2. OnBarUpdate everytime T&S prints.

    Can anyone please confirm these ?

    Also is there any chance to make Plot to be called for each actual market tick if chart size is 1 tick... I am confused how come tick chart displays 2,3,4 ticks?

    The problem with that - on Plot I cant get previous price correct. I get price change on next Plot all the time.

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] currTicks = Convert.ToInt32([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].Truncate(Convert.ToDecimal(Close[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] / TickSize)));
    
    [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Print([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].Format([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Prev {0} Curr {1}"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], prevTicks, currTicks));
    prevTicks = currTicks;
    [/SIZE][/FONT][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT]
    I have for example price on the chart 1 1 2 2 and in Plot O have price - 1 1 1 2.

    Price in Plot is lagging behind!

    Question:

    How can I get correct price in Plot method ?

    Or

    Can I draw my custom GDI+ things in OnBarUpdate?

    #2
    Hi maxima,

    This is attributed to asynchronous multi-thread. There is no guarantee the Plot method will fire in sequential fashion to the OnBarUpdate(). OnBarUpdate() is triggered every time a bar is updated (or incoming tick). The Plot() method is called when the indicator is plotting. I suggest you just run your logic in OnBarUpdate() and just access them from the Plot() method.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Sorry Josh. Actually I was wrong and my question is misleading. I understand that you cannot guarantee sequence because of async threads.

      My real question has to be:

      Why OnBarUpdate/Plot events fire once per 2-5 OnMarketData event?

      Or in simple words - why tick chart is 2-5 times slower than actual ticks speed?

      How can I make it actual 1:1 tick chart?

      The answer will be really appreciated.

      Comment


        #4
        You can set the chart update interval to a value of zero which should update the visuals on each incoming tick instead of timer based. However...I don't recall, there may still be some internal optimization logic.
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks. It seems there is no way to do so in NT UI (I tried 0 in "Display update interval").

          I made my own form and draw every tick there. My CPU at abt 3% (Q9300 quad) loaded. There is no problem to have tick charts as some people may want to do scalping you know .

          I think NT have to provide raw tick charts in ver 7. There is no reason not to

          Comment


            #6
            Thanks for the suggestion. We will put it on the list of future considerations.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Just open a chart, set to 1 tick and use line on close and you will have a raw tick chart.
              RayNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              123 views
              1 like
              Last Post caryc123  
              Started by rocketman7, Today, 09:41 AM
              4 responses
              16 views
              0 likes
              Last Post rocketman7  
              Started by selu72, Today, 02:01 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by WHICKED, Today, 02:02 PM
              2 responses
              16 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by f.saeidi, Today, 12:14 PM
              8 responses
              21 views
              0 likes
              Last Post f.saeidi  
              Working...
              X