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

Passing a Brush as a Parameter

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

    Passing a Brush as a Parameter

    If I am using multiple time frames and my code is structured to call a general Main routine
    which is passed different parameters based on BarsInProgress. How can you ever pass it directly a Brush ? As I understand it the Receiving Brush in the routine needs to be frozen before being used in a Draw routine, and if you do that, on the second call you are trying to write to something that is Frozen from the first pass. Or do you not have to Freeze it because if it is called with a frozen parameter the Brush within the routine simply inherits the attributes?

    Am I missing something here ? What is the explanation ?

    Thanks
    Jerry
    Last edited by JerryWar; 11-30-2016, 10:53 AM.

    #2
    Hello Jerry,

    If you are doing custom rendering, freeze the brush after you create it. In OnRenderTargetChanged() recreate the brush and refreeze it.

    Below is a link to an example that demonstrates.


    If you are not doing custom rendering in OnRender(), don't worry about freezing the brush. Whatever you are passing the brush to will have its own OnRender() and will freeze the brush itself when it needs to.

    You can pass a brush object to an indicator by creating a NinjaScript public property for it. The NinjaTrader generated code will automatically create additional overload methods to call the indicator with that as a parameter.

    If you are making your own custom class, add addition overload methods for each of the different parameter combinations you would like.
    Below is a link to an C# educational site that demonstrates.
    Use overloaded method calls. Inspect the IL code for overloads.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by zstheorist, Today, 07:52 PM
    0 responses
    3 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    149 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Working...
    X