Coding help - page 791

 
AmirHossein Yk #: But it returns only 10 or -1!!

What is “it?”
          Be precise and informative about your problem.

Your OnCalcuate calculates the trend, but you do nothing with it.  You must return a bar index, not trend.