Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert code from OnBarClose to OnPriceChange

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

    Convert code from OnBarClose to OnPriceChange

    Understanding the Close[0] OnBarClose is Now Close[1] OnPriceChange

    indicator dataloaded region

    abc1 = abc(Close, Period, 0); <<< this was OnBarClose this indicator out of the box is set to OnBarClose

    should I load this as below

    abc1 = abc(Close[1], Period, 0);

    *************************************

    also need help with this

    && (Close[0] < MIN(Low,2)[0]) /// in OnBarClose

    tried this in OnPriceChange - I do want current bar low to be less than the Low of last 2 bars NOT Current
    this is triggering very quickly so I know is incorrect

    && (Close[0] < MIN(Low,2)[1])

    how about this

    && (Close[0] < MIN(Low[1],2)[0])


    thanks
    Last edited by DTSSTS; 06-27-2023, 10:55 AM.

    #2
    Hello DTSSTS,

    Thanks for your post.

    When instantiating an indicator in State.DataLoaded you could continue to use abc(Close, Period, 0);.

    Setting the indicator to use Close means that the indicator will use the Close price series for calculating values.

    Please let us know if we may assist further.
    Last edited by NinjaTrader_BrandonH; 06-27-2023, 10:56 AM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      thanks that is what i thought - I have some triggers NOT as expected, so I wanted to confirm that before I trouble shoot the condition sets

      also have issue with below

      also need help with this

      && (Close[0] < MIN(Low,2)[0]) /// in OnBarClose

      tried this in OnPriceChange - I do want current bar low to be less than the Low of last 2 bars NOT Current
      this is triggering very quickly so I know is incorrect

      && (Close[0] < MIN(Low,2)[1])

      how about this

      && (Close[0] < MIN(Low[1],2)[0])​

      thanks again

      Comment


        #4
        this is the reference to abc which is a bool true false statement

        && (abc1.plot1[1] == 0)/// was used with OnBarClose
        && (abc1.plot1[0] == 1)

        && (Close[0] > Open[0]))​

        NOT sure about changing the abc with OnPriceChange

        && (abc1.plot1[2] == 0)/// ?????????????????????????????????????????????????? ????????????
        && (abc1.plot1[1] == 1)



        && (Close[1] > Open[1]))​

        Comment


          #5
          Hello DTSSTS,

          Thanks for your notes.

          Low would be passed into the MIN() method to get the lowest low value over a set period.

          To access the previous MIN() value, you could pass in a barsAgo value of 1. For example: MIN(Low, 2)[1].

          MIN(): https://ninjatrader.com/support/help...inimum_min.htm

          To access the previous value of any PriceSeries or indicator, you would pass in a barsAgo value of 1. For example, abc.plot1[1] would reference the previous value of plot1.



          Last edited by NinjaTrader_BrandonH; 06-27-2023, 11:10 AM.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            && (Close[0] < MIN(Low,2)[1])

            this is what I am using, but OnPriceChange seems to be triiggering on a visit to the current plotting bar when it revisits intrabar previous low NOT the low of the prior 2 closes bars
            ie Close[1] and Close[2]

            Guess I could rewrite code and reference each bar individually

            thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            50 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            69 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X