Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy doesnt enable with this instruction line

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

    Strategy doesnt enable with this instruction line

    Hello group,
    I've code this simple Bullish/bearish Engulfing pattern but the strategy doesnt enable when addding this third Close/open instruction.

    Here's my simple code:



    //Engulfing pattern
    //Bullish
    if ( Open[1] > Close[1] && Open[0] <= Close[1] && Close[0] >= Open[1] && (ToTime(Time[0]) >= 93000 && ToTime(Time[0]) <= 155000) )
    {
    //Draw.ArrowUp(this, @"Bullish Engulfing" + CurrentBars[0].ToString(), true, 0, (Low[0] + (-1 * TickSize)) , Brushes.White);
    }
    //Bearish
    else if ( Open[1] < Close[1] && Open[0] >= Close[1] && Close[0] <= Open[1] && (ToTime(Time[0]) >= 93000 && ToTime(Time[0]) <= 155000) )
    {
    Draw.ArrowDown(this, @"Bearish Engulfing" + CurrentBars[0].ToString(), true, 0, (High[0] + (1 * TickSize)) , Brushes.White);
    }​



    In this code, I have 3 simple instructions (on each side) related to Open/Close and another instruction related to the time I want the strategy to be active.

    If I remove 1 Open/Close instruction on each line, the strategy can be enabled without any problem (but it's no longer a complete engulfing instruction) but not with the 3 'blocks'.

    I had the same problem yesterday with another code involving this OHCL problem not accepting more than 2 instructions of this type.

    What's the problem here please? Is there a limitation on those OHCL instructions we cant involve more than 2 'blocks' of code in a single line?

    Thanks in advance.


    #2
    Question no longer required.

    I found that this 2 lines of code is required within <protected override void OnBarUpdate()> so it could be processed correctly.


    if (CurrentBars[0] < 1)
    return;



    I post that here so future people having the same problem could find this response useful for them.

    Thanks anyway and sorry for this.

    Have a nice day!​

    Comment


      #3
      Hello Bricolico,

      Thanks for your post.

      Yes, you should include a CurrentBars check at the top of your OnBarUpdate() section of code in the script to make sure you have enough bars for the data series you are accessing.

      See this help guide page for more information: https://ninjatrader.com/support/help...nough_bars.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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X