Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time and drawing lines

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

    Time and drawing lines

    Hi,

    How do I instruct the code to draw the line till 4am or till the end of regular trading hours, which ever is later, taking into account daylight saving. How would the endTime be input? I tried keying in various combinations of 040000 but it got rejected.

    This is the code I'm trying to use:-

    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, DashStyleHelper dashStyle, int width)

    I'm using the attached code which I got from Ninjatrader's ecosystem but when I select the "Extend Line", it is drawing the line way past the end of session - till 11:59pm.

    Thanks in advance.

    Regards

    Kay Wai
    Attached Files
    Last edited by kaywai; 06-10-2021, 03:29 AM.

    #2
    Hello kaywai,

    Thanks for the post.

    To draw a line between two times you would need to first figure out the end time and which you wanted to use.

    You can get the trading hours for the given instrument by using the session iterator: https://ninjatrader.com/support/help...essioniterator

    You could then check if the 4am time or the trading hours time is greater to save whichever is greater to a variable.

    Code:
    DateTime endTime     = sessionIterator.ActualSessionEnd;
    DateTime myEndTime = endTime; 
    DateTime fourAmTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 4,0,0); 
    if(fourAmTime > endTime)
        myEndTime = fourAmTime;
    Once you have the end time you wanted to use you can supply that as the end time.

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

    Comment


      #3
      Thank you Jesse. That worked like a gem! Appreciate it.

      Regards
      Kay Wai

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by junkone, Yesterday, 08:06 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by fscabrera03, Yesterday, 07:27 PM
      1 response
      5 views
      0 likes
      Last Post tradecombine  
      Started by Rad4633, Yesterday, 05:31 PM
      0 responses
      2 views
      0 likes
      Last Post Rad4633
      by Rad4633
       
      Started by litamm89, Yesterday, 03:51 PM
      0 responses
      6 views
      0 likes
      Last Post litamm89  
      Started by sgordet, Yesterday, 01:52 PM
      3 responses
      12 views
      0 likes
      Last Post NinjaTrader_Tyler  
      Working...
      X