Announcement

Collapse
No announcement yet.

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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        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
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            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 NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              54 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              131 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 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