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 Harry, 05-02-2018, 01:54 PM
        10 responses
        3,203 views
        0 likes
        Last Post tharton3  
        Started by cre8able, Yesterday, 01:16 PM
        3 responses
        11 views
        0 likes
        Last Post cre8able  
        Started by ChartTourist, Today, 08:22 AM
        0 responses
        6 views
        0 likes
        Last Post ChartTourist  
        Started by LiamTwine, Today, 08:10 AM
        0 responses
        2 views
        0 likes
        Last Post LiamTwine  
        Started by Balage0922, Today, 07:38 AM
        0 responses
        5 views
        0 likes
        Last Post Balage0922  
        Working...
        X