Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unpaint a paintbar

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

    Unpaint a paintbar

    I wrote a paintbar to paint with HH and HL intrabar.
    How do I tell it to unpaint if it becomes a Lower Low before the bar closed?
    I have other paintbars that I want to unpaint as needed intrabar.

    Also how do I make the font in the forum posts be larger. Its too tiny for me.
    Attached Files

    #2
    Hello

    To do this you would need to use BarColorSeries


    In addition to your existing logic, you would also need to store the bar value of when you set the color so you know what bar to remove the color from.

    Code:
    private int storedBar;
    protected override void OnBarUpdate()
    {
       if ( Close[0]>Open[0] && Low[0]> Low[1] && High[0]>High[1] && Close[1]> Open[1] )
       {
            if(storedBar > 0) BarColorSeries[CurrentBar - storedBar] = Color.Empty;
            BarColor = Color.Green;
            storedBar = CurrentBar;
       }
    }
    After storing the bar, when your condition to remove the color becomes true, you could use the Stored bar with the Current bar to find a BarsAgo:

    Regarding the font, while posting you have some control like Bold, if you are just talking about the web browser try using Control + Middle mouse scroll. Most web browsers will increase or decrease the zoom with this command.


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

    Comment


      #3
      The way I had it the bar colored properly.
      Youre saying BarColorSeries instead of BarColor is what makes it adjust between Green if it Is HH and HL and back to normal light green bars when it no longer is.
      Its all about coloring or removing the current bar there is no prior bar that colors or changes after old prior bars close.
      As you can see the magenta and dark green work fine but this was after market hours and I want to know that the color goes away if for ex the low goes from higher low to lower low during the bartime.
      Is all I need to do switch BarColor to BarColorSeries?
      Attached Files

      Comment


        #4
        I guess I'll get the intrabar unpaint part later but first what determines which paintbar overwrites another?
        The attached is a Tradestation and Ninja screenshot of the same bars.\
        Both have the HH-HL and LH-LL paintbar (darker green and magenta) and both have a paintbar that under certain cnditions paints red or blue if the price moves 5 ticks up for long or down for shorts from the bar open after an alert. On Tradestation the red/blue is dominant between the two but on Ninja the red/blue is not dominant and wom't overwrite HH-HL or LH-LL.
        If it matters the order they are in on my Ninja chart indicators list is HHHL then both red and blue indicators then the LHLL one.
        Attached Files

        Comment


          #5
          Although I'd still like to know the ordering rules for 2 indicators painting the same bar, I saw that the HHHL and LLLH (magenta and green) was preventing the red and blue to paint so I dropped the HHHL and LHLL 1 bar forward so in a run the green or magenta will start one bar after the red or blue bar might print.
          I still do not understand how to unpaint a bar if the intrabar conditions retrace so it goes from 5 or 6 ticks from open back to 3 or 4 only and the red or blue would need to come off..
          Last edited by simpletrades; 01-28-2017, 06:50 PM.

          Comment


            #6
            Hello,

            The BarColorSeries would be used in cases where you need to set a color for a BarsAgo or some other bar than the current. If you need to re write a color on a prior bar, you would need to know which bar that is in relation to the current bar and then specify a number of BarsAgo to set that bars color. The BarColor property simply sets the bar being processed at the time or the CurrentBars color.

            To implement this type of logic you would need to do more than just change from BarColor to BarColorSeries, you would need to add more logic to save the bar numbers to know where you need to reset bars. This was the example I had provided previously of using an int variable to store the CurrentBar. Later the CurrentBar can subtract the variable to get a Difference or a BarsAgo. The main concept is that you need to know the number of bars ago from the current bar in which to reset the color.

            Regarding the other items you noted, this is likely because you are using multiple indicators and repainting the same bar. The order would depend on the order added/loaded and the order in which the indicators call OnBarUpdate to set the color. This would be difficult to say specifically with your example. I could suggest to instead try to implement this logic in a single indicator, this would allow you to know when all conditions should be true on each bar and color them accordingly.

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

            Comment


              #7
              There are no bars ago that get painted after the fact.
              I get an entry signal and sometimes hesitate.
              i want to paint the entry bar that is immediately following the signal bar blue once it moves 5 or more ticks if it gave a long signal or red on a short. I figure entering 5 or 6 ticks late isn't good but either way only this possible entry bar is the one that paints.
              If the price moves back intrabar to 4 or less i want the bar color to revert to its normal color light green or pink.
              On Tradestation it was just basically a matter of saying if Criteria 1 was true then paint the bar else no plot1 and that would toggle the color on and off until bar close. Ninja's tougher.
              Last edited by simpletrades; 01-29-2017, 12:25 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by usazencort, Today, 01:16 AM
              0 responses
              1 view
              0 likes
              Last Post usazencort  
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              603 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              22 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              21 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Working...
              X