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

Change Swing Plot Colors Based On Condition

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

    Change Swing Plot Colors Based On Condition

    I want to modify the Swing indicator so that the plot colors are set based on a condition.

    Can you provide a link or sample to help accomplish that?

    #2
    Hello ScorpioTravis,

    Thank you for the post.

    The swing can be duplicated and then edited by using the NinjaScript editor. To duplicate the file you would first need to open it and then right click in the file -> Save as.

    The swing is a fairly complicated indicator which can be pretty difficult to edit. We would likely need more specific details on what kind of conditions you are looking to make in order to provide more relevant help here.

    To color plots you can use PlotBrushes https://ninjatrader.com/support/help...ub=PlotBrushes



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse, I made a copy and modified it by adding the following lines at the end of the protected override void OnBarUpdate() section (CONDITION# = other indicator values):

      Code:
      {
      if (CONDITION1 && CONDITION2)
      {
      PlotColors[0][0] = Color.Transparent;
      PlotColors[1][0] = Color.Yellow;
      }
      else if (CONDITION3 && CONDITION4)
      {
      PlotColors[0][0] = Color.Cyan;
      PlotColors[1][0] = Color.Transparent;
      }
      else
      {
      PlotColors[0][0] = Color.Transparent;
      PlotColors[1][0] = Color.Transparent;
      }
      }
      It seems to work as expected, however, there are some yellow plots even though CONDITION1 and CONDITION2 are both false.

      I can't determine if that's caused by something in the original SWING code or if it's because of an error I made in the additional code logic for changing the colors.

      Update: I sent the indicator data used for the CONDITION#s to an output window, but it doesn't match what's on the chart and data box. I'm still investigating.
      Last edited by ScorpioTravis; 10-05-2021, 06:00 PM.

      Comment


        #4
        Hello ScorpioTravis,

        When you say that you sent the indicator data are you referring to the plot data from the indicator or are you using SwingLowBar/HighBar?

        For your conditions you would need to use a print to see what the values are on each bar where the conditions are both false.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello ScorpioTravis,

          When you say that you sent the indicator data are you referring to the plot data from the indicator or are you using SwingLowBar/HighBar?

          For your conditions you would need to use a print to see what the values are on each bar where the conditions are both false.



          I look forward to being of further assistance.
          Yes, I used PRINT to confirm that for some reason I have yet to determine, the CONDITION#s are both true even though on the chart they're both false.

          Comment


            #6
            Hello ScorpioTravis,

            Could you provide more details about the condition? Are you using indicator values and comparing against manually added indicators? That could be a situation where the chart may differ from the script.


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jesse View Post
              Hello ScorpioTravis,

              Could you provide more details about the condition? Are you using indicator values and comparing against manually added indicators? That could be a situation where the chart may differ from the script.


              I look forward to being of further assistance.
              I don't think I can sufficiently explain it without sending the indicators to you, and I don't expect you to review them.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, 04-17-2024, 06:40 PM
              6 responses
              48 views
              0 likes
              Last Post algospoke  
              Started by arvidvanstaey, Today, 02:19 PM
              4 responses
              11 views
              0 likes
              Last Post arvidvanstaey  
              Started by samish18, 04-17-2024, 08:57 AM
              16 responses
              61 views
              0 likes
              Last Post samish18  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              9 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              21 views
              0 likes
              Last Post traderqz  
              Working...
              X