Thema: mq4 in mq5
Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 20.01.18
Fauschtolo Fauschtolo ist offline
Neues Mitglied
 
Registriert seit: Oct 2017
Beiträge: 5
Fauschtolo befindet sich auf einem aufstrebenden Ast
Standard mq4 in mq5

Ich brauche Hilfe beim übersetzten dieses Indikators von mq4 in mq5


//+------------------------------------------------------------------+
//| RSI + ADX Arrows Alerts & Labels |
//| |
//| Copyright © 2014 / airquest@hotmail.com |
//| |
//| http://smart-trading.world-record.ch |
//+------------------------------------------------------------------+


#property copyright "Copyright © 2014 // airquest // smart-trading.world-record.ch"
#property link "http://smart-trading.world-record.ch"
#property description "RSI + ADX Arrows Alerts & Labels"


//------------------------------------------------------------------

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2


extern bool ShowArrows = True;
extern bool ShowLabels = True;

extern int RsiPeriod = 7;
extern int RsiPrice = PRICE_CLOSE;
extern int RsiOBLevel = 70;
extern int RsiOSLevel = 30;

extern int AdxPeriod = 20;
extern int AdxPrice = PRICE_CLOSE;
extern int AdxLevel = 20;

extern double ArrowsDisplacement = 0.8;
extern color ArrowsUpColor = Lime;
extern color ArrowsDnColor = Red;
extern int ArrowsUpCode = 233;
extern int ArrowsDnCode = 234;
extern int ArrowsWidth = 3;

extern bool AlertsOn = True;
extern bool AlertsOnCurrent = True;
extern bool AlertsMessage = True;
extern bool AlertsEmail = False;
extern bool AlertsSound = False;

extern color LabelBuyColor = Lime;
extern color LabelSellColor = Red;
extern int LabelFontWidth = 14;
extern int LabelCorner = 1;
extern int LabelYDistance = 0;
extern int LabelXDistance = 0;
extern string UniqueID = "RSI+ADX";


double ArrowsBuy[];
double ArrowsSell[];
double trend[];
bool up;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);

SetIndexBuffer(0,ArrowsBuy); SetIndexStyle(0,DRAW_ARROW,NULL,ArrowsWidth,Arrows UpColor); SetIndexArrow(0,ArrowsUpCode);
SetIndexBuffer(1,ArrowsSell); SetIndexStyle(1,DRAW_ARROW,NULL,ArrowsWidth,Arrows DnColor); SetIndexArrow(1,ArrowsDnCode);
SetIndexBuffer(2,trend);

if(!ShowArrows) { SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_NONE); }

return(0);
}

int deinit() { DeleteLabels(); return(0); }

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=MathMin(Bars-counted_bars,Bars-1);

for(int i=limit; i>=0; i--)
{
double rsi = iRSI(NULL,0,RsiPeriod,RsiPrice,i);
double adx = iADX(NULL,0,AdxPeriod,AdxPrice,0,i);

trend[i] = trend[i+1];

if (rsi <= RsiOSLevel && adx <= AdxLevel && Volume[i] <= Volume[i+1]) trend[i] = 1;
else if (rsi >= RsiOBLevel && adx <= AdxLevel && Volume[i] <= Volume[i+1]) trend[i] = -1;
else trend[i] = 0;

double gap = iATR(NULL,0,100,i);
double high = High[i] + gap * ArrowsDisplacement;
double low = Low[i] - gap * ArrowsDisplacement;

ArrowsBuy[i] = EMPTY_VALUE;
ArrowsSell[i] = EMPTY_VALUE;

if(trend[i] != trend[i+1] && trend[i] == 1)
{
ArrowsBuy[i] = low;
if(AlertsOn)
{
if (AlertsOnCurrent)
int whichBar = 0;
else whichBar = 1;
doAlert(whichBar,"Buy Signal - 15 min. expiry");
up = True;
if(ShowLabels) AddLabels();
}
}

else if(trend[i] != trend[i+1] && trend[i] == -1)
{
ArrowsSell[i] = high;
if(AlertsOn)
{
if (AlertsOnCurrent)
whichBar = 0;
else whichBar = 1;
doAlert(whichBar,"Sell Signal - 15 min. expiry");
up = False;
if(ShowLabels) AddLabels();
}
}

else if(trend[i] == 0) DeleteLabels();
}

return(0);
}

//+------------------------------------------------------------------+
void doAlert(int forBar, string doWhat)
{
static string previousAlert = "Nothing";
static datetime previousTime;
string message;

if (previousAlert != doWhat && previousTime != Time[forBar])
{
previousAlert = doWhat;
previousTime = Time[forBar];

message = StringConcatenate(Symbol()," at ",TimeToStr(Time[forBar],TIME_SECONDS)," - ",TimeFrameToString(Period())," - RSI + ADX: ",doWhat);
if (AlertsMessage) Alert(message);
if (AlertsEmail) SendMail(StringConcatenate(Symbol(),"RSI + ADX: "),message);
if (AlertsSound) PlaySound("alert2.wav");
}
}

string TimeFrameToString(int tf)
{
string tfs;

switch(tf)
{
case PERIOD_M1:
tfs = "M1";
break;
case PERIOD_M5:
tfs = "M5";
break;
case PERIOD_M15:
tfs = "M15";
break;
case PERIOD_M30:
tfs = "M30";
break;
case PERIOD_H1:
tfs = "H1";
break;
case PERIOD_H4:
tfs = "H4";
break;
case PERIOD_D1:
tfs = "D1";
break;
case PERIOD_W1:
tfs = "W1";
break;
case PERIOD_MN1:
tfs = "MN";
default: tfs = "M" + DoubleToStr(tf,0);
}
return(tfs);
}

void AddLabels()
{
string name = UniqueID+" Label";
if(up)
{
ObjectDelete(UniqueID+" Label");
ObjectCreate(0,name,OBJ_LABEL,0,Time[0],Close[0]);
ObjectSetText(name,"RSI+ADX+Volume: Call Signal - 15 min. expiry",LabelFontWidth,NULL,LabelBuyColor);
ObjectSet(name,OBJPROP_XDISTANCE,LabelXDistance);
ObjectSet(name,OBJPROP_YDISTANCE,LabelYDistance);
ObjectSet(name,OBJPROP_CORNER,LabelCorner);
}
else if(!up)
{
ObjectDelete(UniqueID+" Label");
ObjectCreate(0,name,OBJ_LABEL,0,Time[0],Close[0]);
ObjectSetText(name,"RSI+ADX+Volume: Put Signal - 15 min. expiry",LabelFontWidth,NULL,LabelSellColor);
ObjectSet(name,OBJPROP_XDISTANCE,LabelXDistance);
ObjectSet(name,OBJPROP_YDISTANCE,LabelYDistance);
ObjectSet(name,OBJPROP_CORNER,LabelCorner);
}
}

void DeleteLabels()
{
ObjectDelete(UniqueID+" Label");
}