This code is for MQL4, Can anybody write AFL of this
code.
/+----------------------------------------------------------+
//|
Synergy Signals [v2].mq4 |
//| SwingMan |
//| Sources: Traders Dynamic
Index, HeikenAshi_DM
|
//+----------------------------------------------------------+
#property
copyright "SwingMan"
#property link ""
//----
#property
indicator_chart_window
#property indicator_buffers 7
//----
colors
#property indicator_color1 Green // long/short Signals
#property
indicator_color2 Red
#property indicator_color3 IndianRed //
StopLoss
#property indicator_color4 LimeGreen
#property indicator_color5
Yellow
#property indicator_color6 Yellow
#property indicator_color7
Green
//---- extern parameters
extern int
PriceChannel_Period=5;
extern int RSI_Period=13; //8-25
extern int
RSISmooth_Period=2;
extern int RSIVolatilityBand_Period=34;
//20-40
extern int RSITradeSignal_Period=7;
extern int
TrendIndicator_Period=55;
extern int RSI_Price=0; //0-6
extern int
RSI_MavgMODE=0; //0-3
extern int RSITradeSignal_MavgMODE=0;
//0-3
extern double Factor_ShortBars=0.50;
extern int
SignalOffset=5;
//---- arrays Traders Dynamic Index
double
RSIBuf[10000],UpZone[10000],BaseLine[10000],DnZone[10000];
double
RSILine[10000],RedLine[10000];
//---- arrays HeikinAshi
Candles
double haBuffer_Low[10000];
double
haBuffer_High[10000];
double haBuffer_Open[10000];
double
haBuffer_Close[10000];
//---- MovingAverages / PriceActionChannel /
PAC
double mavHighs[];
double mavLows[];
double mavTrend[];
//----
signals
double LongSignal[];
double ShortSignal[];
double
StopLong[];
double StopShort[];
//---- variables
string sName="Synergy
Signals [v2]";
double dSignalOffset,
Spread;
//+----------------------------------------------------------+
//|
Custom indicator initialization function
|
//+----------------------------------------------------------+
int
init()
{
IndicatorShortName(sName);
Comment(sName);
dSignalOffset=SignalOffset*Point;
Spread=MarketInfo(Symbol(),
MODE_SPREAD) * Point;
//---- Set Arrays
----------------------------------------------------
ArraySetAsSeries(RSIBuf,
true); // Traders Dynamic Index
ArraySetAsSeries(UpZone,
true);
ArraySetAsSeries(BaseLine,
true);
ArraySetAsSeries(DnZone, true);
ArraySetAsSeries(RSILine,
true);
ArraySetAsSeries(RedLine,
true);
ArraySetAsSeries(haBuffer_Low, true); // HeikinAshi
Candles
ArraySetAsSeries(haBuffer_High,
true);
ArraySetAsSeries(haBuffer_Open,
true);
ArraySetAsSeries(haBuffer_Close, true);
//---- Long/Short
Signals
SetIndexBuffer(0,LongSignal);
SetIndexBuffer(1,ShortSignal);
SetIndexStyle(0,DRAW_ARROW,0,1);
SetIndexStyle(1,DRAW_ARROW,0,1);
SetIndexArrow(0,159);
SetIndexArrow(1,159);
SetIndexLabel(0,"LONG
Signal");
SetIndexLabel(1,"SHORT Signal");
//---- Stops Long/Short
SetIndexBuffer(2,StopLong);
SetIndexBuffer(3,StopShort);
SetIndexStyle(2,DRAW_ARROW,0,0);
SetIndexStyle(3,DRAW_ARROW,0,0);
SetIndexArrow(2,251);
SetIndexArrow(3,251);
SetIndexLabel(2,"Stop
Long");
SetIndexLabel(3,"Stop Short");
//---- MovingAverages /
PriceActionChannel / PAC
SetIndexBuffer(4,mavHighs);
SetIndexBuffer(5,mavLows);
SetIndexBuffer(6,mavTrend);
SetIndexStyle(4,DRAW_LINE,0,2);
SetIndexStyle(5,DRAW_LINE,0,2);
SetIndexStyle(6,DRAW_LINE,0,2);
SetIndexLabel(4,"High
mavg");
SetIndexLabel(5,"Low mavg");
SetIndexLabel(6,"Trend
line");
//---- Draw
begin
SetIndexDrawBegin(0,TrendIndicator_Period);
SetIndexDrawBegin(1,TrendIndicator_Period);
SetIndexDrawBegin(2,TrendIndicator_Period);
SetIndexDrawBegin(3,TrendIndicator_Period);
SetIndexDrawBegin(4,TrendIndicator_Period);
SetIndexDrawBegin(5,TrendIndicator_Period);
SetIndexDrawBegin(6,TrendIndicator_Period);
//----
return(0);
}
//+----------------------------------------------------------+
//|
Custom indicator deinitialization function
|
//+----------------------------------------------------------+
int
deinit() { return(0);
}
//+----------------------------------------------------------+
//|
Custom indicator iteration function
|
//+----------------------------------------------------------+
int
start()
{
bool TradeLong =false;
bool TradeShort=false;
//----
Traders Dynamic Index; Copyright © 2006, Dean Malone
double
MA,RSI[];
ArrayResize(RSI,RSIVolatilityBand_Period);
int
counted_bars=IndicatorCounted();
int
limit=Bars-counted_bars-1;
for(int i=limit; i>=0;
i--)
{
RSIBuf[i]=(iRSI(NULL,0,RSI_Period,RSI_Price,i));
MA=0;
for(int
x=i; x<i+RSIVolatilityBand_Period;
x++)
{
RSI[x-i]=RSIBuf[x];
MA+=RSIBuf[x]/RSIVolatilityBand_Period;
}
UpZone[i]=(MA
+ (1.6185 * StDev(RSI,RSIVolatilityBand_Period)));
// upper
Volatility Band; Blue
DnZone[i]=(MA - (1.6185 *
StDev(RSI,RSIVolatilityBand_Period)));
// lower Volatility
Band; Blue
BaseLine[i]=((UpZone[i] + DnZone[i])*0.5);
//
Market Base Line (MBL);
Yellow
}
for(i=limit-1;i>=0;i--)
{
RSILine[i]=(iMAOnArray(RSIBuf,0,RSISmooth_Period,0,RSI_MavgMODE,i));
// RSI Price Line;
Green
RedLine[i]=(iMAOnArray(RSIBuf,0,RSITradeSignal_Period,0,RSITradeSignal_MavgMODE,i));
//
Trade Signal Line (TSL); Red
}
// MovingAverages / PriceActionChannel /
PAC
for(i=limit-1;i>=0;i--)
{
mavHighs[i]=iMA(NULL,0,PriceChannel_Period,
0,MODE_SMMA,PRICE_HIGH,i); // PriceActionChannel (PAC) Highs;
Yellow
mavLows[i] =iMA(NULL,0,PriceChannel_Period,
0,MODE_SMMA,PRICE_LOW,i); // PriceActionChannel (PAC) Lows;
Yellow
mavTrend[i]=iMA(NULL,0,TrendIndicator_Period,0,MODE_SMMA,PRICE_MEDIAN,i);//
Trend
Line;
Green
}
//+----------------------------------------------------+
//|
Signals
|
//+----------------------------------------------------+
for(i=limit-1;i>=0;i--)
{
//----
HeikinAshi CANDLES
--------------------------------------
double haOpen, haHigh,
haLow,
haClose;
haOpen=(haBuffer_Open[i+1]+haBuffer_Close[i+1])*0.50;
haClose=(Open[i]+High[i]+Low[i]+Close[i])*0.25;
haHigh=MathMax(High[i],
MathMax(haOpen, haClose));
haLow=MathMin(Low[i], MathMin(haOpen,
haClose));
if (haOpen<haClose)
{
haBuffer_Low[i]
=haLow;
haBuffer_High[i]=haHigh;
}
else
{
haBuffer_Low[i]
=haHigh;
haBuffer_High[i]=haLow;
}
haBuffer_Open[i]
=haOpen;
haBuffer_Close[i]=haClose;
//---- local High/Low
if
(haBuffer_High[i] > haBuffer_Low[i])
{
double
thisHigh=haBuffer_High[i];
double thisLow
=haBuffer_Low[i];
}
else
{
thisHigh=haBuffer_Low[i];
thisLow
=haBuffer_High[i];