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

How to get Open value on new candle

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

    How to get Open value on new candle

    Hello,

    on this screen http://prntscr.com/obr8hk I need to get value of openning candle on which I place long market order - price is 7775.00

    I use multitimeframe strategy.

    CurrentBars[0] - visible chart 2 minute
    CurrentBars[1] - chart 2 minute
    CurrentBars[2] -1 tick for very smooth trades handing

    I duplicated data [0] to [1] - for testing on tick data and keeping behaviour.
    Problem is when new candle opens -> i wait fort BarsInProgress = 2 a try to get Opens[2][0], also tried Closes[2][0] - and still get no value 7775 but close of previous candle 7774,5

    Am i missing something?

    Thanks for advices
    P. Kujal

    #2
    I use Calculate.OnBarClose and try to get Open on IsFirstTickOfBar which should not do any bad.. should it?

    Comment


      #3
      Hello kujista,

      To confirm, you are wanting the Open of the most recently fully closed bar on another series?

      What are you comparing to know that this is not the value you are getting?

      When Calculate is OnBarClose, IsFirstTickOfBar will always be true because the script is not checking individual ticks of the bar.


      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        I am trying to get open of newly opened candle on barsinprogress = 2, which i supposed is close of barsinprogress = 1, see the picture and price i get. It is close of recently closed candle and i need open of actual. I hope i do not have to switch to calculate.oneachtick. I see the isfirsttickofbar is useless when using onbarclose

        Comment


          #5
          Hello kujista,

          If you are wanting values from an open bar, you would need to use Calculate .OnEachTick. In historical TickReplay must also be enabled.

          Below are links to the help guide on Calculate, TickReplay, and how bar information is accessed.



          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            ok i see that i have to optimize strategy using isfirstickofbar.. to minimize consumption. i also want to minimize cpu load on calculatin indicators inside strategy how does it work? do the indicators in strategy calculate oneachtick and if so how can i force them to calculate onbarclose.. i am still thinking about performance i use multiframes and more indicators and i have to minimize cpu load. thanjs for the tips

            Comment


              #7
              Hello kujista,

              The hosted indicators will use the same Calculate mode as the host strategy.
              This is necessary and should not be changed.

              In the indicator, you can also code for logic to occur only if IsFirstTickOfBar is true.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                thank you for explanation so indicator is called on each incoming tick of dataseries, which indicator uses inside strategy?

                Comment


                  #9
                  Hello kujista,

                  When you mention "which indicator uses inside strategy", are you asking which indicators can be called from a strategy?

                  Pretty much any indicator with plots (or updated public properties) can be called from a strategy.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    i meant, when i add into strategy indicator e. g. trend(inputs[2]), it will calculate indicator value on each incoming tick of inputs[2].. so i have to use if isfirstickofbar in indicator to optimize performance?

                    Comment


                      #11
                      Hello kujista,

                      If the Strategy is using Calculate .OnEachTick, or .OnPriceChange, the indicators will also be using that Calculate setting.

                      If you want actions to only occur on the first tick of a bar in any called indicator, add to the condition for that action IsFirstTickOfBar.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by junkone, Today, 11:37 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post junkone
                      by junkone
                       
                      Started by quantismo, 04-17-2024, 05:13 PM
                      5 responses
                      35 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by proptrade13, Today, 11:06 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by love2code2trade, 04-17-2024, 01:45 PM
                      4 responses
                      34 views
                      0 likes
                      Last Post love2code2trade  
                      Started by cls71, Today, 04:45 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post eDanny
                      by eDanny
                       
                      Working...
                      X