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

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
    Paul H.NinjaTrader Customer Service

    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:	468
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:	583
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:	527
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:	529
Size:	29.7 KB
ID:	1115538
        Paul H.NinjaTrader Customer Service

        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 Barry Milan, Today, 10:35 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by WeyldFalcon, 12-10-2020, 06:48 PM
          14 responses
          1,427 views
          0 likes
          Last Post Handclap0241  
          Started by DJ888, Yesterday, 06:09 PM
          2 responses
          9 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          40 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Today, 08:51 AM
          2 responses
          16 views
          0 likes
          Last Post bill2023  
          Working...
          X