Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Correlation indicator in Market Analyzer

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

    Correlation indicator in Market Analyzer

    Hi,

    Is there any reason why Correlation would not work inside Market Analyzer using the Indicator reference.

    The period only accepts positive values but was -1

    But I cant track where the period is -1

    Thanks,

    Tinkerz.
    Attached Files

    #2
    Hello Tinkerz,

    Thank you for your post.

    Is this occurring when you call the Correlation from within your own custom script? Can you provide the code you are using to call this indicator and the exact message you are receiving?

    Comment


      #3
      Thanks I just simplified the script

      Comment


        #4
        Correlation and 2 data streams

        Hi,

        Can the Analyser work with 2 data feeds? I need to get 2 sets of data into my calculation.

        Index 1 is the base data and index 2 is adding an extra symbol.

        Thanks.

        Code:
            if (BarsInProgress==0)
            {
                    for (int index1 = 0; index1 < Length-1; index1++) 
                    {                    
                    Output1[index1]=Closes[0][index1];
                    }                                        
            }
            
            if (BarsInProgress==1)
            {
                    for (int index1 = 0; index1 < Length-1; index1++) 
                    {                    
                    Output2[index1]=Closes[1][index1];
                    }                                        
            }

        Comment


          #5
          Hi tinkerz,

          Yes, the Strategy Analyzer will work with multiple data series in a script as long as there is data for both instruments.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hi,

            The indicator on the chart works fine but in MA its not working, can bars in progress be used in MA? Or can it be simplified?

            Thanks

            Comment


              #7
              Hello tinkerz,

              Yes, the script should work the same in the Market Analyzer as it does on a chart as long as the settings are all the same.

              What are you finding isn't working?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                In the MA all the correlations are the same if I load 1 or more of the correlation indicators.

                And they are >100 which is wrong

                I dont think the right data is getting in my arrays using bars in progress

                Comment


                  #9
                  Hi tinkerz,

                  What are you calling in your script?

                  Are you passing the correct BarsArray to the ma indicator call?

                  For example to call the SMA with the secondary data series use:
                  SMA(BarsArray[1], 19)[0]

                  This would be the current bar value of the SMA 19 using the secondary data series as the input series.
                  http://www.ninjatrader.com/support/h.../barsarray.htm
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    I am using 'closes' and BarsInProgress to select the correct data and insert into an array, this is not working, but it is the charts.



                    Code:
                        if (BarsInProgress==0)
                        {
                                for (int index1 = 0; index1 < Length-1; index1++) 
                                {                    
                                Output1[index1]=Closes[0][index1];
                                }                                        
                        }
                        
                        if (BarsInProgress==1)
                        {
                                for (int index1 = 0; index1 < Length-1; index1++) 
                                {                    
                                Output2[index1]=Closes[1][index1];
                                }                                        
                        }

                    Comment


                      #11
                      Hi tinkerz,

                      I saw that MA and immediately started thinking moving average.

                      Sorry about that....

                      If you print these values to the Output window (directly without using the arrays) are the values the same or not printing?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        I have changed the script to print, and it does not print, it does print in the charts.

                        It seems its to do with currentbar, when I take it out it prints but errors because of the look back

                        if (CurrentBar <= Length)
                        return;


                        if (BarsInProgress==0)
                        {
                        for (int index1 = 0; index1 < Length-1; index1++)
                        {
                        Output1[index1]=Closes[0][index1];
                        Print(Output1[index1]+"A");
                        }
                        }

                        if (BarsInProgress==1)
                        {
                        for (int index1 = 0; index1 < Length-1; index1++)
                        {
                        Output2[index1]=Closes[1][index1];
                        Print(Output1[index1]+"B");
                        }
                        }

                        Comment


                          #13
                          Hi tinkerz,

                          Ah, I see, this may be because of the MaximumBarsLookBack. Try setting this to infinite.

                          (I am not seeing the value of Length in your code so I am not able to see how far back you are calling the Closes. Had I seen that you are looping through every bar (or more than 256 bars) then I would have suggested this.)
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Just 100 on the lookback, where do I set maximumbarslookback?

                            Comment


                              #15
                              Hi tinkerz,

                              Originally posted by tinkerz View Post
                              Just 100 on the lookback, where do I set maximumbarslookback?
                              Does this mean that Length is set to 100? (If so, this may not be the issue)

                              I would recommend that if you have multiple data series, you check that all data series have enough bars instead of just one.


                              if (CurrentBars[0] <= Length || CurrentBars[1] <= Length)
                              return;


                              But this also may not be the issue....

                              To try setting MaximumBarsLookBack to Infinite:
                              • Right-click the Market Analyzer -> select Columns...
                              • Select the Indicator column in question from the active columns below
                              • On the right set 'Maximum bars look back' to Infinite



                              Let me know if that does not work.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by llanqui, Today, 10:32 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              45 responses
                              3,992 views
                              3 likes
                              Last Post johntraderuser2  
                              Started by TAJTrades, Today, 09:46 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post TAJTrades  
                              Started by rhyminkevin, Yesterday, 04:58 PM
                              5 responses
                              62 views
                              0 likes
                              Last Post dp8282
                              by dp8282
                               
                              Started by realblubb, Today, 09:28 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post realblubb  
                              Working...
                              X