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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      72 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      143 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      76 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      47 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X