• 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

automated TrendChannel Indicator. Cant find the paramteters for the second low,

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

    automated TrendChannel Indicator. Cant find the paramteters for the second low,

    Dear NinjaSupport,



    I'm trying to build my own indicator on NT 8. It should be an automated TrendChannel Indicator. Ufortunatly I can't continiue because I don't find the parameters of the second low of a period.

    Im at the beginnig of ninjascript and still a newbie at programming.



    I tried this code for the second low MIN(Low, 75)[0] but it doesn't work on the Draw.Trendchannel method.
    This doesn't show anything.


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




    This works but only for the Currentbar

    This work but only for the Currentbar.

    But I need 1 Anchor First Low of the period and the 2 Anchor the second lowest Low of the period.

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


    It should be looking like the white line.





    Best regards

    Stef
    Last edited by TradeMyth; 03-20-2019, 01:53 PM.

    #2
    Hello Stef,

    Welcome to the NinjaTrader forums!

    A trend channel will have 2 parallel lines of the same length and 3 anchor points. The first two anchor points are for the first line which set the length and angle of the line. The third anchor point sets where the originating point of the second line will come from, but from there will have the same length and angle of the first line.

    Are you trying to calculate the price of the anchor of the starting point of the second line?
    Draw.TrendChannel(NinjaScriptBase owner, string tag, bool isAutoScale, int anchor1BarsAgo, double anchor1Y, int anchor2BarsAgo, double anchor2Y, int anchor3BarsAgo, doubleanchor3Y)

    The lowest low between the bars you have highlighted appears to be the first red bar after the first anchor. The second lowest low appears to be the green bar right after it (second bar after the first anchor).
    Are you wanting to find the low of the green bar right after the first red bar? (This would be the second lowest low)

    Are you wanting some logic that is looking for a specific number of consecutive green bars, then a certain number of consecutive red bars and then on the first green bar after that finding the low?


    Below is a public link to the Draw.TrendChannel() page in the help guide.
    https://ninjatrader.com/support/help...endchannel.htm
    Last edited by NinjaTrader_ChelseaB; 03-20-2019, 02:47 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Stef,

      A trend channel will have 2 parallel lines of the same length and 3 anchor points. The first two anchor points are for the first line which set the length and angle of the line. The third anchor point sets where the originating point of the second line will come from, but from there will have the same length and angle of the first line.

      Are you trying to calculate the price of the anchor of the starting point of the second line?
      Draw.TrendChannel(NinjaScriptBase owner, string tag, bool isAutoScale, int anchor1BarsAgo, double anchor1Y, int anchor2BarsAgo, double anchor2Y, int anchor3BarsAgo, doubleanchor3Y)

      The lowest low between the bars you have highlighted appears to be the first red bar after the first anchor. The second lowest low appears to be the green bar right after it (second bar after the first anchor).
      Are you wanting to find the low of the green bar right after the first red bar? (This would be the second lowest low)

      Are you wanting some logic that is looking for a specific number of consecutive green bars, then a certain number of consecutive red bars and then on the first green bar after that finding the low?


      Below is a public link to the Draw.TrendChannel() page in the help guide.
      https://ninjatrader.com/support/help...endchannel.htm
      Hello ChelseaB,

      Thank you for the fast reply!



      The logic for one low should be 2 green Bars.
      You can pay no attention at first at the second linie. It should be on the High. But you can ignore that

      The first picture was false the logic for one low should be 2 green bars.
      It should look like the new picture.


      Attached Files

      Comment


        #4
        Hello Stef,

        What is the exact logic.

        You are saying after the first anchor of the drawing object, you are looking for two consecutive green bars and then the first red bar?

        That would be the 7th bar that appears after the first anchor of the drawing object.

        The first bar after the first anchor is a red bar. This is followed by 4 green bars. Then there is bar where the open and close are equal. Then there is a red bar.

        I am not able to understand the logic you are wanting from what you are drawing in the screenshot.

        Try and write the logic into plain english words.

        As an example:
        After 2 or more consecutive bars look for any number of red bars and on the first green bar after any consecutive number of red bars, check the low of the previous red bar..
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Stef,

          What is the exact logic.

          You are saying after the first anchor of the drawing object, you are looking for two consecutive green bars and then the first red bar?

          That would be the 7th bar that appears after the first anchor of the drawing object.

          The first bar after the first anchor is a red bar. This is followed by 4 green bars. Then there is bar where the open and close are equal. Then there is a red bar.

          I am not able to understand the logic you are wanting from what you are drawing in the screenshot.

          Try and write the logic into plain english words.

          As an example:
          After 2 or more consecutive bars look for any number of red bars and on the first green bar after any consecutive number of red bars, check the low of the previous red bar..


          Hello ChelseaB,

          Thank you for the fast reply!




          sorry for my indistinct explanation

          I have adjusted my parameters from before. These parameters fit now.


          A movement should be 16 ticks or more than 16 ticks, both up and down
          As an example,
          I have added a picture.
          I added the ZigZag indicator on the chart you can see the movement of 16 ticks drawn in.
          The channel should look like the red drawn channel in the picture.


          The movement: One movement is 16 Ticks up or down.

          Period: The period should be 240 candles.

          anchor1Y: The first anchor point should be the last low

          Anchor2Y:The second anchor point should be the penultimate low.

          Anchor3Y:The third anchor point is the high within the 2 lows (Anchor1Y and Anchor2Y) .



          How can I code it that way. I would like to try it myself. Of course, if you can help me, it would be great!

          Comment


            #6
            Hello TradeMyth,

            You will need to be more specific with the logic you are wanting to write.

            Previously, we were trying to decide on the logic for determining the 3rd anchor for the TrendChannel drawing tool.

            Are you still asking about the TrendChannel drawing tool?

            To confirm, starting 240 bars ago, after the price rises 16 ticks a trigger would be set, then the price must fall 16 ticks, and on this bar where the price falls 16 ticks you would like to put the 3rd anchor for the TrendChannel, is this correct?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7

              Hey ChelseaB,

              Are you still asking about the TrendChannel drawing tool?

              No it's not about the TrendChannel drawing tool it's about coding an automated indicator which shows a Trendchannel on the chart.


              To confirm, starting 240 bars ago, after the price rises 16 ticks a trigger would be set, then the price must fall 16 ticks, and on this bar where the price falls 16 ticks you would like to put the 3rd anchor for the TrendChannel, is this correct?

              Yes, exactly as you wrote. The 3rd anchor ist just the second line.

              Comment


                #8
                Hello TradeMyth,

                Thank you for confirming you are still deciding on the logic for determining the 3rd anchor for the TrendChannel drawing tool.

                You can use a for loop to loop through the last 240 bars.
                The index will be the barsAgo value.

                Below is a link to a 3rd party educational site on for loops.
                https://www.dotnetperls.com/for

                In your loop, I would recommend you start the index at 240 and then decrement to 0.

                Use a bool as the trigger that is set to false outside of the loop.

                In the first condition, once there is a bar where the high is equal to or greater than the trigger price (the open of 240 bars ago plus 16 ticks), set the bool to true to know the first trigger has been set. In another condition within the loop require the bool to be true and for the low of a bar to be equal to or less than the open of 240 bars ago. When true, save the bars ago value to an int variable as this will be the bars ago number for where you are wanting the action.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello TradeMyth,

                  Thank you for confirming you are still deciding on the logic for determining the 3rd anchor for the TrendChannel drawing tool.

                  You can use a for loop to loop through the last 240 bars.
                  The index will be the barsAgo value.

                  Below is a link to a 3rd party educational site on for loops.
                  https://www.dotnetperls.com/for

                  In your loop, I would recommend you start the index at 240 and then decrement to 0.

                  Use a bool as the trigger that is set to false outside of the loop.

                  In the first condition, once there is a bar where the high is equal to or greater than the trigger price (the open of 240 bars ago plus 16 ticks), set the bool to true to know the first trigger has been set. In another condition within the loop require the bool to be true and for the low of a bar to be equal to or less than the open of 240 bars ago. When true, save the bars ago value to an int variable as this will be the bars ago number for where you are wanting the action.
                  Hello ChelseaB,

                  Thanks for the fast reply.

                  I'll try it with the loop.

                  Best regards
                  Stef

                  Comment


                    #10
                    Hello chelseaB,


                    I can not even determine the 1 anchor point. I can find out the low of my entered period. But it is not the period i need for my 1anchor.
                    How do I determine the lowest bar or the period of a 16 tick move?
                    how i can define a 16 Tick move into a code ?
                    on the picture the Orange Dot shows the Low of the 450 period.
                    Hope you understand what i mean



                    That's my current code
                    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


                    #region Using declarations
                    using System;
                    using System.Collections.Generic;
                    using System.ComponentModel;
                    using System.ComponentModel.DataAnnotations;
                    using System.Linq;
                    using System.Text;
                    using System.Threading.Tasks;
                    using System.Windows;
                    using System.Windows.Input;
                    using System.Windows.Media;
                    using System.Xml.Serialization;
                    using NinjaTrader.Cbi;
                    using NinjaTrader.Gui;
                    using NinjaTrader.Gui.Chart;
                    using NinjaTrader.Gui.SuperDom;
                    using NinjaTrader.Gui.Tools;
                    using NinjaTrader.Data;
                    using NinjaTrader.NinjaScript;
                    using NinjaTrader.Core.FloatingPoint;
                    using NinjaTrader.NinjaScript.DrawingTools;
                    #endregion

                    //This namespace holds Indicators in this folder and is required. Do not change it.
                    namespace NinjaTrader.NinjaScript.Indicators
                    {
                    public class TestKanal : Indicator
                    {

                    private Series<double> fLowSerie;



                    private double fLow;


                    protected override void OnStateChange()
                    {
                    if (State == State.SetDefaults)
                    {
                    Description = @"";
                    Name = "TestKanal";
                    Calculate = Calculate.OnBarClose;
                    IsOverlay = true;
                    DisplayInDataBox = true;
                    DrawOnPricePanel = true;
                    DrawHorizontalGridLines = true;
                    DrawVerticalGridLines = true;
                    PaintPriceMarkers = true;
                    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive = true;
                    Perioden = 450;

                    AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Dot, "Dot");
                    }
                    else if (State == State.Configure)
                    {
                    fLow = 0;

                    }
                    else if (State == State.DataLoaded)
                    {
                    fLowSerie = new Series<double>(this);
                    }



                    }

                    protected override void OnBarUpdate()
                    {
                    if (CurrentBar < Perioden) return;



                    for (int i = Perioden; i > 1 ; i--)
                    {

                    fLow = MIN(Low, Perioden)[i];


                    }


                    fLowSerie[0] = fLow;
                    Value[0] = fLowSerie[0];



                    }


                    #region Properties

                    //

                    [NinjaScriptProperty]
                    [Range(1, int.MaxValue)]
                    [Display(Name="Perioden", Description="Anzahl der Perioden", Order=1, GroupName= "Parameter")]
                    public int Perioden
                    { get; set; }



                    //

                    [Browsable(false)]
                    [XmlIgnore()]
                    public Series<double> indicatorValues
                    {
                    get
                    {
                    Update();
                    return Values[0];
                    }
                    }

                    #endregion




                    }
                    }

                    #region NinjaScript generated code. Neither change nor remove.

                    namespace NinjaTrader.NinjaScript.Indicators
                    {
                    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                    {
                    private TestKanal[] cacheTestKanal;
                    public TestKanal TestKanal()
                    {
                    return TestKanal(Input);
                    }

                    public TestKanal TestKanal(ISeries<double> input)
                    {
                    if (cacheTestKanal != null)
                    for (int idx = 0; idx < cacheTestKanal.Length; idx++)
                    if (cacheTestKanal[idx] != null && cacheTestKanal[idx].EqualsInput(input))
                    return cacheTestKanal[idx];
                    return CacheIndicator<TestKanal>(new TestKanal(), input, ref cacheTestKanal);
                    }
                    }
                    }

                    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                    {
                    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                    {
                    public Indicators.TestKanal TestKanal()
                    {
                    return indicator.TestKanal(Input);
                    }

                    public Indicators.TestKanal TestKanal(ISeries<double> input )
                    {
                    return indicator.TestKanal(input);
                    }
                    }
                    }

                    namespace NinjaTrader.NinjaScript.Strategies
                    {
                    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                    {
                    public Indicators.TestKanal TestKanal()
                    {
                    return indicator.TestKanal(Input);
                    }

                    public Indicators.TestKanal TestKanal(ISeries<double> input )
                    {
                    return indicator.TestKanal(input);
                    }
                    }
                    }

                    #endregion

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

                    Comment


                      #11
                      Hello TradeMyth,

                      Chelsea is out of the office today, but will get back to you as soon as he returns.

                      Thanks for your patience.
                      Josh G.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello TradeMyth,

                        As we have received an email from you at platformsupport [at] ninjatrader [dot] com, we continue the conversation privately through email.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hey Chelsea,

                          thank you for the help last time.

                          I am currently trying to draw a line with the values of then ZigZag indicator. I use the code of the ZigZag indicator. In the region Miscellaneous you can find the code that I show in the pictures. I have displayed the values in the output window.
                          I want to draw a line with the first value and the third value. After that I want to copy the line and put it on the second value, this creates a channel. The values are already given, but I can not isolate them and draw two Lines. I have inserted pictures for better understanding. How can I code it so that I can filter out the values and finally connect them with a line.

                          Have a great weekend!



                          Attached Files

                          Comment


                            #14
                            Hello TradeMyth,

                            Do you have two bar numbers and two price values you would like to draw the line between?

                            Below is a link to the ZigZag in the help guide.
                            https://ninjatrader.com/support/help...-us/zigzag.htm
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by usero86, Today, 04:28 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post usero86
                              by usero86
                               
                              Started by bohenriksen, Today, 04:00 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post bohenriksen  
                              Started by Derjan, Today, 03:09 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post Derjan
                              by Derjan
                               
                              Started by exutmlay, Today, 02:38 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post exutmlay  
                              Started by CDXTrader, Today, 12:29 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post CDXTrader  
                              Working...
                              X