• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inserting Arrow on Price Panel

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

    Inserting Arrow on Price Panel

    Hi,

    I have an indicator that paints/brushes candles/OHLC either one of three different colors (green[1], red[2], blue[3]) upon close of the candle and based upon three specific conditions. I would like the indicator to draw an arrow upon the close of the current bar if the bar was brushed green [1] and the previous bar was red [2], and vice versa (red [2], green [1]). I don't want anything to happen if ([1],[3])([3],[1]), ([2],[3]), ([3],[2]).

    Any help would be greatly appreciated.

    Thank you!

    #2
    Hello TopGun13,

    Thanks for your post.

    You could add a custom data series to your script. A custom data series will provide a "slot" to store values in that would be sync'd to your charts bars and would allow you to use [n] bars ago references.

    So in your code when you paint the candle a specific color you would assign a value to the data series. For example:

    if (conditions to paint green)
    {
    BarBrush = Brushes.Green;
    myCustomSeries[0] = 1;
    }
    else if (conditions to paint red)
    BarBrush = Brushes.red;
    myCustomSeries[0] = 2;
    }
    else if (conditions to paint Blue)
    {
    BarBrush = Brushes.Blue;
    myCustomSeries[0] = 3;
    else
    {
    // no bar painted
    myCustomSeries[0] = 0; // or any other value you wish to help you know it was not painted
    }

    Then you can create your arrow drawing logic:

    if (myCustomseries[0] == 1 && myCustomSeries[1] == 2) // Current bar green, previous bar red.
    {
    // Draw arrow...
    }
    etc.etc.

    Please see the help guide here on creating a custom series: https://ninjatrader.com/support/help...8/?seriest.htm


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul! This helped a lot.

      I am also wondering if you could help me connect-the-dots (i.e. backbrush) between indicator signals. For example I am using the following to paint the background:

      if (Value[0] == 1 && Value[1] == 1 && Value[2] == 1 || (Value[0] == 4 && Value[1] == 1 && Value[2] == 1) || (Value[0] == 4 && Value[1] == 4))
      {
      BackBrushesAll[0] = Bullish;
      }

      if (Value[0] == -1 && Value[1] == -1 && Value[2] == -1 || (Value[0] == -4 && Value[1] == -1 && Value[2] == -1) || (Value[0] == -4 && Value[1] == -4))
      {
      BackBrushesAll[0] = Bearish;

      }

      As you can see I used your logic to create plots. Bullish and bearish plots have three different rules separated by "or". Although it is possible to generate all three bullish signals before a bearish signal is generated, I was wondering if I can paint the background bullish (or bearish) for the candles in-between a bull and then bear signal (or a bear and then bull signal).

      Any guidance would be greatly appreciated.

      Thank you!

      Comment


        #4
        I have attached a picture for further clarification.

        Thank you once again!

        Comment


          #5
          Hello TopGun13,

          Thanks for your replies.

          " I was wondering if I can paint the background bullish (or bearish) for the candles in-between a bull and then bear signal (or a bear and then bull signal)". If I understand correctly, once you have a signal you want to continue plotting the background that color until the opposite signal is generated? To accomplish that, remove the assigning colors from your code block and instead create/use a new bool variable that is set true or false by those conditions and then use the bool to paint the background.

          if (Value[0] == 1 && Value[1] == 1 && Value[2] == 1 || (Value[0] == 4 && Value[1] == 1 && Value[2] == 1) || (Value[0] == 4 && Value[1] == 4))
          {
          myBool = true;
          }
          else if (Value[0] == -1 && Value[1] == -1 && Value[2] == -1 || (Value[0] == -4 && Value[1] == -1 && Value[2] == -1) || (Value[0] == -4 && Value[1] == -4))
          {
          myBool = false;
          }

          //Paints the back ground on every bar and only changes when above conditions change the bool state.

          if (myBool)
          {
          BackBrushesAll[0] = Bullish;
          }
          else
          {
          BackBrushesAll[0] = Bearish;
          }
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Excellent! Worked perfectly.

            Thank you Paul!

            Best.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by zulok, Today, 05:02 PM
            0 responses
            1 view
            0 likes
            Last Post zulok
            by zulok
             
            Started by Andreas M., Today, 04:42 PM
            0 responses
            1 view
            0 likes
            Last Post Andreas M.  
            Started by sidlercom80, Today, 12:29 PM
            2 responses
            21 views
            0 likes
            Last Post fx.practic  
            Started by itrader46, Today, 02:49 PM
            3 responses
            12 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by m94306, Today, 03:01 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Heath  
            Working...
            X