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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      46 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      22 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X