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

Can't draw

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

    Can't draw

    What's the problem with the following code? It doesn't draw. Tried everything - to no avail.

    private double sessionOpen = 0;

    protected override void OnMarketData()
    {
    if (sessionOpen == 0)
    {
    sessionOpen = Close[0];
    DrawHorizontalLine("sessionOpenLine", true, sessionOpen, Color.Blue, DashStyle.Solid, 1);
    }
    }

    #2
    Hello,

    Are you receiving any errors on the Log tab?

    Why are you doing this in OnMarketData? This would be more CPU intensive. I'd suggest moving it to OnBarUpdate()

    If you wish to use it in OnMarketData, you are missing some over rides.

    The following should work as long as your connected to a data provider and getting OnMarketData calls

    Code:
            protected override void OnMarketData(MarketDataEventArgs e)
            {
    
                if (sessionOpen == 0)
                {
    
                    sessionOpen = Close[0];
                    DrawHorizontalLine("sessionOpenLine", true, sessionOpen, Color.Blue, DashStyle.Solid, 1);
    
                }
    
            }
    MatthewNinjaTrader Product Management

    Comment


      #3
      No errors, tried also inside OnBarUpdate, doesn't work. I feel myself stupid..
      Should one call suffice, or do I need to call the method in connection with each new bar? All I need is one horizontal line extending from start of trading to present.

      Comment


        #4
        One call should be enough to Draw it.

        Are you connected to a data provider when doing this?

        If you put a Print(Time[0]) statement in OnBarUpdate, do you get any recent calls?
        MatthewNinjaTrader Product Management

        Comment


          #5
          Simulated data feed, Sim account, OnBarUpdate and OnMarketData get called by turns (verified), and everything else works as one could expect with Sim feed & account. Or do draw methods require real-time data?

          Comment


            #6
            Matthew,
            Interesting finding: If I launch the strategy from a chart, the line appears. If from Control Center / Strategies tab (right click and so forth...), it doesn't. Is this a bug or a feature

            Comment


              #7
              Originally posted by jp_kettunen View Post
              Matthew,
              Interesting finding: If I launch the strategy from a chart, the line appears. If from Control Center / Strategies tab (right click and so forth...), it doesn't. Is this a bug or a feature
              If you don't start the strategy in a chart, the strategy won't know where to draw things.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,607 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              9 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              19 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              6 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              16 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X