Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Same basic indicator, two different period types Problem

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

    Same basic indicator, two different period types Problem

    This issue has caused me great pains all day. It's a little past midnight and I need some help understanding something.

    Thanks in advance...

    I have a wonderful custom indicator I call (add) to a wonderful custom strategy and everything is working great. I trade from range bars.

    I decided today to use the same Long and Short trade indicator but on a tick chart to help determine the longer term trend and was going to test only trading in the direction of the long term trend. Same basic indicator, but one on a range chart and one on a tick chart.

    Everything was set up with Indicator2 to plot the long term trend. This indicator works perfectly on a 2400 tick chart. I print to the output window either: TREND IS UP or TREND IS DOWN and there are no issues. I can also run this on a 5 minute data series...On it's own chart, in isolation, there are no issues.

    When I add Indicator2 to the strategy which contains Indicator1, which is run on a 4 Range Bar data series, both indicators 1 & 2 run on the 4 Range data series. The tick chart is ignored

    What I want is to run Indicator1 on a 4 Range and Indicator2 on a 2400 Tick. I take a single value from Indicator2 and use that as a filter for Indicator1 in my strategy.

    What I don't understand is why Indicator1 hijacks Indicator2 and causes different Long and Short Trend information based off the 4 Range chart when the tick chart is still outputting the correct information.

    Allow me to give an example... The tick chart is Long and the 4 Range bar is about to turn short. In this example, if I was only trading with the long term trend, when the 4 Range chart goes Short, an order should not fire because the long term Tick Chart is still long.

    But here is what happens, when the 4 Range turns short, that is being read by the strategy as the long term trend going short, even though the tick Chart is still outputting the correct trend information. That leads me to believe the Tick Chart is not being read by the strategy

    How do I get the strategy to see the tick data output from Indicator2 when Indicator1 is reading 4 Range data. I thought passing the value of the trend from Indicator2 to the strategy would be a clean and simple process the same way I pass other data from Indicator1. So, I believe I have the coding correct, just need to use tick data for Indicator2 not range data...

    Does that make sense?

    #2
    Hello,

    Thank you for the question.

    If you are loading both indicators on the same chart they would be using the same data series from the chart.
    If in each indicator you are not adding a data series of the type you need (tick) and then referencing in your calculations the second data series this would cause what is happening.

    I would like to ask are you using the Add method to add a tick series and then using the second data series for calculations? If you can provide any examples of the code you are using that would be helpful as well.

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

    Comment


      #3
      I am glad to get some help with this . Thanks in advance!

      From: protected override void Initialize()

      Code:
                  Add(Confirmation(SetTicks)); //This is the second indicator I want to use        with Tick Chart for long term trend
                  EntriesPerDirection = 1;
                  EntryHandling = EntryHandling.AllEntries; 
                  CalculateOnBarClose = true;
                  TraceOrders = true;
                  TimeInForce = Cbi.TimeInForce.Day;
                  Add(AA07A(SetTicks,OscTicks,TrendT...... etc); // This is the primary indicator, less the long term trend added above
      I generally use a 4 or 5 Range Chart to take trades...so I switch that up depending on VIX, etc. But you see my problem exactly.... I need the Indicator called Confirmation to use a tick chart and leave AA07A to use whatever I choose, either 4 or 5, sometimes 6 Range chart.

      I am most eager to learn....and really want the option to add this piece to the puzzle. I even have a useConfirmation bool so if I don't want to use the Confirmation I do not have to.... that code looks like this:

      Code:
      // Code Starts here for LONG trades with TREND CONFIRMATION
              
                  if ( 
                      useConfirmation == true
                      && (Confirmation(SetTicks).upTrendIndicator[0]==true)
                      && orderId.Length == 0  
                      && atmStrategyId.Length == 0
      etc, etc....
      If can point me in the right direction that would be great!

      Thanks Again...

      Comment


        #4
        Hello,

        Thank you for the reply.

        I believe what is happening is that your base chart series is being used for the indicator.

        In your indicator have you added a data series like in the example located here: http://www.ninjatrader.com/support/h...s/nt7/add3.htm

        You would be using the BarsInProgress and specifically using the added data series instead of the main chart series. In order to use more than 1 timerframe you need to add additional data series and specify a bars in progress depending on what needs calculated for which data series.

        There is an example installed in your NinjaTrader you can look at it is called SampleMultiTimeFrame

        If you are already doing this please let me know.

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

        Comment


          #5
          OK. I'll browse through this tonight and report back...I am appreciative of your support and you definitely understand my problem so I figure we are half way to fixing it!

          Comment


            #6
            I looked at the example...and I see the addition of two PeriodTypes to the strategy itself....since I have two indicators I want to run independently (one on ticks and one on range), you seem to be saying I have to add code to the indicator itself...before I call it into the strategy.
            Code:
            Add (PeriodType.Range,4);  // to indicator 1
            
            
            and
            
            Add(PeriodType.Ticks, 2000); // to indicator 2
            Am I following you?

            Comment


              #7
              Hello sarasotavince,

              Thank you for your response.

              I do not believe it would be necessary to add the additional bar series here. Can you attach a screenshot of the chart when you add both indicators to the chart? I will need to see what is being reported as the input series of both indicators.

              Comment


                #8
                Since the entry Strategy is run on a 4 Range Chart, I do not add the second confirming indicator here, I run it on it's own Tick chart--that's the idea of having an independent measure of the overall Trend. If the Tick chart is long and the 4 Range agrees, based on my other criteria, I take the trade long.

                It would seem to me NT should be able to read a public bool from this second chart and use the chosen variables accordingly....What if I want to switch the Major Trend indicator from 2400 Ticks to 5 minute Bars... I should be able to change the data series and the results of the Trend passed to the strategy without having to change the hard coding of Add PeriodType.Ticks...Minutes, etc.

                Here is exactly how my workspace looks. I have the strategy running on a 4 Range Chart; the strategy calls the primary indicator and will take short and long trades according to my inputs...This combination is working well...no issues. It has been traded LIVE for 2 months without a problem. I open a second chart with 2400 Ticks, using a different indicator (by name) to plot the overall Trend. Of course this chart shows either a Short Trend or a Long Trend. What I have been doing is adjusting my strategy manually to either take ONLY long trades or ONLY short trades, which means stopping and restarting the strategy each time the Trend changes.

                I am looking for the easiest way to have the strategy only take trades in the direction of the major Trend automatically.

                Does this give you a better understanding of my situation?

                Thanks in advance for your assistance.

                Comment


                  #9
                  Hello sarasotavince,

                  Add the other indicator for trend's method to your strategy code after adding an additional series to the code (the desired tick series for example) to be used as the input for the secondary series. For example, the code below provides a look at this in it's basic form to try to illustrate the point.
                  Code:
                          protected override void Initialize()
                          {
                  			Add(PeriodType.Tick, 120);
                          }
                  
                          protected override void OnBarUpdate()
                          {
                  			if(CurrentBar <= 20)
                  				return;
                  			
                  			if(Closes[0][0] > EMA(BarsArray[0], 20)[0])
                  			{
                  				Print("The last price of the main series is greater than the EMA 20 for the main series.");
                  			}
                  			if(Closes[1][0] > EMA(BarsArray[1], 20)[0])
                  			{
                  				Print("The last price of the secondary series is greater than the EMA 20 for the secondary series.");
                  			}	
                          }
                  So we use BarsArray to dictate the input series, and Closes to call the series. For information on using multiple time frames (bar series) in your code please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm

                  Comment


                    #10
                    I'm still not there in my understanding....but maybe I am getting closer.
                    Modified Initialize as follows:
                    Code:
                    protected override void Initialize()
                    
                            {
                    		  Add(AA07A(SetTicks,OscTicks,TrendTicks,ShowRange));	//the primary time frame
                                      Add(PeriodType.Tick,2400); // add second time frame
                            }
                    Compiled, no errors.

                    Here is a line of code that worked perfectly before I added the 2nd Period (TICKS)
                    Code:
                    if (AA07A(SetTicks,OscTicks,TrendTicks,ShowRange).countForShort[0]==true)
                    {do something}
                    Now, the {do something} does not do anything -- I guess because it is not referencing the 4 Range data correctly.


                    So, please Kind Sir, how must I modify the line of code above to be sure it references the primary series which is a 4 Range Chart, onto which the strategy runs? I have tried to follow your example and I get error messages when compiling. I have tried BarsArray [0] as it is now my understanding that the "0" is the primary series (RANGE) and when I start using the TICKS data it will be BarsArray [1]. But, one step at a time. Once I get the correct sequencing for the AA07A lines, there will be lots to modify before I move to the next step. Thanks Again.

                    Comment


                      #11
                      Hello sarasotavince,

                      Thank you for your response.

                      The code would be the following:
                      Code:
                      if (AA07A(BarsArray[0], SetTicks,OscTicks,TrendTicks,ShowRange).countForShort[0]==true)

                      Comment


                        #12
                        Thought I tried that but maybe I had an "(" or ")" out of place...will follow up after some more experimentation and perhaps bring this thread to a conclusion...Happy Thanksgiving, as I thank you again.

                        Comment


                          #13
                          So, quick Question:

                          Is there a way to run the second data series (TICKS, in my example) on a second panel of the RANGE chart?

                          Comment


                            #14
                            Hello,

                            Unfortunately, no. If you wanted this you would need to create a second indicator to plot the values of the secondary bar series as the input.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by gravdigaz6, Today, 01:43 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post gravdigaz6  
                            Started by DayneSwift, Yesterday, 11:06 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post DayneSwift  
                            Started by AidanLawrence, Yesterday, 10:03 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post AidanLawrence  
                            Started by butt_toast, Yesterday, 09:47 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post butt_toast  
                            Started by GaryOz, Yesterday, 06:54 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post GaryOz
                            by GaryOz
                             
                            Working...
                            X