For this I decide to start with TMA Slope indicator and than I will tray to make Robot for cTrader. Every body are welcome to help.
cTrader - Help to build TMA Slope for cTrader/cAlgo
- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
cTrader - Help to build TMA Slope for cTrader/cAlgo
I decide to start with cTrader because I think there is great potential and I don't want to use CRAP Empty4 any more. My last EA was using TMA Slope combination with SMA 2 of TMA (not finished yet). The EA was using reversal patterens of TMA (SCALPER) ....
For this I decide to start with TMA Slope indicator and than I will tray to make Robot for cTrader. Every body are welcome to help.
For this I decide to start with TMA Slope indicator and than I will tray to make Robot for cTrader. Every body are welcome to help.
- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
cTrader have Triangular Moving Average...
You do not have the required permissions to view the files attached to this post.
- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
Ok this is my first shot my first C#.... for this dont smile to me instead help me...
normaly don't work
normaly don't work
Code: Select all
// -------------------------------------------------------------------------------
//
// This is a Template used as a guideline to build your own Robot.
// Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false)]
public class TMASlope : Indicator
{
private AverageTrueRange _averageTrueRange;
private TriangularMovingAverage _triangularMovingAverage;
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Output("Main", Color = Colors.Turquoise, PlotType = PlotType.Histogram)]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
_triangularMovingAverage = Indicators.TriangularMovingAverage(MarketSeries.Close, 21);
_averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(100);
}
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 = _triangularMovingAverage.Result[index];
dblPrev = calcPrevTrue( index );
gadblSlope = ( dblTma - dblPrev ) / atr;
}
Result[index] = gadblSlope ;
}
}
}- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
Second atempt - no errors but don't work...
Code: Select all
//#reference: C:\Users\ToTo\Documents\cAlgo\Sources\Indicators\AverageTrueRange.algo
// -------------------------------------------------------------------------------
//
// This is a Template used as a guideline to build your own Robot.
// Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false)]
public class TMASlope : Indicator
{
private AverageTrueRange _averageTrueRange;
private TriangularMovingAverage _triangularMovingAverage;
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Output("Main", Color = Colors.Turquoise, PlotType = PlotType.Histogram)]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
_triangularMovingAverage = Indicators.TriangularMovingAverage(MarketSeries.Close, 21);
_averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(100);
}
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 = _triangularMovingAverage.Result[index];
dblPrev = calcPrevTrue( index );
gadblSlope = ( dblTma - dblPrev ) / atr;
}
Result[index] = gadblSlope ;
}
}
}- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
This is the answer from spotware support on forum where is error..
In the Calculate method index is the last index of the series at the moment. Therefore any value such as:
MarketSeries.Close[index + 1 + jnx ]
does not exist yet.
You want to calculate backwards by subtracting from the last index instead of adding.
- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
If somebody can help is welcome.... 
-
scheinwerfer
- Trader
- Posts: 42
- Joined: Mon Dec 12, 2011 12:36 am
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
Hey,
First of all I'm not much of a help, especially so as I first heard of cTrader couple of days ago
But I'm very interested how you get on, a while back I tried to port the same indi to another backtesting platform and it didn't work out properly cause values were off. I couldn't trace the bug, didn't have a source at hand.
But my humble advice would be to change pluses to minuses:
First of all I'm not much of a help, especially so as I first heard of cTrader couple of days ago
But I'm very interested how you get on, a while back I tried to port the same indi to another backtesting platform and it didn't work out properly cause values were off. I couldn't trace the bug, didn't have a source at hand.
But my humble advice would be to change pluses to minuses:
Code: Select all
MarketSeries.Close[index - 1 - jnx ] - babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
I am traying now but stil have a problem...
p.s.: sorry form my EN
p.s.: sorry form my EN
-
scheinwerfer
- Trader
- Posts: 42
- Joined: Mon Dec 12, 2011 12:36 am
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
Read your code, that copy-paste work won't fly, a few dodgy parts. I remembered now problems I had, very similar to yours.
I think first of all lets try to get some values on the screen, run this one and report back what it shows.
I think first of all lets try to get some values on the screen, run this one and report back what it shows.
Code: Select all
//#reference: C:\Users\ToTo\Documents\cAlgo\Sources\Indicators\AverageTrueRange.algo
// -------------------------------------------------------------------------------
//
// This is a Template used as a guideline to build your own Robot.
// Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false)]
public class TMASlope : Indicator
{
private AverageTrueRange _averageTrueRange;
private TriangularMovingAverage _triangularMovingAverage;
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Output("Main", Color = Colors.Turquoise, PlotType = PlotType.Histogram)]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
_triangularMovingAverage = Indicators.TriangularMovingAverage(MarketSeries.Close, 21);
_averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(100);
}
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 = _triangularMovingAverage.Result[index];
dblPrev = 1; //calcPrevTrue( index );
gadblSlope = ( dblTma - dblPrev ) / atr;
}
Result[index] = gadblSlope ;
}
}
}- babalu4u
- Trader
- Posts: 173
- Joined: Fri Apr 13, 2012 6:52 pm
- Location: Slovenia - EU
Re: cTrader - Help to build TMA Slope for cTrader/cAlgo
Ok now it show histogram... looks like this
You do not have the required permissions to view the files attached to this post.