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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X