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 use on price change and on bar close in my script

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

    how use on price change and on bar close in my script

    hi
    imagine i want to use volumetric bar values in bar close mode and in the same time 1,5,15,30,60 minute in on price change mode in one script.
    how can i adjust this ?
    since i know on script title we can use only bar close or price change or tick change mode.
    Best regard..

    #2
    Hello f.saeidi,

    You won't be able to change the Calculate setting for specific series.

    You can use Calculate.OnPriceChange and then for BarsInProgress 0 require IsFirstTickOfBar to be true to trigger actions after a bar has closed on the primary series, and not require IsFirstTickOfBar to be true for BarsInProgress 1 allowing for updates on each price change.

    Below is a link to the help guide.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It's serious problem since volumetric bar only works well In close mode and for multi time trend analyse work with price or tick mode.

      Comment


        #4
        Hello f.saeidi,

        Unfortunately, the entire script updates with the Calculate setting for all data series and it will not be possible to set a calculate mode for different data series.

        That said, I am not aware of any issue when using an indicator on volumetric bars with Calculate.OnPriceChange.

        I've given this a test and am finding this is updating with the correct values without issue even when using IsFirstTickOfBar with Calculate.OnPriceChange.
        Below is a link to a video of the test.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          It's not any problem with price change or tick mode with volumetric bar values since I find tick mode give exact values.
          Main broblem is if you want to use if condition in volumetric bars for example
          If(volume >1500 && delta sl>0)
          {
          Buy arrow
          ​​​​​​}
          Its not work correctly since you must use bar close condition because values change tick by tick
          So in price change or tick change you can't use it conditions.
          This is serious problem...

          Comment


            #6
            Hello f.saeidi,

            Thanks for your notes.

            As NinjaTrader_ChelseaB noted in post # 2, you could set your script's Calculate mode to Calculate.OnPriceChange and IsFirstTickOfBar to process some logic in your script on bar close.

            If the Volumetric series is the primary series your script is running on, you could create a condition that checks if BarsInProgres == 0. Inside that BarsInProgress condition you could create a condition that checks if IsFirstTickOfBar is true. Any logic you want to process on bar close would then be placed inside that IsFirstTickOfBar condition.

            For example:

            Code:
            if (BarsInProgress == 0
            {
                if (IsFirstTickOfBar)
                {
                    //place logic you want to calculate on bar close here
                }
            }
            Here is a reference sample demonstrating separating logic to either calculate once on bar close or on every tick which you might find helpful: https://ninjatrader.com/support/help...either_cal.htm

            Also, see the IsFirstTickOfBar help guide documentation linked on post # 2.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              can i use below config ?
              i want to add volumetric and multi time series as below:

              else if (State == State.Configure)
              {
              AddDataSeries(null, BarsPeriodType.Second,30);
              AddDataSeries(null,BarsPeriodType.Minute,1);
              AddDataSeries(null,BarsPeriodType.Minute,5);
              AddDataSeries(null,BarsPeriodType.Minute,15);
              AddDataSeries(null,BarsPeriodType.Minute,30);
              AddDataSeries(null,BarsPeriodType.Minute,60);
              AddDataSeries(null,BarsPeriodType.Minute,240);
              AddVolumetric(null, BarsPeriodType.Range, 3, VolumetricDeltaType.BidAsk, 0);

              }​

              problem is script work only with volumetric bars and when i apply above multi time series ninja start to stop and price dont move in simulate.what is mistake about it?
              its dont me allow i configure.
              Last edited by f.saeidi; 04-11-2024, 04:01 AM.

              Comment


                #8
                Hello f.saeidi,

                "Its not work correctly since you must use bar close condition because values change tick by tick
                So in price change or tick change you can't use it conditions.​"

                This is incorrect.

                You can use the values in conditions. The values will be correct values, as shown in the video I have provided you.

                When using IsFirstTickOfBar, reference the previous bars value for the values of the most recently fully closed bar in the conditions.

                This is demonstrated in the video I have provided you.

                With the code you are suggesting in post # 7, the added volumetric series will be BarsArray[8], and will update OnBarUpdate() with BarsInProgress 8.
                This means you will need to cast BarsArray[8] as volumetric bars and use CurrentBars[8] to get the bar number.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  thnx for notes.
                  how can i read volumetric bar for example volume[candle 1],volume[candle 2],
                  and other volumetric bar parameters in different candles?
                  i need compare values.
                  for example if ( volume[candle 0] > volume[candle 1] && volume[candle 1] > volume[candle 2] )

                  thnx.
                  Last edited by f.saeidi; 04-11-2024, 07:24 AM.

                  Comment


                    #10
                    Hello f.saeidi,

                    As shown in the video, when Calculate is OnEachTick or OnPriceChange, the most recently fully closed bar would be index [CurrentBar - 1].
                    The previous bar would be [CurrentBar - 2]. For 3 bars ago this would be [CurrentBar - 3], etc.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by ETFVoyageur, Today, 07:55 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post ETFVoyageur  
                    Started by janio973, Today, 07:24 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by aligator, 01-06-2022, 12:14 PM
                    4 responses
                    242 views
                    0 likes
                    Last Post john_44573  
                    Started by reynoldsn, Today, 05:56 PM
                    0 responses
                    13 views
                    0 likes
                    Last Post reynoldsn  
                    Started by bortz, 11-06-2023, 08:04 AM
                    51 responses
                    1,996 views
                    0 likes
                    Last Post aligator  
                    Working...
                    X