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

Finding Session Start Times

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

    Finding Session Start Times

    I am having a heck of time here. I want to draw a fibonacci retracement over the most current trading days first 30 minutes. I think I have all the code down, but the Bars.SessionBegin always comes up as 2/15 instead of the most current date.

    Here is my current code... can anyone help?

    (I also know the high and low finding routine is hardcoded now for three periods, that is an issue I have not made it to yet)

    Code:
    protected override void OnBarUpdate()
            {
                DrawTextFixed("tempdate",Bars.SessionBegin.ToString(),TextPosition.BottomRight);
                this.m_bFibsSet = true;
                
                if(this.m_LastCurrentDate != Bars.SessionBegin)
                {
                    this.m_LastCurrentDate = Bars.SessionBegin;
                    this.m_bFibsSet = false;
                }
                
                if(!this.m_bFibsSet && CurrentBar != 0)
                {
                    if(Bars.Period.Id != PeriodType.Minute)
                    {
                        this.m_bFibsSet = true; //only plot this on minute charts
                    }
                    else
                    {
                        int nBarLength = Bars.Period.Value;
                        
                        if(nBarLength > 10)
                        {
                            this.m_bFibsSet = true; //this is for 10-min charts or smaller
                        }
                        else
                        {
                            //we only want the most current session
                            //if(    Bars.SessionBegin.Day == DateTime.Now.Day && 
                            //    Bars.SessionBegin.Month == DateTime.Now.Month &&
                            //    Bars.SessionBegin.Year == DateTime.Now.Year)
                            {
                                //we now need to find how many minutes have ticked by since the open
                                //how many minutes in a bar
                                int nNumBars = NumberOfMinutes/Bars.Period.Value;
                                
                                if(Bars.BarsSinceSession == nNumBars)
                                {
                                    //find the high
                                    double nHigh = Math.Max(Math.Max(High[2],High[1]),High[0]);
                                    double nLow = Math.Min(Math.Min(Low[2],Low[1]),Low[0]);
                                    
                                    
                                    DrawFibonacciRetracements("TheFib",2,nHigh,0,nLow);
                                    this.m_bFibsSet = true;
                                    
                                    //DrawTextFixed("tempdate",this.m_LastCurrentDate.ToString(),TextPosition.BottomRight);
                                }
                            }
                        }
                    }
                }

    #2
    Actually I would like to be able to choose whether or not to plot the opening 30 mins with a fib or to take the prior day's low/high and plot a fib against the low/high of the open on the current day's first bar. Any advice?

    Comment


      #3
      Hello,

      Someone will respond to your post as soon as possible on Monday.
      DenNinjaTrader Customer Service

      Comment


        #4
        Hi, unfortunately this is not supported - however have you checked this script from our sharing section, it may already deliver what you're after - http://www.ninjatrader-support2.com/...&id=63&catid=1

        Otherwise I can suggest debugging you code with those tips to check if the implemented logic delivers - http://www.ninjatrader-support2.com/...ead.php?t=3418
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by lightsun47, Today, 03:51 PM
        0 responses
        4 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        8 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        44 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        13 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        9 views
        0 likes
        Last Post port119
        by port119
         
        Working...
        X