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

when green go long when red go short

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

    when green go long when red go short

    Hi folks,

    How could we make the Strategy Builder go long with the line is green and go short when the line is red (using the Strategy Builder)?

    See attached which is this simple indicator Trend Magic - NinjaTrader Ecosystem

    Thanks a bunch!

    Greg
    Attached Files

    #2
    Hello Greg,

    Thanks for your post.

    It would not be possible to compare the TrendMagic indicator line in a Strategy Builder strategy to see if the line is green or red.

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_BrandonH well...ok...is there another way to to detect it rising or falling or going up or down etc? Anything?

      What would need to be added to the indicator to allow it to detect red or green as well? There must be a way?

      Greg

      Comment


        #4
        Hello Greg,

        Thanks for your note.

        You could consider modifying the indicator in the NinjaScript Editor window by adding a plot to the indicator, checking if the PlotBrushes[0][0] is equal to BearBrush or BullBrush, and assigning a value of 0 or 1 to the plot depending on the brush being used.

        The added plot could be referenced in the Strategy Builder by comparing the added plot to a numerical value of 0 or 1 to detect if BullBrush (green) or BearBrush (red) is being used.

        See the help guide documentation below for more information.

        AddPlot: https://ninjatrader.com/support/help...t8/addplot.htm
        PlotBrushes: https://ninjatrader.com/support/help...lotbrushes.htm

        Please let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_BrandonH Is there any other indicator out here I can review its code that already has line plots where the strategy builder has a choice to select if long or short? I can get the plots but the option will not show in the strategy builder yet so I can evaluate if it is long or short then do x yet.

          Comment


            #6
            Hello Greg,

            Thanks for your notes.

            I have attached a modified version of the TrendMagic indicator that demonstrates how to incorporate the advice mentioned in post # 4.

            This sample script is modified to include a second plot called BullOrBear. When the TrendMagicModified plot is set to use the BullBrush (lime green), a value of 0 is assigned to the BullOrBear plot indicating the TrendMagicModified plot is lime green. When the TrendMagicModified plot is set to use the BearBrush (red), a value of 1 is assigned to the BullOrBear plot indicating the TrendMagicModified plot is red.

            You could compare the BullOrBear plot of the TrendMagicModified indicator to a Numerical Value (Misc folder > Numerical value) in the Strategy Builder. If you compare the BullOrBear Indicator plot to 0, this means you are checking if the TrendMagicModified plot is green. If you compare the BullOrBear Indicator plot to 1, this means you are checking if the TrendMagicModified plot is red.

            Please let me know if I may assist further.​
            Attached Files
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              NinjaTrader_BrandonH Awesome man...thanks so much! I can now take this code and compare it and fix other indicators to do similar as needed! I really appreciate you putting in this example as it really helped! Greg

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rhyminkevin, Today, 04:58 PM
              1 response
              39 views
              0 likes
              Last Post Anfedport  
              Started by iceman2018, Today, 05:07 PM
              0 responses
              5 views
              0 likes
              Last Post iceman2018  
              Started by lightsun47, Today, 03:51 PM
              0 responses
              7 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              14 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              49 views
              0 likes
              Last Post futtrader  
              Working...
              X