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 Barry Milan, Today, 10:35 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by WeyldFalcon, 12-10-2020, 06:48 PM
    14 responses
    1,427 views
    0 likes
    Last Post Handclap0241  
    Started by DJ888, Yesterday, 06:09 PM
    2 responses
    9 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    40 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Today, 08:51 AM
    2 responses
    16 views
    0 likes
    Last Post bill2023  
    Working...
    X