Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Net Change in Strategy

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

    Net Change in Strategy

    I would like to use the Net Change percentage as a trigger in a strategy but I am not sure about how this works in the Strategy Builder. This is the input I am attempting to use now. https://www.screencast.com/t/nv5kqDwsx And below is the the syntax compiled in the code. What I am looking for is a scenario whereas trades are only triggered if the instrument has exceeded 1% price change from the settlement of the day before, as would be illustrated by the Net Change Display indicator. Is this possible with the indicator or is hard coding required?


    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (Close[0] > (CurrentDayOHL1.CurrentOpen[0] * 0.1) )
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (Close[0] < (CurrentDayOHL1.CurrentOpen[0] * -0.1) )
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    }

    #2
    Hello Dolfan,

    Thanks for your post.

    The indicator CurrentDayOHL does not provide the settlement price from the day before as it only uses intraday bars. Typically, depending on your data source, the Close of the daily bar is adjusted to the settlement price.

    With that in mind, I would suggest adding daily bars to the strategy and using the Close of the prior day.

    Comment


      #3
      OK Paul, I profess my ignorance. How do I add, in the Strategy Builder, daily bars where I will be using 5 and 15 minute charts?

      Comment


        #4
        Hello Dolfan,

        Thanks for your reply.

        Here is a short video on adding data series in the strategy builder and then accessing it in the condition builder; https://paul-ninjatrader.tinytake.co...MF8xMTY0NTQyMw

        Comment


          #5
          Thanks Paul. I believe this was helpful in more ways than one. Given again that I want to ensure that the movement in market is at least 1%, does this input look correct? https://www.screencast.com/t/i5cm1cYvhiO

          I ask because the code syntax returns the following, where I am fearful that the "* 1" will be a multiplier of 1 instead of 1%. Hopefully my question is clear enough. :-)

          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < 1
          || CurrentBars[4] < 1)
          return;

          // Set 1
          if (Close[0] > (Closes[4][1] * 1) )
          {
          EnterLong(Convert.ToInt32(DefaultQuantity), "");
          }

          // Set 2
          if (Close[0] < (Closes[4][1] * -1) )
          {
          EnterShort(Convert.ToInt32(DefaultQuantity), "");
          }

          }
          }
          Last edited by Dolfan; 06-26-2020, 10:06 AM.

          Comment


            #6
            Hello Dolfan,

            Thanks for your reply.

            No, that would produce a value that is either the close price or a - close price.

            In the strategy builder, make sure you select the offset as percent and for a 1 % value of the daily close I would use 1.01 and 0.99. this would provide you with a +/- 1 percent of the daily close as related to price.

            Note that if you are using Calculate.OnBarClose, to get the previous day bar value, you would have to use the bar index of [4][0] as that would be yesterdays bar close in that mode. If you are using calculate.OnPriceChange or Calculate.OnEachTick, then on live data you would need to use [4][1].

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            53 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            70 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X