Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adjust an indicator logic for use in Strategy Builder

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

    Adjust an indicator logic for use in Strategy Builder

    Hello,
    How can I use this free indicator (here) as a condition to develop my own strategy on Strategy Builder?
    I mean this indicator can calculate the closing percentage on the current bar and then brushes it, but instead of that I need that closing percentage condition in order to use it on Strategy Builder.

    Something like this:
    If this bar closes higher than 75%, go long ...

    (I know how to use the Strategy Builder but I don't know what I need to add/edit to the indicator for the use I described above, and I don't want to unlock the code of my Strategy because I won't be able to edit it anymore)


    Regards,

    #2
    Hello MarcoNT29,

    Thanks for your post and welcome to the NinjaTrader forums!

    The strategy builder would not be able to use the indicator. For the strategy builder to use an indicator, the indicator must provide a plot signal and the referenced indicator only colors the bars and does not provide a plot.

    You could replicate the indicator coding in the strategy builder. The indicator uses these two conditions:

    (For an upbrush): if(Close[0] >= Low[0] + BarPercent*(High[0]-Low[0]))

    (For a down brush) if(Close[0] <= High[0] - BarPercent*(High[0]-Low[0]))

    In both condition note that this calculation is the same: BarPercent*(High[0]-Low[0]) so it only needs to be done once

    You would need to create a "custom series" in the strategy builder to "store" the calculation of BarPercent*(High[0]-Low[0]) on each bar.
    The calculations would be done in two steps, first High[0] - Low[0] and store that value in the custom series, then takes that custom series value times the BarPercent and write that in the custom series. (The math is done using the "offset" feature).

    You would create a user input for the BarPercent value (default is 0.75) (assuming you want to be able to change it)

    The final calculation would be stored into two double type variables you could create (one for low and one for high)

    LowCheck = Low[0] + customseries[0]
    HighCheck = High[0] - customseries[0]

    Next in one set create the condition of Close[0] >= lowcheck and in another set you would have Close <= highcheck

    When those condition/sets are true you will have the same output as the indicator shows.

    References:
    https://ninjatrader.com/support/help...setAnItemValue
    https://ninjatrader.com/support/help...onalDataScreen

    Comment


      #3
      Thanks NinjaTrader_PaulH !
      I have carried out the activities that you told me but the strategy does not do anything when I execute it .... Is something wrong?

      Custom Series
      Name: CustomS / Type: Double

      Inputs
      Name: BarPercent / Type: Double / Default 0.75

      Variables
      Name: HighCheck / Type: Double / Default 0
      Name: LowCheck / Type: Double / Default 0

      Conditions
      Misc/Custom series/CustomS = Price/High/Arithmetic Offset - Close
      Misc/Custom series/CustomS = Misc/Custom series/CustomS/Percent Offset BarPercent
      User variables/HighCheck = Price/Low/Arithmetic Offset + CustomS
      Price/Close >= User variables/HighCheck

      Click image for larger version

Name:	Annotation 2020-08-25 130229.jpg
Views:	548
Size:	36.4 KB
ID:	1115529


      Regards,

      Comment


        #4
        Hello MarcoNT29,

        Thanks for your post.

        Sorry, I was not as clear as needed. The custom series values need to be assigned in the "do the following" section of a set.

        Here are screenshots (i used different names but I think you will be able to follow.

        In Set 1 there are no conditions, only the actions to assign values to the custom series and the 2 variables. the sequence of this set as the first is important. the calculations are done on each bar.

        Click image for larger version

Name:	set1-1.PNG
Views:	675
Size:	29.9 KB
ID:	1115536

        Set 2 contains a single condition and has the action to draw a colored dot that should align with a colored bar (by the indicator) as a way to test
        Click image for larger version

Name:	set2.PNG
Views:	622
Size:	30.0 KB
ID:	1115537

        Set 3 is the last set that contains the other condition and like set 2 contains an action to draw a dot that would correspond with a color bar (by the indicator) of the other direction.

        Click image for larger version

Name:	set3.PNG
Views:	621
Size:	29.7 KB
ID:	1115538

        Comment


          #5
          Thank you very much NinjaTrader_PaulH !

          The Strategy is working now... and I learned more than I thought!

          I really appreciate your help

          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