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 frslvr, 04-11-2024, 07:26 AM
    9 responses
    123 views
    1 like
    Last Post caryc123  
    Started by rocketman7, Today, 09:41 AM
    4 responses
    15 views
    0 likes
    Last Post rocketman7  
    Started by selu72, Today, 02:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by WHICKED, Today, 02:02 PM
    2 responses
    16 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Working...
    X