Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tushar Chande's Trendscore

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

    Tushar Chande's Trendscore

    I was watching a trading lecture that mentioned this indicator and it seemed interesting.

    The code is so hopelessly simple that I'm embarrassed I've spent the last hour and still can't get it to plot. I'm obviously overlooking something very basic and was hoping someone could take a look at it.

    This is the Metastock code and I've attached the MetaTrader indicator (which I tried to convert)

    Code:
    Chande's Trendscore                                                    If(C>=Ref(C,-11),1,-1) + If(C>=Ref(C,-12),1,-1) + 
      If(C>=Ref(C,-13),1,-1) + If(C>=Ref(C,-14),1,-1) + 
      If(C>=Ref(C,-15),1,-1) + If(C>=Ref(C,-16),1,-1) +
      If(C>=Ref(C,-17),1,-1) + If(C>=Ref(C,-18),1,-1) + 
      If(C>=Ref(C,-19),1,-1) + If(C>=Ref(C,-20),1,-1)
    In MetaTrader it seems the 'meat' of it is;

    Code:
    for (score=0,k=0; k<LookBackLength; k++)
                      if (Close[i] >= Close[i+k+LookBack])
                            score++;
                      else  score--;                        
             TrendBuffer[i] = score/LookBackLength;
    Which would be something like this in NT;

    Code:
    for (score=0,k=0; k<LookBackLength; k++)
                      if (Close[0] >= Close[k+LookBack])
                            score++;
                      else  score--;                        
             TrendBuffer.Set(score/LookBackLength);


    thanks in advance.
    Attached Files

    #2
    Hey Elliott

    What are you getting on your plot? (I cant try the code until later today)

    Also, I suggest you always use brackets around statements just to keep things clean and 100% certain the logic is executing as you suspect. Additionally, keep the for statement to only "controlled" variables (so here we remove the score). This is probably not the cause of a problem, but it makes code more readable.

    Code:
    score = 0;
    for(int k = 0 ; k < LookBackLength ; k++)
    {
      if(Close[0] >= Close[k + LookBack])
         score++;
      else
         score--;
    }
    let me know
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      Elliot,

      I'm curious about this code,

      you posted :
      ------------------------------------------------------------------
      for (score=0,k=0; k<LookBackLength; k++)
      if (Close[0] >= Close[k+LookBack])
      score++;
      else score--;
      TrendBuffer.Set(score/LookBackLength);
      -----------------------------------------------------------------

      OK, my stupid question first. Is this an issue?

      if CurrentBar < (k+LookBack)
      return;

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

      Anyway, could you show us the NT code you developed so far...

      Thanks,

      RJay
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        If what rt is suggesting is the problem you should see an error in the LOG tab.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          I'll take another look today after being well rested, but I tried many different things included busting out my C# for dummies and changing the for loop to a while loop etc.

          I think part of the issue is that the MT4 indicator is multi-timeframe and has some code I don't think is needed, but perhaps is.

          I also tried doing a very inefficient string of 20 if/else statements regarding Close[0] > Close [1, 2, 3] etc, and no matter what I couldn't get anything to plot.

          Comment


            #6
            Is this what are you looking for?
            I hope I understood the logics properly...
            Looks like rt6176 was right
            Attached Files
            Last edited by roonius; 01-08-2009, 09:00 PM.

            Comment


              #7
              That looks exactly right, I'll check it out now and try to learn where I was going wrong.

              While I feel I'm improving at NinjaScript sometimes the only way to see where I was going wrong is to see it right.

              Comment


                #8
                It seems to work perfect.

                I added a description and interpretation instructions as well as a zero line and fixed the parameter spellings (length vs lenght).

                Very simple code, but it seems quite effective for what its supposed to do.
                Attached Files

                Comment


                  #9
                  Thanks,

                  Since English is not my native, I appologize in advance for future spelling mistakes.
                  Last edited by roonius; 01-08-2009, 09:00 PM.

                  Comment


                    #10
                    Since C# is not my native language I apologize in advance for any future bonehead coding mistakes. lol

                    Its good to have you here Roonuis and thanks again for contributing.

                    Comment


                      #11
                      Can anybody re-write this Indicator for NT7?

                      Comment


                        #12
                        Hi, could anyone convert the Chande Trendscore for Ninjatrader 8? thank you

                        Comment


                          #13
                          Hello cheto,

                          While we cannot convert indicators for all clients via request in the support department, we have authorized a conversion of this script.

                          Please allow sometime time, and another member of the Scripting Support team will follow up after they have completed this conversion.
                          JimNinjaTrader Customer Service

                          Comment


                            #14
                            Hello cheto,

                            For your convienince, I have attached the NT8 version of Chandes Trendscore indicator based on the NT7 version by member Elliot wave. I will also be posting both the NT7 & NT8 versions in the NT user apps for everyone.

                            Below is a screenshot of both NT7 and NT8 showing the indicator.


                            Click image for larger version

Name:	Cheto-1.PNG
Views:	204
Size:	96.4 KB
ID:	1057795

                            [ATTACH]n1057796[/ATTACH]
                            Paul H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by localappleseed, Yesterday, 03:19 PM
                            1 response
                            9 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by westofpluto, Yesterday, 03:07 PM
                            2 responses
                            21 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by localappleseed, Yesterday, 02:12 PM
                            1 response
                            13 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by MojoJojo, Yesterday, 12:21 PM
                            3 responses
                            12 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by Jschmelz, Yesterday, 11:40 AM
                            5 responses
                            26 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Working...
                            X