stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

TMA True Slope
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2448
Page 1 of 1
Author:  babalu4u [ Wed Jun 05, 2013 9:28 pm ]
Post subject:  TMA True Slope

Hi,

The indicator calculate TMA True Slope and SMA of TMA. You must have also Average True Range indicator instaled!
This was my first experience with C# and cAlgo and I must say that is izzy to migrate.
Author:  babalu4u [ Wed Jun 05, 2013 9:33 pm ]
Post subject:  Re: TMA Slope

And here is the code:

Code: Select all

 //#reference: AverageTrueRange.algo

    using System;
    using cAlgo.API;
    using cAlgo.API.Indicators;

    namespace cAlgo.Indicators
    {
        [Indicator(IsOverlay = false)]
        public class TMASlope_01 : Indicator
        {
          private AverageTrueRange _averageTrueRange;
          private WeightedMovingAverage _weightedMovingAverage;
          private SimpleMovingAverage _simpleMovingAverage;
          
            [Parameter(DefaultValue = 14)]
        	public int smaPeriod { get; set; }
        	
            [Output("TMA", Color = Colors.Gray, PlotType = PlotType.Histogram)]
            public IndicatorDataSeries TMA { get; set; }

            [Output("Positive TMA", Color = Colors.Green, PlotType = PlotType.Histogram)]
            public IndicatorDataSeries TMA_Up { get; set; }
            
            [Output("Negative TMA", Color = Colors.Red, PlotType = PlotType.Histogram)]
            public IndicatorDataSeries TMA_Down { get; set; }

			[Output("Sma", Color = Colors.Red)]
        	public IndicatorDataSeries Sma { get; set; }
        	
            protected override void Initialize()
            {
                _weightedMovingAverage = Indicators.WeightedMovingAverage(MarketSeries.Close, 21);
                _averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(100);
                _simpleMovingAverage = Indicators.SimpleMovingAverage(TMA, smaPeriod );
            }
           
          double calcPrevTrue( int index )
          {
             double dblSum  = MarketSeries.Close[ index - 1] * 21;
                double dblSumw = 21;
                int jnx, knx;
       
                dblSum  += MarketSeries.Close[ index ] * 20;
                dblSumw += 20;

                for ( jnx = 1, knx = 20; jnx <= 20; jnx++, knx-- )
                {
                   dblSum  += MarketSeries.Close[index - 1 - jnx ] * knx;
                   dblSumw += knx;
                }
             return ( dblSum / dblSumw );
          }


            public override void Calculate(int index)
            {
                double dblTma, dblPrev;
                double atr =_averageTrueRange.Result[index - 10] / 10;
                double gadblSlope = 0.0;

                if ( atr != 0 )
                {
                   dblTma =_weightedMovingAverage.Result[index];
                   dblPrev = calcPrevTrue( index );
                   gadblSlope = ( dblTma-dblPrev ) / atr;
                }
                
                TMA[index] = gadblSlope ;

                if( TMA[index]>0)
                {
                TMA_Up[index] = TMA[index] ;
                TMA_Down[index] = 0 ;
                }
                if(TMA[index]<0)
                {
                TMA_Down[index] = TMA[index] ;
                TMA_Up[index] = 0 ;
                }
                Sma[index] = _simpleMovingAverage.Result[ index ] ;
            }
        }
    }
Author:  excalibre30 [ Wed Apr 30, 2014 2:56 pm ]
Post subject:  TMA True Slope

What does TMA mean bro? Trying to understand this but can not find a reference to it's meaning. Is this what Nanningbob uses?
Author:  milanese [ Wed Apr 30, 2014 3:02 pm ]
Post subject:  TMA True Slope

excalibre30 » Wed Apr 30, 2014 2:56 pm wrote:What does TMA mean bro? Trying to understand this but can not find a reference to it's meaning. Is this what Nanningbob uses?
TMA=Triangular moving average

Cheers :)

Tommaso
Author:  excalibre30 [ Wed Apr 30, 2014 3:20 pm ]
Post subject:  TMA True Slope

milanese wrote:
excalibre30 » Wed Apr 30, 2014 2:56 pm wrote:What does TMA mean bro? Trying to understand this but can not find a reference to it's meaning. Is this what Nanningbob uses?
TMA=Triangular moving average

Cheers :)

Tommaso
Thanks Tommaso.

I read that it is the origin of CSS but I also read that TMA has to be used in conjuction with css. I'm confused. :(
Author:  milanese [ Wed Apr 30, 2014 3:31 pm ]
Post subject:  TMA True Slope

excalibre30 » Wed Apr 30, 2014 3:20 pm wrote:
Thanks Tommaso.

I read that it is the origin of CSS but I also read that TMA has to be used in conjuction with css. I'm confused. :(
yes this is right the TMA-Slope is base for the CSS, CSS is the TMA slope calculation using all selected pairs for the calculation, too you can look at the TMA bands, if you read the 10.7 thread http://www.stevehopwoodforex.com/phpBB3 ... =38&t=3549 and the CSS thread http://www.stevehopwoodforex.com/phpBB3 ... =38&t=3556 you will understand it better..

Cheers :)

Tommaso
Author:  SpiderX [ Wed May 21, 2014 12:24 am ]
Post subject:  TMA True Slope

milanese » Wed Apr 30, 2014 11:02 pm wrote: TMA=Triangular moving average

Cheers :)

Tommaso
Hi Tommaso

Can you point to a discussion specifically on this or maybe write an article on this ?
The forum seems to assume everyone knows about this.

Cheers
Author:  milanese [ Wed May 21, 2014 8:44 am ]
Post subject:  TMA True Slope

SpiderX » Wed May 21, 2014 12:24 am wrote:
milanese » Wed Apr 30, 2014 11:02 pm wrote: TMA=Triangular moving average

Cheers :)

Tommaso
Hi Tommaso

Can you point to a discussion specifically on this or maybe write an article on this ?
The forum seems to assume everyone knows about this.

Cheers
I will take a look if I find some time ..

Cheers :)

Tommaso
Author:  milanese [ Wed May 21, 2014 4:08 pm ]
Post subject:  TMA True Slope

milanese » Wed May 21, 2014 8:44 am wrote:
SpiderX » Wed May 21, 2014 12:24 am wrote:
milanese » Wed Apr 30, 2014 11:02 pm wrote: TMA=Triangular moving average

Cheers :)

Tommaso
Hi Tommaso

Can you point to a discussion specifically on this or maybe write an article on this ?
The forum seems to assume everyone knows about this.

Cheers
I will take a look if I find some time ..

Cheers :)

Tommaso
I added some information about the TMA to the KnowLedge base http://www.stevehopwoodforex.com/phpBB3/kb.php?a=16

Cheers :)

Tommaso
All times are UTC Page 1 of 1