Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Chart Styles

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

    Custom Chart Styles

    Hello,

    I feel like I'm trying to do something relatively simple, but I just can't seem to get it to work.

    All I'm trying to do is take the Hollow Candlestick chart style and get it to fill in the down bars with the same color it's using for the outline. I'd like it to be exactly the same otherwise.

    I've tried creating a new ChartStyle in ninjascript with the wizard but two things happen when I do that. The first is that no matter what I do, I can't even get the new custom chartstyle (I just named it tester) to be an option in the "Chart Style" drop down menu in the Data Series panel. This is after saving and compiling. Afterwards, I tried just copying the entire HollowCandlestick ninjascript verbatim into another test chartstyle just to see if that would work but when I save and compile, it throws a ton of errors.

    As another test, I looked for a free download of a chart style online to tinker with but couldn't find anything compatible. Tried an indicator instead, but now I'm getting the "One of your ninjascipt add-ons has errors, please correct before adding more" error. I went into the bin/Custom/ChartStyles folder and deleted all files that did not have the @ symbol for the first character. Upon reboot, I checked that drop-down menu again and to my surprise, one of the test ChartStyles I made was in the dropdown menu, the script I just deleted. I'm not sure what's going on. If it helps, this is my first adventure with ninjascript, but not my first experience with C#. I did some projects with the microsoft kinect in college, which also uses C#, but that was years ago in college.

    Any help would be sincerely appreciated



    tl,dr; Trying to modify a copy of an existing chart style but can't get it to compile or even populate the "chart style" drop-down menu of the "data series" panel

    #2
    Hello Convert,

    Welcome to the NinjaTrader support forum.

    All I'm trying to do is take the Hollow Candlestick chart style and get it to fill in the down bars with the same color it's using for the outline. I'd like it to be exactly the same otherwise.
    For this item, the easiest solution would be to duplicate the existing hollow candlestick chart style and then modify that.

    The first is that no matter what I do, I can't even get the new custom chart style (I just named it tester) to be an option in the "Chart Style" drop-down menu in the Data Series panel. This is after saving and compiling.
    Without more details, it sounds like potentially the ID or Name have not been set to a unique value here.


    Afterward, I tried just copying the entire HollowCandlestick ninjascript verbatim into another test chart style just to see if that would work but when I save and compile, it throws a ton of errors.
    Yes, you would not be able to directly copy a type by copy/pasting it because of naming conflicts. This is a C# language feature, or that you cannot have two identically named classes. To get around this you just need to save the file the correct way. In the editor, first, open the file you want to duplicate then Right click -> Save As. this will rename the class and name of the NinjaScript item to what you name it preventing the errors.

    After making the duplicate, you can look at the existing Candlestick chart style for examples of filling a rectangle that is the size of the candle, the quick answer is that it would require the use of FillRectange() instead of DrawRectangle().

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Alright, so I did exactly as you suggested. I opened the HollowCandleStick chart style in the editor and then right-clicked > save as > bigbird. I changed nothing else. It still does not give me the option to select bigbird as a chart type, not from the Data Series panel, nor from the little button next to time frame selection on the chart itself. Am I looking for it in the wrong place? Is there some extra step after saving and compiling that I need to do in order to actually be able to select it as a chart style? I've rebooted the software and computer hoping that would fix it but I still can't apply it to a chart.

      Thanks again for your help

      Comment


        #4
        Hello Convert,

        Thank you for the reply.

        Yes if nothing else was changed it would retain the original Name and ID. I should have noted this again following the save as instructions, this is the same comment as before:

        it sounds like potentially the ID or Name have not been set to a unique value here.
        You would need to give it a unique Name and ID, the SaveAs step just gives the class the correct name along with the actual file.

        Code:
        protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        Name            = "TestStyle";
                        ChartStyleType    = (ChartStyleType) 5468; //this should be a fairly unique number less than int.maxvalue if you plan to distrubute this
                    }
        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Works like a charm. Those migrating from thinkorswim might appreciate this look, I've attached the script if anyone's interested. The closest matching colors imho are LimeGreen, OrangeRed, and LightGray.

          Thanks again for your help, Jesse. I greatly appreciate it

          ComboCandleStyle.zip

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by stafe, Today, 10:43 AM
          0 responses
          2 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by UltraNIX, Today, 09:13 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by Tuxstuff215, Today, 06:32 AM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by carlot, Today, 08:10 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by KirkHammett, Yesterday, 11:15 PM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X