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

Display Bug in DrawText Method

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

    Display Bug in DrawText Method

    When I invoke DrawText from a strategy's BarsInProgress==1 code, I find that the text displayed is off by a bar ... it should be 1 bar further to the right.

    See attached.
    Attached Files

    #2
    KBJ, thanks for the post - I'll try reproducing this on my end.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      KBJ, I tried this on my end but not sure I follow what you would expect to see - the DrawText is placed on the next bar after your barcount condition is fullfilled.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        KBJ, I tried this on my end but not sure I follow what you would expect to see - the DrawText is placed on the next bar after your barcount condition is fullfilled.
        Bertrand, The "next bar after" would be the bar to the right of the current bar, and I would understand it if that were happening. (I might not like it, but I would understand it.)

        Inseead, the text is being displayed 1/2 to 1.5 bars to the left of the bar in question (see my screen snapshot again).

        Since the DrawText method is being called from immediately after the EnterLong call, shouldn't the text be displayed on the same bar as the trade visualization?

        (That's all I'm trying to do, by the way, is to just add some additional text to the trade visualization, for which there is no provision in the overloads for SetStopLoss and SetProfitTarget. Add to feature suggestions?)

        I'd expect the text display to be a bar to the left if I'd specified the "barsAgo" parameter with a value of 1, but I didn't do that.

        Is there some other nuance that I'm missing here?

        Comment


          #5
          KBJ, thanks for clarifying - in backtesting the EnterLong is processed on the following bar, so this would explain the differences you note. Maybe drawing on the this on the BIP 1 OnBarUpdate would bring you closer to what you seek.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Bertrand, Thanks for the explanation.

            It was already calling the DrawText method on the BarsInProgress==1 OnBarUpdate.

            I changed the design so it now does the display on the next BarsInProgress==1 OnBarUpdate. This now works but is lots of extra coding.

            What contortions it takes to make it do what I want.

            If anyone's interested, the working version of the code is attached. (It is, at least a good ... and fairly well commented ... example of how to switch control back and forth between the OnBarUpdate calls with the different BarsInProgress values.)
            Attached Files

            Comment


              #7
              KBJ, thanks for sharing this.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cre8able, Yesterday, 01:16 PM
              3 responses
              11 views
              0 likes
              Last Post cre8able  
              Started by ChartTourist, Today, 08:22 AM
              0 responses
              5 views
              0 likes
              Last Post ChartTourist  
              Started by LiamTwine, Today, 08:10 AM
              0 responses
              2 views
              0 likes
              Last Post LiamTwine  
              Started by Balage0922, Today, 07:38 AM
              0 responses
              5 views
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Working...
              X