Thanks for the welcome and sorry, I did not know about the external links not allowed.
I need somebody to tell me what basically such indicator "is" in order to re-create it in my platform.
Below are the codes of Fx Sniper's Ergodic CCI Trigger for MT4 and Amibroker.
Code: Select all
//+------------------------------------------------------------------+
//| Louw Coetzer aka FX Sniper |
//| Copyright © 2004, MetaQuotes Software Corp. |
//|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Fx Sniper."
#property link
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
// Ergo Variables
extern int pq =2;
extern int pr = 10;
extern int ps = 5;
extern int trigger =3;
//---- indicator buffers
string signal;
double mtm[];
double absmtm[];
double ErgoCCI[];
double MainCCI[];
double var1[];
double var2[];
double var2a[];
double var2b[];
//double valor1[];
//double valor2[];
//double extvar[];
//double cciSignal[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(8);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,Blue);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Red);
SetIndexBuffer(0,ErgoCCI);
SetIndexLabel(0,"Egodic CCI");
SetIndexBuffer(1,MainCCI);
SetIndexLabel(1,"Trigger Line");
SetIndexBuffer(2,mtm);
SetIndexBuffer(3,var1);
SetIndexBuffer(4,var2);
SetIndexBuffer(5,absmtm);
SetIndexBuffer(6,var2a);
SetIndexBuffer(7,var2b);
//---- name for DataWindow and indicator subwindow label
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Calculations |
//+------------------------------------------------------------------+
int start()
{
int limit;
int i;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
//---- done
for(i=0; i <= Bars; i++)
{
mtm[i]= Close[i]- Close[i +1];
}
for(i=0; i <= Bars-1; i++)
{
absmtm[i] = MathAbs(mtm[i]);
}
for(i=0; i <= Bars-1; i++)
{
var1[i]= iMAOnArray(mtm,0,pq,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
var2[i]= iMAOnArray(var1,Bars,pr,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
var2a[i]= iMAOnArray(absmtm,0,pq,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
var2b[i]= iMAOnArray(var2a,0,pr,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
ErgoCCI[i] = (500 * iMAOnArray(var2,0,ps,0,MODE_EMA,i))/(iMAOnArray(var2b,0,ps,0,MODE_EMA,i)); //var2a[i]/var2b[i];
}
for(i=0; i<=Bars; i++)
{
MainCCI[i]=iMAOnArray(ErgoCCI,0,trigger,0,MODE_EMA,i);
}
for(i=0; i<=Bars; i++)
{
if(MainCCI[i] > ErgoCCI[i])
{signal = "SHORT";}
if (MainCCI[i] < ErgoCCI[i])
{signal = "LONG";}
if (MainCCI[i] == ErgoCCI[i])
{signal = "NEUTRAL";}
IndicatorShortName("FX Sniper's Ergodic CCI & Trigger: "+signal);
return(0); }
}
=====================================================================
Code for AMIBROKER:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// ErgoCCI
/// </summary>
[Description("ErgoCCI")]
public class ErgoCCI : Indicator
{
#region Variables
private int pq =2;
private int pr = 10;
private int ps = 5;
private int trigger =3;
private DataSeries mtm;
private DataSeries var1;
private DataSeries var2;
private DataSeries mtmAbs;
private DataSeries var2a;
private DataSeries var2b;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "MainCCI"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "ErgCCI"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
mtm = new DataSeries(this);
var1 = new DataSeries(this);
var2 = new DataSeries(this);
mtmAbs = new DataSeries(this);
var2a = new DataSeries(this);
var2b = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(CurrentBar<1) return;
mtm.Set (Close[0]-Close[1]);
var1.Set(EMA(mtm, pq)[0]);
var2.Set(EMA(var1, pr)[0]);
mtmAbs.Set(Math.Abs(Close[0]-Close[1]));
var2a.Set(EMA(mtmAbs,pq)[0]);
var2b.Set(EMA(var2a,pr)[0]);
ErgCCI.Set(500* (EMA(var2,ps)[0])/(EMA(var2b,ps)[0]));
MainCCI.Set(EMA(ErgCCI,trigger)[0]);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries MainCCI
{
get { return Values[0]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries ErgCCI
{
get { return Values[1]; }
}
[Description("EMA period")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
[Category("Parameters")]
public int PQ
{
get { return pq; }
set { pq = Math.Max(1, value); }
}
[Description("EMA period")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
[Category("Parameters")]
public int PR
{
get { return pr; }
set { pr = Math.Max(1, value); }
}
[Description("EMA period")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
[Category("Parameters")]
public int PS
{
get { return ps; }
set { ps = Math.Max(1, value); }
}
[Description("EMA period")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
[Category("Parameters")]
public int Trigger
{
get { return trigger; }
set { trigger = Math.Max(1, value); }
}
#endregion
}
}
#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
public partial class Indicator : IndicatorBase
{
private ErgoCCI[] cacheErgoCCI = null;
private static ErgoCCI checkErgoCCI = new ErgoCCI();
/// <summary>
/// ErgoCCI
/// </summary>
/// <returns></returns>
public ErgoCCI ErgoCCI(int pQ, int pR, int pS, int trigger)
{
return ErgoCCI(Input, pQ, pR, pS, trigger);
}
/// <summary>
/// ErgoCCI
/// </summary>
/// <returns></returns>
public ErgoCCI ErgoCCI(Data.IDataSeries input, int pQ, int pR, int pS, int trigger)
{
checkErgoCCI.PQ = pQ;
pQ = checkErgoCCI.PQ;
checkErgoCCI.PR = pR;
pR = checkErgoCCI.PR;
checkErgoCCI.PS = pS;
pS = checkErgoCCI.PS;
checkErgoCCI.Trigger = trigger;
trigger = checkErgoCCI.Trigger;
if (cacheErgoCCI != null)
for (int idx = 0; idx < cacheErgoCCI.Length; idx++)
if (cacheErgoCCI[idx].PQ == pQ && cacheErgoCCI[idx].PR == pR && cacheErgoCCI[idx].PS == pS && cacheErgoCCI[idx].Trigger == trigger && cacheErgoCCI[idx].EqualsInput(input))
return cacheErgoCCI[idx];
ErgoCCI indicator = new ErgoCCI();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.PQ = pQ;
indicator.PR = pR;
indicator.PS = pS;
indicator.Trigger = trigger;
indicator.SetUp();
ErgoCCI[] tmp = new ErgoCCI[cacheErgoCCI == null ? 1 : cacheErgoCCI.Length + 1];
if (cacheErgoCCI != null)
cacheErgoCCI.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheErgoCCI = tmp;
Indicators.Add(indicator);
return indicator;
}
}
}
// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
/// <summary>
/// ErgoCCI
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.ErgoCCI ErgoCCI(int pQ, int pR, int pS, int trigger)
{
return _indicator.ErgoCCI(Input, pQ, pR, pS, trigger);
}
/// <summary>
/// ErgoCCI
/// </summary>
/// <returns></returns>
public Indicator.ErgoCCI ErgoCCI(Data.IDataSeries input, int pQ, int pR, int pS, int trigger)
{
return _indicator.ErgoCCI(input, pQ, pR, pS, trigger);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// ErgoCCI
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.ErgoCCI ErgoCCI(int pQ, int pR, int pS, int trigger)
{
return _indicator.ErgoCCI(Input, pQ, pR, pS, trigger);
}
/// <summary>
/// ErgoCCI
/// </summary>
/// <returns></returns>
public Indicator.ErgoCCI ErgoCCI(Data.IDataSeries input, int pQ, int pR, int pS, int trigger)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
return _indicator.ErgoCCI(input, pQ, pR, pS, trigger);
}
}
}
#endregion