Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where Are All The Shared ChartStyles

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

    Where Are All The Shared ChartStyles

    Hi, i'm looking to see if there is some sort of FileSharing page for ChartStyles, similar to the User App Share for Indicators and Strategies


    I'd like to check if there is a NT8 version of this NT7 ChartStyle version
    https://ninjatrader.com/support/foru...969#post725969
    Else I'll try and convert it although it is challenging with the SharpDX requirement in NT8.
    or could someone tell if we could convert it without SharpDX? Thanks
    Last edited by PaulMohn; 02-07-2022, 10:20 AM.

    #2
    Hello PaulMohn,

    Thanks for your post.

    Unfortunately, there is no specific site or section of the forums pertaining to specifically finding custom ChartStyles.

    You may find some custom ChartStyles in the User App Share center. Otherwise, you would need to convert the script in question to be compatible with NinjaTrader 8.

    If the script in question uses SharpDX, it is likely that SharpDX would need to be used when converting the script to NinjaTrader 8.

    This thread will be open for other community members to share their insight on this topic.

    Below I am including a link to a list of the code-breaking changes from NinjaTrader 7 to NinjaTrader 8. The help guide page will be the best way to see how things have changed from NinjaTrader 7 to NinjaTrader 8.
    http://ninjatrader.com/support/helpG...ng_changes.htm

    Below is a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hello Brandon and thanks for the reply and info. The tricky part is that the ChartSyle Code does not uses SharpDX (NT7), but the similar NT8 ohlcStyle Chart (built in NT8) does use SharpDX.

      Here's the NT7 Code for quick reference:
      Code:
      [LIST=1][*]//[*]// Copyright (C) 2012, NinjaTrader LLC <www.ninjatrader.com>.[*]// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.[*]//[*][*]// Version 2.0, Pawnbroker, 30th October 2012[*]// Adapted by Sim22 Mar 2016 for adaptable O-C notches.[*]#region Using declarations[*]using System;[*]using System.ComponentModel;[*]using System.Drawing;[*]using System.Xml.Serialization;[*]#endregion[*][*]// This namespace holds all chart styles. Do not change it.[*]namespace NinjaTrader.Gui.Chart[*]{[*]public class OhlcChartStyle : ChartStyle[*]{[*]private static bool registered  = Chart.ChartStyle.Register(new OhlcChartStyle());[*]// private float barHigh, barLow, barClose;[*][*]private Pen             downPen     = new Pen(Color.Red, 4);[*]private Pen             upPen       = new Pen(Color.Green, 4);[*][*]/// <summary>[*]/// </summary>[*]/// <returns></returns>[*]public override object Clone()[*]{[*]OhlcChartStyle ret  = new OhlcChartStyle();[*]ret.BarWidth            = BarWidth;[*]ret.Pen                 = Gui.Globals.Clone(Pen);[*]ret.DownColor           = DownColor;[*]ret.UpColor             = UpColor;[*]return ret;[*]}[*][*]/// <summary>[*]/// </summary>[*]/// <returns></returns>[*]public override string DisplayName[*]{[*]get { return "OHLC_One11"; }[*]}[*][*]/// <summary>[*]/// </summary>[*]public override void Dispose()[*]{[*]base.Dispose();[*][*]downPen.Dispose();[*]upPen.Dispose();[*]}[*][*]/// <summary>[*]/// </summary>[*]/// <param name="barWidth"></param>[*]/// <returns></returns>[*]public override int GetBarPaintWidth(int barWidth)[*]{[*]// middle line + 2 * open/close lines[*]return (int) (Pen.Width + 2 * (2 + barWidth));[*]}[*][*]/// <summary>[*]/// </summary>[*]/// <param name="propertyDescriptor"></param>[*]/// <param name="chartStyle"></param>[*]/// <param name="attributes"></param>[*]/// <returns></returns>[*]public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, ChartStyle chartStyle, Attribute[] attributes)[*]{[*]PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, chartStyle, attributes);[*]properties.Remove(properties.Find("Pen", true));[*]properties.Remove(properties.Find("Pen2", true));[*][*]// here is how you change the display name of the property on the properties grid[*]Gui.Design.DisplayNameAttribute.SetDisplayName(pro perties, "BarWidthUI",    "\r\r\rBar width");[*]Gui.Design.DisplayNameAttribute.SetDisplayName(pro perties, "DownColor",     "\r\r\rColor for down bars");[*]Gui.Design.DisplayNameAttribute.SetDisplayName(pro perties, "UpColor",       "\r\r\rColor for up bars");[*][*]return properties;[*]}[*][*]/// <summary>[*]/// </summary>[*]public override bool IsTransparent[*]{[*]get { return UpColor == Color.Transparent && DownColor == Color.Transparent && Pen.Color == Color.Transparent; }[*]}[*][*]/// <summary>[*]/// </summary>[*]public OhlcChartStyle() : base(ChartStyleType.Custom7)[*]{[*]this.DownColor  = Color.Red;[*]this.UpColor    = Color.Green;[*]}[*][*]/// <summary>[*]/// </summary>[*]/// <param name="chartControl"></param>[*]/// <param name="graphics"></param>[*]/// <param name="bars"></param>[*]/// <param name="panelIdx"></param>[*]/// <param name="fromIdx"></param>[*]/// <param name="toIdx"></param>[*]/// <param name="bounds"></param>[*]/// <param name="max"></param>[*]/// <param name="min"></param>[*]public override void PaintBars(ChartControl chartControl, Graphics graphics, Data.Bars bars, int panelIdx, int fromIdx, int toIdx, Rectangle bounds, double max, double min)[*]{[*]Pen tmpUpPen    = Gui.Globals.Clone(this.upPen);    // work on copy, not on original object, otherwise issues with chart bars flickering on OHLC[*]Pen tmpDownPen  = Gui.Globals.Clone(this.downPen);  // work on copy, not on original object, otherwise issues with chart bars flickering on OHLC[*][*]if (tmpDownPen.Color != DownColor)[*]tmpDownPen.Color = DownColor;[*][*]if (tmpUpPen.Color != UpColor)[*]tmpUpPen.Color = UpColor;[*][*]Color   barColor;[*]int     barWidth        = bars.BarsData.ChartStyle.BarWidthUI;[*]int     close;[*]double  closeValue;[*]int     high;[*]int     low;[*]Color   oldColor        = Color.Empty;[*]int     open;[*]double  openValue;[*]Pen     pen             = tmpUpPen;[*]int     penWidth;[*]int     penHalfWidth;[*]int     x, x1, CloseWidth;[*][*]if (Math.Max(1, barWidth - 2) != tmpUpPen.Width)[*]{[*]tmpDownPen  = new Pen(DownColor, Math.Max(1, barWidth - 2));[*]tmpUpPen    = new Pen(UpColor, Math.Max(1, barWidth - 2));[*]}[*][*]for (int idx = fromIdx; idx <= toIdx; idx++)[*]{[*]barColor        = chartControl.GetBarOverrideColor(bars, idx);[*]closeValue      = bars.GetClose(idx);[*]close           = chartControl.GetYByValue(bars, closeValue);[*]high            = chartControl.GetYByValue(bars, bars.GetHigh(idx));[*]low             = chartControl.GetYByValue(bars, bars.GetLow(idx));[*]openValue       = bars.GetOpen(idx);[*]open            = chartControl.GetYByValue(bars, openValue);[*]pen             = (closeValue >= openValue ? tmpUpPen : tmpDownPen);[*]penHalfWidth    = (int) (pen.Width / 2);[*]penWidth        = (int) pen.Width;[*]x               = chartControl.GetXByBarIdx(bars, idx);[*]x1              = chartControl.GetXByBarIdx(bars, idx - 1);[*][*]if (barColor != Color.Empty)[*]{[*]oldColor    = pen.Color;[*]pen.Color   = barColor;[*]}[*][*]pen.Width = penWidth;   // important to alleviate selecting the bar series[*]//CloseWidth = (int)(Math.Min(penWidth + penHalfWidth, (x -x1)  / 2.2)) ; //original is CloseWidth = (x -x1)  / 2;[*]CloseWidth = (int)(Math.Max(penHalfWidth * 1.1, Math.Min(penWidth + (double)penHalfWidth * 0.8, (x -x1)  / 2.2)));[*][*]graphics.DrawLine(pen, x - CloseWidth, open, x, open);[*]graphics.DrawLine(pen, x, Math.Min(high, low) - penHalfWidth, x, Math.Max(high, low) + penHalfWidth);[*]graphics.DrawLine(pen, x, close, x + CloseWidth,    close);[*][*]if (barColor != Color.Empty)[*]pen.Color = oldColor;[*]}[*][*]tmpDownPen.Dispose();[*]tmpUpPen.Dispose();[*]}[*]}[*]}[/LIST]
      Can it be converted without using SharpDX?
      Could you please if possible contact the poster to ask (I don't know how to contact other users)? Thanks

      Comment


        #4
        And the OhlcStyle ChartStyle for NT8 code

        Code:
        [LIST=1][*]//[*]// Copyright (C) 2021, NinjaTrader LLC <www.ninjatrader.com>.[*]// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.[*]//[*]#region Using declarations[*]using NinjaTrader.Data;[*]using NinjaTrader.Gui.Chart;[*]using SharpDX;[*]using SharpDX.Direct2D1;[*]using System;[*]using System.Windows.Media;[*]#endregion[*]namespace NinjaTrader.NinjaScript.ChartStyles[*]{[*]public class OhlcStyle : ChartStyle, ISubModeProvider[*]{[*]private object icon;[*]public override int GetBarPaintWidth(int barWidth) { return 3 * barWidth; }[*]public override object Icon { get { return icon ?? (icon = Gui.Tools.Icons.ChartOHLC); } }[*]public OhlcMode Mode { get; set; }[*]public override void OnRender(ChartControl chartControl, ChartScale chartScale, ChartBars chartBars)[*]{[*]Bars                    bars            = chartBars.Bars;[*]float                   lineWidth       = (float) Math.Max(1, BarWidth);[*]Vector2                 point0          = new Vector2();[*]Vector2                 point1          = new Vector2();[*]Vector2                 point2          = new Vector2();[*]Vector2                 point3          = new Vector2();[*]Vector2                 point4          = new Vector2();[*]Vector2                 point5          = new Vector2();[*]for (int idx = chartBars.FromIndex; idx <= chartBars.ToIndex; idx++)[*]{[*]SharpDX.Direct2D1.Brush overriddenBrush = chartControl.GetBarOverrideBrush(chartBars, idx);[*]double                  closeValue      = bars.GetClose(idx);[*]float                   close           = chartScale.GetYByValue(closeValue);[*]float                   high            = chartScale.GetYByValue(bars.GetHigh(idx));[*]float                   low             = chartScale.GetYByValue(bars.GetLow(idx));[*]double                  openValue       = bars.GetOpen(idx);[*]float                   open            = chartScale.GetYByValue(openValue);[*]float                   x               = chartControl.GetXByBarIndex(chartBars, idx);[*]point0.X                                = point1.X = x;[*]point0.Y                                = high  - lineWidth * 0.5f;[*]point1.Y                                = low   + lineWidth * 0.5f;[*]SharpDX.Direct2D1.Brush b               = overriddenBrush ?? (closeValue >= openValue ? UpBrushDX : DownBrushDX);[*]if (!(b is SharpDX.Direct2D1.SolidColorBrush))[*]TransformBrush(b, new RectangleF(point0.X - lineWidth * 1.5f, point0.Y, lineWidth * 3, point1.Y - point0.Y));[*]RenderTarget.DrawLine(point0, point1, b, lineWidth);[*]if (!Equals(Mode, OhlcMode.HiLo))[*]{[*]point2.X = x + lineWidth * 1.5f;[*]point2.Y = close;[*]point3.X = x;[*]point3.Y = close;[*]RenderTarget.DrawLine(point2, point3, b, lineWidth);[*]if (Equals(Mode, OhlcMode.OHLC))[*]{[*]point4.X = x - lineWidth * 1.5f;[*]point4.Y = open;[*]point5.X = x;[*]point5.Y = open;[*]RenderTarget.DrawLine(point4, point5, b, lineWidth);[*]}[*]}[*]}[*]}[*]protected override void OnStateChange()[*]{[*]if (State == State.SetDefaults)[*]{[*]Name            = Custom.Resource.NinjaScriptChartStyleOHLC;[*]ChartStyleType  = ChartStyleType.OHLC;[*]Mode            = OhlcMode.OHLC;[*]BarWidth        = 2;[*]}[*]else if (State == State.Configure)[*]{[*]Properties.Remove(Properties.Find("Stroke", true));[*]Properties.Remove(Properties.Find("Stroke2", true));[*]SetPropertyName("BarWidth",     Custom.Resource.NinjaScriptChartStyleBarWidth);[*]SetPropertyName("UpBrush",      Custom.Resource.NinjaScriptChartStyleOhlcUpBarsCol or);[*]SetPropertyName("DownBrush",    Custom.Resource.NinjaScriptChartStyleOhlcDownBarsC olor);[*]}[*]}[*]public void SetSubmode(object mode)[*]{[*]if (mode is OhlcMode)[*]Mode = (OhlcMode) mode;[*]}[*]public override System.Collections.Generic.IEnumerable<object> SubModes { get { foreach (object value in Enum.GetValues(typeof (OhlcMode))) yield return value; } }[*]}[*]public enum OhlcMode { OHLC, HLC, HiLo }[*]}[/LIST]

        Comment


          #5
          Hello PaulMohn,

          Thanks for your note.

          If you are wanting to modify the OHLC ChartStyle in NinjaTrader 8, you could create a copy of the OHLC ChartStyle script in a NinjaScript Editor window and make the modifications to the script that you are wanting. Since the NinjaTrader 8 version of the OHLC ChartStyle uses SharpDX, you would need to use SharpDX when modifying the OHLC ChartStyle in NinjaTrader 8.

          You would also likely need to use SharpDX in NinjaTrader 8 when converting the script from NinjaTrader 7 to NinjaTrader 8.

          Note that to contact a specific forum user, you could click on the 'Messages' drop-down menu in the top right of the forum page and select 'Send new message'. Then input the username of the person you are wanting to contact.

          Let us know if we may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            I'd love to see a section for user shared chart styles!

            Comment


              #7
              Thanks a lot Brandon for the "messages" info. I've sent one to the OP.

              Just an aside question. I haven't very good eyes anymore and I've been wondering for a long time if there is a way to paste code with intact format into Ninjatrader Forum. I've tried several ways but it always displays the code without the easily readable formatting. For short snippets it's somewhat ok to get the code tabulated by hand but not for longer code. How do you get it to paste with preserved formatting? Thanks

              Added note: I'm aware of beautifier tools, but for some reason I usually get the code adulterated with them and then get compile errors in the NinjaScript Editor.
              Last edited by PaulMohn; 02-07-2022, 12:33 PM. Reason: Beautifiers note

              Comment


                #8
                Originally posted by PaulMohn View Post
                Thanks a lot Brandon for the "messages" info. I've sent one to the OP.

                Just an aside question. I haven't very good eyes anymore and I've been wondering for a long time if there is a way to paste code with intact format into Ninjatrader Forum. I've tried several ways but it always displays the code without the easily readable formatting. For short snippets it's somewhat ok to get the code tabulated by hand but not for longer code. How do you get it to paste with preserved formatting? Thanks
                Brilliant idea!

                Comment


                  #9
                  Hello PaulMohn,

                  Thanks for your note.

                  Unfortunately, there are no options available that preserve the formatting of code when copy/pasting code into the NinjaScript Editor window. The code's format would need to be manually modified after pasting.

                  We are currently tracking interest in this feature and your vote has been added. The internal tracking number for your feature request is SFT-3502. Please reference this internal tracking number when contacting Platform Support if you ever have questions regarding this feature request.

                  When a feature request is implemented, you'll find a description of the new feature in the release notes:
                  Let us know if we may further assist.
                  Brandon H.NinjaTrader Customer Service

                  Comment


                    #10
                    Ok thanks Brandon for the answer. I think it would be great to use an other code pasting online app which preserves the formatting, or request pasters to share txts or .cs file as attachment (to avoid the adulteration of code problem).

                    samsonli, here are the User App Share currently returned ChartStyle when searching "ChartStyle" (but others as the one from post one above are missing)


                    it would be helpful to gather all shared ChartStyles under a common section, to first see what has already been done and not recode it if not necessary.

                    Comment


                      #11
                      Hello Brandon,

                      Do you have some commented/annotated versions of the NT8 built in OhlcStyle and the CandleStyle ChartStyle scripts?

                      I've found some helpful (with examples) doc about

                      PaintBars (NT7 to NT8 Conversion)
                      https://ninjatrader.com/support/foru...212#post678212


                      rectangle F
                      https://docs.microsoft.com/en-us/dot...system-single)

                      ?? and ??= operators (C# reference)
                      https://docs.microsoft.com/en-us/dot...scing-operator

                      C# Ternary Operator (?: ) with Example
                      https://www.tutlane.com/tutorial/csh...-with-examples

                      But there are still many things difficult to follow. I can't find examples and info related to the ChartStyle codes in the SharpDX doc and there's no commenting in the ChartStyle Scripts.

                      Using SharpDX for Custom Chart Rendering
                      https://ninjatrader.com/support/help..._rendering.htm
                      Last edited by PaulMohn; 02-08-2022, 09:51 AM.

                      Comment


                        #12
                        Hello PaulMohn,

                        Thanks for your note.

                        You could view the OhlcStyle ChartStyle and the CandleStyle ChartStyle that comes default with NinjaTrader in a New > NinjaScript Editor window.

                        To do so, open a New > NinjaScript Editor window, open the ChartStyle folder, and select the ChartStyle script you would like to view the code for.

                        Note that we do not have any other examples available for OhlcStyle or CandleStyle ChartStyles.

                        If you would like to modify one of those ChartStyle scripts then you could make a copy of the script. You could open the script you want to modify in the NinjaScript Editor window, right-click in the script, and select 'Save As' to make a copy of the script. Then that copy could be modified.

                        For more information about working with SharpDX, please see the SampleCustomRender indicator script that comes default with NinjaTrader. This script contains comments regarding using SharpDX in a custom NinjaScript.

                        Let us know if we may assist further.
                        Last edited by NinjaTrader_BrandonH; 02-08-2022, 10:41 AM.
                        Brandon H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Jimmyk, 01-26-2018, 05:19 AM
                        6 responses
                        834 views
                        0 likes
                        Last Post emuns
                        by emuns
                         
                        Started by jxs_xrj, 01-12-2020, 09:49 AM
                        6 responses
                        3,290 views
                        1 like
                        Last Post jgualdronc  
                        Started by Touch-Ups, Today, 10:36 AM
                        0 responses
                        9 views
                        0 likes
                        Last Post Touch-Ups  
                        Started by geddyisodin, 04-25-2024, 05:20 AM
                        11 responses
                        62 views
                        0 likes
                        Last Post halgo_boulder  
                        Started by Option Whisperer, Today, 09:55 AM
                        0 responses
                        8 views
                        0 likes
                        Last Post Option Whisperer  
                        Working...
                        X