Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Candle crossAbove()/CrossBelow() seems not to be always working

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

    Candle crossAbove()/CrossBelow() seems not to be always working

    I am executing entry orders whenever a candle is crossing above/below the MA; however, it seems to work sometimes, and sometimes it doesn't.

    Example of what I am doing:

    PHP Code:
    
    //If Any
    
    CrossBelow(Close, WMA(Close, 20), 1)
    CrossBelow(Median, WMA(Close, 20), 1) 
    
    Here is a screenshot showing what's happening:

    Click image for larger version

Name:	Screen Shot 2021-05-31 at 11.27.22.jpg
Views:	256
Size:	256.1 KB
ID:	1158210

























    P.S I am using the strategy builder.
    Attached Files

    #2
    Hello Harry Croi,

    Thanks for the post.

    Are the indicators pictured being manually added or has your strategy added them for you? In some cases manually added indicators may not line up with strategy indicators. The best way to observe when the condition is true would be to use prints in the condition.

    If you manually added the indicators, try removing them and then have the strategy use AddChartIndicator. If you are using the strategy builder you can check the plot on chart option when configuring the conditions.



    I look forward to being of further assistance.

    Comment


      #3
      Hello,

      The indicators were added from the strategy, not manually.

      Comment


        #4
        Hello Harry Croi,

        Thanks for the post.

        I would suggest using a Print and the NinjaScript output window in that situation. A print could be added to the action of your condition. Observing the NinjaScript output window to see if that print outputs for those areas would be helpful to know if the condition was true or not. If the condition was not true it may be that a cross was not detected. Another set could be used with no conditions if you wanted to output the values used in your conditions for each bar.

        https://ninjatrader.com/support/help...nt8/output.htm

        An action of Misc -> Print could be used to output items like the Time and a message. The message can include other items like indicator or price values so you can explore the condition in more detail for each bar.



        I look forward to being of further assistance.

        Comment


          #5
          Thanks for getting back.

          Will it work when being in "Playback mode" ?

          Comment


            #6
            Seems that there is something wrong, what I am trying to achieve so far is something very simple:

            PHP Code:
            if
            
            CrossAbove(Close, WMA(20), 1)
            
            then
            
            EnterLongStopMarket(DefaultQuantity, (High[0] + (10 * TickSize)) , "");
            Draw.ArrowUp(this, @"Long...", false, 0, Default input[0], Brushes.Lime); 
            
            However, although the bar crosses WMA 20, nothing happens, you may clearly see that many bars crossing above the WMA, but no long conditions are being triggered.

            Click image for larger version

Name:	Screen Shot 2021-06-01 at 00.34.56.jpg
Views:	243
Size:	44.1 KB
ID:	1158326

            Comment


              #7
              Hello Harry Croi,

              Thanks for the post.

              Yes prints work in playback mode.

              Have you tried using EnterLong instead of a stop market? If the cross above is no longer true on the next bar and the order has not filled it will be expired. You can enable TraceOrders from the builders configuration menu and then observe the NinjaScript output window to see if that order was expired.



              I look forward to being of further assistance.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              64 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              139 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              75 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X