Announcement

Collapse
No announcement yet.

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 Hwop38, 05-04-2026, 07:02 PM
              0 responses
              173 views
              0 likes
              Last Post Hwop38
              by Hwop38
               
              Started by CaptainJack, 04-24-2026, 11:07 PM
              0 responses
              328 views
              0 likes
              Last Post CaptainJack  
              Started by Mindset, 04-21-2026, 06:46 AM
              0 responses
              252 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by M4ndoo, 04-20-2026, 05:21 PM
              0 responses
              354 views
              0 likes
              Last Post M4ndoo
              by M4ndoo
               
              Started by M4ndoo, 04-19-2026, 05:54 PM
              0 responses
              181 views
              0 likes
              Last Post M4ndoo
              by M4ndoo
               
              Working...
              X