Beruflich Dokumente
Kultur Dokumente
mq4 |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
double UpSignal[];
double DnSignal[];
double UpEntry[];
double DnEntry[];
double smax[];
double smin[];
double trend[];
datetime prevTime;
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int init()
string short_name;
//IndicatorBuffers(7);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,108);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexStyle(2,DRAW_ARROW);
//SetIndexArrow(2,108);
SetIndexStyle(3,DRAW_ARROW);
//SetIndexArrow(3,108);
IndicatorDigits(MarketInfo(_Symbol,12));
IndicatorShortName("PriceChannel_Signal("+Length+")");
SetIndexLabel(0,"UpSignal");
SetIndexLabel(1,"DnSignal");
SetIndexLabel(2,"UpRe-Entry");
SetIndexLabel(3,"DnRe-Entry");
SetIndexDrawBegin(0,Length);
SetIndexDrawBegin(1,Length);
SetIndexDrawBegin(2,Length);
SetIndexDrawBegin(3,Length);
SetIndexBuffer(0,UpSignal);
SetIndexBuffer(1,DnSignal);
SetIndexBuffer(2,UpEntry);
SetIndexBuffer(3,DnEntry);
SetIndexBuffer(4,smax);
SetIndexBuffer(5,smin);
SetIndexBuffer(6,trend);
return(0);
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int start()
int limit;
if(Bars<=Length) return(0);
int CountedBars=IndicatorCounted();
if (CountedBars>0) CountedBars--;
limit=Bars-CountedBars;
//----
double hi = High[iHighest(NULL,0,2,Length,i)];
double lo = Low[iLowest(NULL,0,1,Length,i)];
smax[i] = hi - (33-Risk)*(hi-lo)/100;
smin[i] = lo + (33-Risk)*(hi-lo)/100;
trend[i]=trend[i+1];
if(trend[i]>0)
if (trend[i+1]<0)
UpSignal[i] = Low[i]-0.5*iATR(NULL,0,Length,i);
}
if (UseReEntry > 0 && price > smax[i] && price1 <= smax[i+1])
UpEntry[i] = Low[i]-0.5*iATR(NULL,0,Length,i);
DnSignal[i]=EMPTY_VALUE; DnEntry[i]=EMPTY_VALUE;
else
if(trend[i]<0)
if (trend[i+1]>0)
DnSignal[i] = High[i]+0.5*iATR(NULL,0,Length,i);
if (UseReEntry > 0 && price < smin[i] && price1 >= smin[i+1])
DnEntry[i] = High[i]+0.5*iATR(NULL,0,Length,i);
UpSignal[i]=EMPTY_VALUE; UpEntry[i]=EMPTY_VALUE;
//----------
Alert (Message);
UpTrendAlert=true; DownTrendAlert=false;
if (UseReEntry>0 && trend[i+2]>0 && price1 > smax[i+1] && price2 <= smax[i+2] &&
Time[i]!=prevTime)
Alert (Message);
prevTime = Time[i];
else
Alert (Message);
DownTrendAlert=true; UpTrendAlert=false;
if (UseReEntry>0 && trend[i+2]<0 && price1 < smin[i+1] && price2 >= smin[i+2] &&
Time[i]!=prevTime)
{
Message = " "+_Symbol+" M"+Period()+": Re-Entry for SELL";
Alert (Message);
prevTime = Time[i];
//---- done
return(0);
//+------------------------------------------------------------------+
//******************************************** Emulation
*******************************************
double Ask;
double Bid;
double Bars;
double Open[];
double Close[];
double High[];
double Low[];
datetime Time[];
long Volume[];
void Set_Values_to_variables()
MqlTick last_tick;
SymbolInfoTick(_Symbol,last_tick);
Ask=last_tick.ask;
Bid=last_tick.bid;
ArraySetAsSeries(Close,true);
CopyClose(_Symbol,_Period,0,Bars(_Symbol,_Period),Close);
ArraySetAsSeries(Open,true);
CopyOpen(_Symbol,_Period,0,Bars(_Symbol,_Period),Open);
ArraySetAsSeries(Low,true);
CopyLow(_Symbol,_Period,0,Bars(_Symbol,_Period),Low);
ArraySetAsSeries(High,true);
CopyHigh(_Symbol,_Period,0,Bars(_Symbol,_Period),High);
ArraySetAsSeries(Time,true);
CopyTime(_Symbol,_Period,0,Bars(_Symbol,_Period),Time);
ArraySetAsSeries(Volume,true);
CopyTickVolume(_Symbol,_Period,0,Bars(_Symbol,_Period),Volume);
void OnTick()
Set_Values_to_variables();
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double
&open[], const double &high[],
const double &low[], const double &close[], const long &tick_volume[], const long &volume[],
const int &spread[])
Set_Values_to_variables();
void OnInit()
Set_Values_to_variables();
init();
switch(tf)
case 0: return(PERIOD_CURRENT);
case 1: return(PERIOD_M1);
case 5: return(PERIOD_M5);
case 2: return(PERIOD_M2);
case 3: return(PERIOD_M3);
case 4: return(PERIOD_M4);
case 6: return(PERIOD_M6);
default: return(PERIOD_CURRENT);