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

High Light Boxes

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

    High Light Boxes

    I am trying to draw boxes around the candles that confirms a Simple moving average cross. The code I have so far come up with is:

    if (CrossAbove(SMA(Close, 5), SMA(Close, 20), 1))
    {
    DrawRectangle(
    "My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Blue,BackColor,2);
    }
    if (CrossBelow(SMA(Close, 5), SMA(Close, 20), 1))
    {
    DrawRectangle(
    "My rectangle2"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Red,BackColor,2);
    }

    The edges of the boxes go through the middle of the candles not either side of the correct candle.Is there a way of correcting this?
    Can I change the color of the inside high light?
    For some reason not all crosses are high lighted. Any ideas why?

    Many thanks

    #2
    Hi cptrader,

    I briefly checked your code on the Dec ES 3 min chart and saw all crosses in relation to your SMA settings (5 / 20) plotted correctly.

    The start of the rectangle was set at the time coordinate 1 bar ago to the bar on which the cross was detected, which is what your code set out to do.

    You can change the fill color, by setting the 'BackColor' to your desired color, see my code change in red below.

    Code:
    [SIZE=2][SIZE=2]DrawRectangle([/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"My blue rectangle"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]+ CurrentBar , [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], Low[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] - [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] * TickSize, [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], High[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] + [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] * TickSize, Color.Blue, [COLOR=red]Color.Blue[/COLOR], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]);[/SIZE][/SIZE]
    Please also review this link - http://www.ninjatrader-support.com/H...Rectangle.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      High Light Boxes

      Thanks for the reply
      Is there any way to adjust code so to have the box go around the candle rather than from middle of one candle to the middle of the next.

      Comment


        #4
        Hi cptrader,

        Maybe there is a simpler way to accomplish what you seek - you could change either the bar color or the outline color of the candles according to your cross over condition.

        Please see these links - http://www.ninjatrader-support.com/H...lineColor.html

        BertrandNinjaTrader Customer Service

        Comment


          #5
          High Light Boxes

          Good idea. I did notice when I change timeframes the correct bar is not always colored. Is there a reason for this?
          I also tried putting diamonds using
          DrawDiamond("tag2", true,1, Low[0] - TickSize, Color.Red);

          Is there a way to put diamonds on all occurrance and not just last occurance

          Comment


            #6
            Hi cptrader,

            Please post a screenshot of where you think a drawing is missing. Keep in mind a cross can be visually hard to identify sometimes, because values can be very close. So comparing values in the DataBox bar by bar may help you out.

            Please create a unique tag by using this format: 'Your Tag Name' + CurrentBar, then you should see all the Diamonds in your chart.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Tick Size

              I have tried placing diamonds above or below cross overs.
              I am having some issue with ticksize.
              For ES-1208 ticksize appears to be 1 full point and not a tick.
              For Currencies ticksize does not use decimals so my charts are distorted when I plot the diamonds.
              Is there a way to get ticksize to use the increments of the instrument being used?

              Comment


                #8
                Hi cptrader,

                Just did a quick test and get the correct TickSize of the ES with 0.25, not a full point.

                For the EURUSD I get 0.0001, which is 1 Pip, so also correct.

                Please check your settings for ES in the Instrument Manager, Tick Size should be 0.25 and Point Value 50.

                For EURUSD 0.0001 TickSize and Pointvalue of 100000.

                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by andrewtrades, Today, 04:57 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                6 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                7 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X