• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ichimoku loses color every time I open NinjaTrader

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

    Ichimoku loses color every time I open NinjaTrader

    Hello, it is an indicator that I use a lot and it is that clouds are colorless each time I close NinjaTrader and then open it. Here is your code, you can help?
    I would like to leave the green set for bullish and bearish red cloud, and these colors are those who remain colorless.


    Thanks in advance.

    -----------------------------------------------------------------------------------------------------

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Ichimoku Clouds Senkou Span
    /// </summary>
    [Description("Ichimoku Clouds Senkou Span")]
    public class IchimokuCloudsSenkouSpan : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int tenkanPeriod = 9;
    private int kijunPeriod = 26;
    private int senkouPeriod = 52;
    private int forward = 26;

    private Color senkouCloudAColor = Color.Green;
    private Color senkouCloudBColor = Color.Red;
    private int senkouCloudOpacity = 2;
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.Empty, PlotStyle.Line, "Tenkan-sen"));
    Add(new Plot(Color.Empty, PlotStyle.Line, "Kijun-sen"));
    Add(new Plot(SenkouCloudAColor, PlotStyle.Line, "Senkou Span A"));
    Add(new Plot(SenkouCloudBColor, PlotStyle.Line, "Senkou Span B"));

    Overlay = true;
    //No plot until the max of all bars are available
    BarsRequired = System.Math.Max(System.Math.Max(tenkanPeriod,kijun Period),senkouPeriod);
    Displacement = Forward;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if(CurrentBars[0] <= BarsRequired)
    return;

    //Calculate plot values
    double vTenkanSen = (MAX(High,TenkanPeriod)[0] + MIN(Low,TenkanPeriod)[0])/2;
    double vKijunSen = (MAX(High,KijunPeriod)[0] + MIN(Low,KijunPeriod)[0])/2;
    double vSenkouSpanA = (vTenkanSen + vKijunSen)/2;
    double vSenkouSpanB = (MAX(High,SenkouPeriod)[0] + MIN(Low,SenkouPeriod)[0])/2;

    //Update plot values
    TenkanSen.Set(vTenkanSen);
    KijunSen.Set(vKijunSen);
    SenkouSpanA.Set(vSenkouSpanA);
    SenkouSpanB.Set(vSenkouSpanB);

    //Draw the clouds
    if(vSenkouSpanA > vSenkouSpanB)
    {
    DrawRegion(CurrentBar+"", -Forward-1, -Forward, SenkouSpanA, SenkouSpanB, Color.Empty, SenkouCloudAColor, SenkouCloudOpacity);
    }
    else
    {
    DrawRegion(CurrentBar+"", -Forward-1, -Forward, SenkouSpanA, SenkouSpanB, Color.Empty, SenkouCloudBColor, SenkouCloudOpacity);
    }
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries TenkanSen
    {
    get { return Values[0]; }
    }

    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries KijunSen
    {
    get { return Values[1]; }
    }

    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries SenkouSpanA
    {
    get { return Values[2]; }
    }

    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries SenkouSpanB
    {
    get { return Values[3]; }
    }

    [Description("Tenkan/Conversion Line Period")]
    [GridCategory("Parameters")]
    public int TenkanPeriod
    {
    get { return tenkanPeriod; }
    set { tenkanPeriod = Math.Max(1, value); }
    }

    [Description("Kijun/Base Line Period")]
    [GridCategory("Parameters")]
    public int KijunPeriod
    {
    get { return kijunPeriod; }
    set { kijunPeriod = Math.Max(1, value); }
    }

    [Description("Senkou/Leading Span Period")]
    [GridCategory("Parameters")]
    public int SenkouPeriod
    {
    get { return senkouPeriod; }
    set { senkouPeriod = Math.Max(1, value); }
    }

    [Description("Senkou Cloud Color when Span A is higher")]
    [GridCategory("Parameters")]
    public Color SenkouCloudAColor
    {
    get { return senkouCloudAColor; }
    set { senkouCloudAColor = value; }
    }

    [Description("Senkou Cloud Color when Span B is higher")]
    [GridCategory("Parameters")]
    public Color SenkouCloudBColor
    {
    get { return senkouCloudBColor; }
    set { senkouCloudBColor = value; }
    }

    [Description("Senkou Cloud Opacity")]
    [GridCategory("Parameters")]
    public int SenkouCloudOpacity
    {
    get { return senkouCloudOpacity; }
    set { senkouCloudOpacity = Math.Max(0, value); }
    }

    [Description("Senkou Cloud Opacity")]
    [GridCategory("Parameters")]
    public int Forward
    {
    get { return forward; }
    set { forward = Math.Max(0, value); Displacement = value;}
    }
    #endregion

    #2
    Hello punkiy2111,

    For future reference, to export a NinjaTrader 7 NinjaScript to share the code do the following:
    1. Click File -> Utilities -> Export NinjaScript
    2. Enter a unique name for the file in the value for 'File name:'
    3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
    4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message

    By default your exported file will be in the following location:
    • (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript\<export_file_name.z ip>


    Below is a link to the help guide on Exporting NinjaScripts.
    http://www.ninjatrader.com/support/h...nt7/export.htm


    I have added the code you have posted to an indicator, which I am attaching to this post.
    I am finding that the regions are being drawn on chart in historical data (meaning they appear when the indicator is first added to the chart). Is there something other than these regions that should be appearing?
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello, I'm still having problems restarting the NinjaTrader. Colors disappear. Maybe it's something related to "Empty" that perhaps do nothing. What I like is that quedase seimpre fixed colors for the cloud, ie green for bullish and bearish red cloud.

      Thank you.

      Comment


        #4
        Hello punkiy2111,

        Are you using the script I have posted?

        Are the green and red regions not being colored?

        If so, I'd like to schedule a call to assist. Please send an email to platformsupport [at] ninjatrader.com. In the email, please include a link to this forum thread.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello punkiy2111,

          Are you using the script I have posted?

          Are the green and red regions not being colored?

          If so, I'd like to schedule a call to assist. Please send an email to platformsupport [at] ninjatrader.com. In the email, please include a link to this forum thread.
          Yes, I've used and still malfunctioning, lost colors. I just sent an email with the complete file.

          Thank you.

          Comment


            #6
            Hi punkiy2111,

            I think I found the issue.
            The color inputs are not serialized.
            This means they can't be saved in the workspace so they come up blank.

            How to serialize color inputs.
            http://ninjatrader.com/support/forum...5038#post25038

            This used to cause an error that I would look for. Not sure why there is no error appearing.

            Serializing this corrects the behavior on my end after a restart. (Or when applying from a template)
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Perfect!!!

              thanks great team.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Ilpropio, Yesterday, 09:45 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_EricB  
              Started by sgordet, Yesterday, 10:31 PM
              1 response
              2 views
              0 likes
              Last Post NinjaTrader_EricB  
              Started by Revan, Yesterday, 05:44 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Marco  
              Started by superg3, Yesterday, 07:57 PM
              0 responses
              4 views
              0 likes
              Last Post superg3
              by superg3
               
              Started by Longhornmark, Yesterday, 07:06 AM
              5 responses
              36 views
              0 likes
              Last Post nkhoi
              by nkhoi
               
              Working...
              X