Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The name "IsFirstBarOnChart" does not exist in the current chart

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

    The name "IsFirstBarOnChart" does not exist in the current chart

    Team - I am new to the coding and trying to embed my custom code in the strategy and it give me the following error:
    The name "IsFirstBarOnChart" does not exist in the current chart
    The name "IsLastBarOnChart" does not exist in the current chart

    How do I fix this.The code is below:

    {

    if (IsFirstBarOnChart && Close[1] < Open[1])
    {
    Then...............
    }

    if (IsLastBarOnChart && Position.MarketPosition == MarketPosition.Long)
    {
    ​Then....


    Thanks and your help is much appreciated.
    Last edited by NRITV; 01-12-2024, 07:01 PM.

    #2
    Hello NRITV,

    Thanks for your post.

    IsFirstBarOnChart and IsLastBarOnChart are not supported NinjaScript methods or properties found in the help guide which is why the error messages are occurring.

    To check for the first bar on a chart you could consider creating a condition that checks if CurrentBar is equal to 0.

    CurrentBar returns the number of bars on the chart.

    Bars are counted from the leftmost bar to the rightmost bar on the chart. The first bar (leftmost bar) on a chart would have a bar index of 0.

    See this help guide page for more information about CurrentBar: https://ninjatrader.com/support/help...currentbar.htm

    Below is a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:


    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:


    And the MSDN (Microsft Developers Network) C# Language Reference.
    https://ninjatrader.com/support/help...erence_wip.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X