Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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(CloseWMA(Close20), 1)
    CrossBelow(MedianWMA(Close20), 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:	194
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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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(CloseWMA(20), 1)

            then

            EnterLongStopMarket
            (DefaultQuantity, (High[0] + (10 TickSize)) , "");
            Draw.ArrowUp(this, @"Long..."false0, 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:	180
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.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by pechtri, 06-22-2023, 02:31 AM
              8 responses
              122 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by frankthearm, 04-18-2024, 09:08 AM
              16 responses
              64 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by habeebft, Today, 01:18 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by benmarkal, Today, 12:52 PM
              2 responses
              13 views
              0 likes
              Last Post benmarkal  
              Started by f.saeidi, Today, 01:38 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X