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

Multiple Area in 5min Bar

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

    Multiple Area in 5min Bar

    Hey guys, I have a code which Plots channels on a Range Bar using the 5min bar. It works well. What I would like to do is plot the same thing for the Last 2 minutes of every 5minute bar. How would I accomplish this??

    To summarize: if a 5 minute bar is 5:50 to 5:55. how do I plot the 5:53 to 5:55 area?

    Code:
      
    protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Square, "UpChannel"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Square, "DownChannel"));
    			Add(PeriodType.Minute, 5);
    
    OnBarUpdate()
    	//Plot the Price Channel
    			UpChannel.Set(DonchianChannel(BarsArray[1], period).Upper[0]);
    			DownChannel.Set(DonchianChannel(BarsArray[1], period).Lower[0]);
            }
    Thank You!

    #2
    Hello,

    Thank you for the question.

    I wanted to better understand what you are trying to do, You said that you want to plot the 5:53 - 5:55 area, could you provide an image of this area to better understand how the chart is set up and what you are trying to accomplish?

    I have read this in two ways, either you are trying to plot based off of data but only from 5:53 - 5:55 or you are trying to plot on part of a bar or in between bars. Can you confirm this and provide more details on this?

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

    Comment


      #3
      The picture is here

      Comment


        #4
        Any ideas?? If maybe there was a way to use a Timer or something that Only worked every 3 minutes, and the remaining 2 minuted gets plotted or something drawn on it. how would I make that happen??

        If you can you this using TimeSpan maybe that's Possible I was looking at it. but have no real idea how to use it for this purpose.

        I'm not too sure how to use this
        Code:
        TimeSpan span1 = TimeSpan.FromMinutes(5);
        	TimeSpan span2 = TimeSpan.FromMinutes(2);
        	TimeSpan span3 = span1.Subtract(span2);
        If this results in 3 min, how would I use this?
        Last edited by ginx10k; 11-26-2015, 11:40 AM.

        Comment


          #5
          Hello,

          Thank you for the reply.

          For what you are wanting to do, because there is no way to draw on the last X time of a bar, this could require some logic to get working. All drawing objects are locked to Bar placement values, so for example a 5 minute series can only have objects placed on each 5 minute bar.

          You would likely need to either add a 1 minute series or execute this logic for only the primary series on 1 minute. This would also depend on the CalculateOnBarClose setting, I will provide one possibility below assuming this is set to true.

          On each 5 minute bar store the 5 minute bars time to a variable
          On each 1 minute bar, check if the Current 1 minute bars time is 3 minutes from the start of the stored time.
          Once the value is 3 minutes after the start time, store the 1 minute bars CurrentBar as the rectangle start bar and plot the rectangle from the Stored bar to the Current bar.
          Now when the 5 minute bar closes once again, reset the time variable to the new time.

          This could potentially work for a single box in realtime, it would depend on the specifics of what you are trying to do on how you would need to execute this but this should provide some ideas on what could potentially be used.

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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          15 responses
          3,271 views
          0 likes
          Last Post xiinteractive  
          Started by Tim-c, Today, 02:10 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Taddypole, Today, 02:47 PM
          0 responses
          2 views
          0 likes
          Last Post Taddypole  
          Started by chbruno, 04-24-2024, 04:10 PM
          4 responses
          51 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          10 responses
          403 views
          1 like
          Last Post beobast
          by beobast
           
          Working...
          X