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

Problem with bar closure

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

    Problem with bar closure

    Hi. I'm a rookie programmer.
    I have this code
    (Volume[0] < Volume[1])&&(Volume[1] > Volume[2])
    The bar that fulfills this condition will be called the Bv
    I don't know how to do this now.
    If the Low[0] is < Bv then draw arrow
    thank you.

    #2
    Hello julifro,

    Thanks for your post.

    It depends on what of the Bv bar you are wishing to compare. I'll show a couple of ways.

    You could make Bv an int variable that holds the bar number of the latest bar that meets the criteria. You can then subtract the Bv from the CurrentBar to get the bars ago that the Bv was and reference that bars data, for example:

    if (Volume[0] < Volume[1])&&(Volume[1] > Volume[2])
    {
    Bv = Currentbar; // save bar number of the Bv bar
    }

    if (Low[0] < Low[CurrentBar - Bv]) // if the low is less than the low of the Bv bar.
    {
    // draw the arrow
    }

    Alternatively, if all you are interested in is the low Bv value then you could make the Bv a double variable and just store the low of the Bv bar at that point, for example:

    if (Volume[0] < Volume[1])&&(Volume[1] > Volume[2])
    {
    Bv = Low[0]; // save the Bv bar low value
    }

    if (Low[0] <Bv) // if the low is less than the low of the Bv bar.
    {
    // draw the arrow
    }
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by LiamTwine, Today, 08:10 AM
    0 responses
    0 views
    0 likes
    Last Post LiamTwine  
    Started by Balage0922, Today, 07:38 AM
    0 responses
    5 views
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    19 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    6 views
    0 likes
    Last Post Creamers  
    Working...
    X