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

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.

    Paul H.NinjaTrader Customer Service

    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

        Paul H.NinjaTrader Customer Service

        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].

            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by suroot, 02-25-2017, 04:43 AM
            11 responses
            2,548 views
            0 likes
            Last Post Zilvercat  
            Started by Rogers101, 05-05-2024, 11:30 AM
            16 responses
            50 views
            0 likes
            Last Post Rogers101  
            Started by ninza33, Today, 12:31 PM
            2 responses
            10 views
            0 likes
            Last Post ninza33
            by ninza33
             
            Started by Bobin, 03-12-2024, 08:51 AM
            15 responses
            482 views
            0 likes
            Last Post fiddich
            by fiddich
             
            Started by Skifree, Today, 11:21 AM
            4 responses
            15 views
            0 likes
            Last Post Skifree
            by Skifree
             
            Working...
            X