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

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. "
    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 adeelshahzad, Today, 03:54 AM
              4 responses
              22 views
              0 likes
              Last Post adeelshahzad  
              Started by merzo, 06-25-2023, 02:19 AM
              10 responses
              823 views
              1 like
              Last Post NinjaTrader_ChristopherJ  
              Started by frankthearm, Today, 09:08 AM
              5 responses
              15 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              43 views
              0 likes
              Last Post jeronymite  
              Started by yertle, Today, 08:38 AM
              5 responses
              16 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X