Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last time value - after script start

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

    Last time value - after script start

    Hi. I have a question about start of ninja script, where is comparing current time.

    There is my code:

    Stav=0;
    protected override void OnBarUpdate()
    {
    switch(Stav)
    {
    case 0:
    if (ToTime(Time[0]) == ToTime(13,40,0))
    {
    Stav = 1;
    }
    break;

    case 1:
    EnterLong();
    break;
    }
    }

    For example, when actual time is 16:30 so after start of this strategy is open Long. I tried to check Time[0] trought Output window and after start has Time[0] some historical values. Example: 233000, 233100, 233200, 233300,... to the last 162900 and 163000. But in this series is value 134000 and Long order is executed. Could you help me how to start counting from last time value? Thank you

    #2
    Hello hanysfx,

    Thank you for your post.

    When enabling your strategy it will load historical bars. So when you Print(Time[0]) there will be historical prints for the time up until the most recent bar update.

    You can use something like the following which will only print the time on real-time bars and not historical:
    Code:
    if(!Historical)
    {
    Print(Time[0]);
    }
    However, you mention a counter to count the time. Is this to count the time since your entry?

    I look forward to your response.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    80 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    66 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X