Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Right margin

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

    Right margin

    I'm trying to make adjustable right margin. Bigger if CurrentBar == ChartBars.ToIndex otherwise it should be smaller. But chart starts blinking if CurrentBar == ChartBars.ToIndex and I move right-left with my mouse. Same with ctrl + arrows.

    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    if (ChartBars == null) return;
    ChartControlProperties myProperties = chartControl.Properties;// Instantiate a ChartControlProperties object to hold a reference to chartControl.Properties

    if (CurrentBar == ChartBars.ToIndex && !SmartMarginSet)
    {
    myProperties.BarMarginRight = SmartMarginValue;
    SmartMarginSet = true;
    }
    else
    {
    myProperties.BarMarginRight = BasicMarginValue;
    SmartMarginSet = false;
    }
    }

    #2
    Hello Leeroy_Jenkins,

    Putting this in OnRender() is going to cause a huge amount of cpu usage. I would recommend doing this in OnBarUpdate or OnMarketData. There can be hundreds of render passes in just a few seconds, especially when scrolling the chart. Making changes to the visual properties or making changes to WPF is not recommended in OnRender().

    Just to clarify, you want modify the visual margin once you have scrolled all the way to the right?

    As a heads up:
    "Warning: These are UI properties which are designed to be set by a user. Attempting to modify these values through a custom script is NOT guaranteed to take effect. "
    https://ninjatrader.com/support/help...properties.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Put this in OnBarUpdate - works like a charm. Thanks.

      Comment


        #4
        Btw I have a question regarding OnOrderUpdate sample that you guys made. Let's say I wanna 5 entries with different stops. So I should make 5 entryOrder/stopOrder to handle this. My question is there any way to do so more efficient? So I don't need to make 5 entryOrder/stopOrder. One code for as many entries as I want.

        Comment


          #5
          Hello Leeroy_Jenkins,

          Yes, you should submit 5 entries with different signal names, and have the 5 stops using the From entry signal of each entry.

          I wouldn't recommend this, but in the unmanaged approach you can submit a single entry with a quantity of 5, and then submit 5 exit orders. No from entry signals are used in the unmanaged approach. You have full control over the orders.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Oh gosh that's make harder to code..
            What does this entryOrder == execution.Order check? Within OnExecutionUpdate(Execution execution..
            Can't find anything about it in manual. It checks if order executed?

            Comment


              #7
              Hello Leeroy_Jenkins,

              This would checking to see if the execution updating OnExecutionUpdate() is from the order assigned to entryOrder.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by futurenow, Today, 07:17 PM
              0 responses
              3 views
              0 likes
              Last Post futurenow  
              Started by Emma1, Today, 07:15 PM
              0 responses
              1 view
              0 likes
              Last Post Emma1
              by Emma1
               
              Started by n8dogg59, 05-10-2019, 08:00 AM
              14 responses
              621 views
              0 likes
              Last Post brownsfan019  
              Started by [email protected], Today, 06:03 PM
              0 responses
              1 view
              0 likes
              Last Post bpatel20@gmail.com  
              Started by Johnny Santiago, Today, 04:36 PM
              2 responses
              13 views
              0 likes
              Last Post -=Edge=-  
              Working...
              X