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

Creating a Simple Font

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

    Creating a Simple Font

    I've used the sample in this thread to create a SimpleFont in NT8 and it works fine with just one indicator. https://ninjatrader.com/de/support/f...ects#post19660

    However, I've got multiple indicators creating text on the screen and for simplicity purposes I'd like to re-use the font in other indicators. I tried duplicating all the code in each indicator (which isn't very elegant) and while it works initially, at some point when a chart refreshes all the text reverts back to the default font (which is way to big for my text).

    Would somebody point me in the right direction about how to create this font in function/library so that it can be re-used appropriately?

    Thanks in advance,

    Nick


    #2
    Hello Nick,

    1. If it's shared code, put this in a separate file, either in (preferably) a custom namespace, or the NinjaTrader.NinjaScript.Indicators namespace.

    2. In each indicator create a new public variable of that type. Serialize it because a font is not a string (or easily converted to a string)

    3. Use that public variable anywhere a simplefont type is needed.

    However, to get specific, I want to clarify what you meant. Are you trying to use the same default font for new instances of scripts, or do you want to propagate changes in one script to the other scripts?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for the quick reply. I'm little bit a newbie to C# can you elaborate on those three steps.

      1. What does it mean to put shared code in a custom namespace or the NinjaTrader.NinjaScript.Indicators namespace? Do you have an example?
      2. I currently don't have any public variables in my indicator scripts (only public properties). Would I put a public variable above the public class declaration of my Indicator?
      3. I think I can figure #3 out. Probably 1-2 as well but will take a bit of digging and hacking which I'm already doing. I realize this forum is not a C# learning forum.

      In terms of clarifying what I trying to do, here's a sample Draw.Text piece of code that gets used with different inputs. But the EMFont parameter is always the same. I don't want to have to redefine it in each indicator, but instead define it once and re-use it. Thanks for the education.

      HTML Code:
       Draw.Text(this, @"EMMS_Down"+CurrentBar, true, "MS"+intADXFast, 0, High[0]+intArrowOffset+IndicatorOffset, 0, Brushes.Yellow, EMFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
      Nick

      Comment


        #4
        Hello nduckste,

        1. If you have not started with the Strategy Builder 301 and NinjaScript Editor 401 videos (where the namespaces are discussed) I would recommend starting with the training material.
        https://ninjatrader.com/support/foru...040#post786040

        Below is a link to reference sample that has an enum in a custom namespace.
        https://ninjatrader.com/support/help...ned_parame.htm

        I am also including a link to the microsoft documentation.
        https://docs.microsoft.com/en-us/dot...de/namespaces/

        2. Class level variables need to be within the scope of the class. (Between the curly braces for the class)

        This can be above methods below methods, that does not matter, as long as they are not within a method.

        3. Not certain I am understanding the question here. Are you asking if the EMFont parameter is valid? We cannot see the declaration for this or the assignment of an instantiated object so we would not be able to say.
        Last edited by NinjaTrader_ChelseaB; 02-04-2021, 10:43 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the resources. I have watched 301 but not 401. Without having a problem at hand, the concepts went over my head. I'll dig into this and get back to the thread if I get stuck.

          Cheers,

          Nick

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by JoMoon2024, Today, 06:56 AM
          0 responses
          6 views
          0 likes
          Last Post JoMoon2024  
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          17 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          5 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Working...
          X