//*****************************************************************************//
//*****************************************************************************//
//* BS_Living Now.mq4 *//
//* Copyright © 2013, Backspace *//
//* Success Version *//
//*****************************************************************************//
//*****************************************************************************//
//* Òîðãóé òðåíäû *//
//* Óìåíüøàé ïîòåðè *//
//* Äàâàé ïðèáûëè ðàñòè *//
//* Óïðàâëÿé ðèñêàìè *//
//*****************************************************************************//
//*****************************************************************************//
#property copyright "Copyright © 2013, Backspace" //
#property link "Success Version" //
//
#property indicator_chart_window //
#property indicator_buffers 4 //
#property indicator_color1 Red //
#property indicator_color2 Yellow //
#property indicator_color3 Red //
#property indicator_color4 Yellow //
//******************// Ââîä ïàðàìåòðîâ èíäèêàòîðà
extern int BQuant=48; // - êîë-âî ïðîñ÷èòûâàåìûõ áàðîâ
//******************// Ñîñòàâíûå ÷àñòè èíäèêàòîðà
double ExtrimHi[], // - ýêñòðåìóì High
ExtrimLo[], // - ýêñòðåìóì Low
BreakHi[], // - ýêñòðåìóì High
BreakLo[]; // - ýêñòðåìóì Low
//*****************************************************************************//
//**************************-Indicator Initialization-*************************//
//*****************************************************************************//
//
int init() //
{ //
Comment("BS_Living Now"); //
//******************// Íàñòðîéêè ãðàôè÷åñêîãî îòîáðàæåíèÿ
IndicatorBuffers (4); //
SetIndexLabel (0,"ExtrimHi"); //
SetIndexBuffer (0,ExtrimHi); //
SetIndexStyle (0,DRAW_ARROW,EMPTY,2); //
SetIndexArrow (0,159); //
SetIndexLabel (1,"ExtrimLo"); //
SetIndexBuffer (1,ExtrimLo); //
SetIndexStyle (1,DRAW_ARROW,EMPTY,2); //
SetIndexArrow (1,159); //
SetIndexLabel (2,"BreakHi"); //
SetIndexBuffer (2,BreakHi); //
SetIndexStyle (2,DRAW_NONE,EMPTY,1); // çàìåíèòü íà DRAW_ARROW
SetIndexArrow (2,224); //
SetIndexLabel (3,"BreakLo"); //
SetIndexBuffer (3,BreakLo); //
SetIndexStyle (3,DRAW_NONE,EMPTY,1); // çàìåíèòü íà DRAW_ARROW
SetIndexArrow (3,224); //
//*********//
return(0); //
} //
//
//*****************************************************************************//
//*************************-Indicator Deinitialization-************************//
//*****************************************************************************//
//
int deinit() //
{ //
Comment(""); //
//*********//
return(0); //
} //
//
//*****************************************************************************//
//*********************************-Living Now-********************************//
//*****************************************************************************//
//
int start() //
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+BQuant;
//
for(int s=limit; s>=1; s--) //
{ //
Comment("Living Now\n","Spread =",MarketInfo(Symbol(),MODE_SPREAD)); //
Extrim_Detect(s+1); //******************// Îïðåäåëåíèå ýêñòðåìóìîâ
} //
//*********//
return(0); //
} //
//
//*****************************************************************************//
//*********************************-SubPogramms-*******************************//
//*****************************************************************************//
//
double Extrim_Detect(int t) //***********************************// Îïðåäåëåíèå ýêñòðåìóìîâ
{ //
if((TimeDayOfWeek(Time[t])==5 && TimeHour(Time[t])>=20)|| //
(TimeDayOfWeek(Time[t])==1 && TimeHour(Time[t])<=1)) //
{ExtrimHi[t] =0; ExtrimLo[t] =0;} //
else //
{ //
if(iHigh(NULL,0,t)>=High[iHighest(NULL,0,2,BQuant,t+1)] && //
iHigh(NULL,0,t)>iHigh(NULL,0,t-1)) //
{ //
ExtrimHi[t] =iHigh(NULL,0,t); //
Break_Detect(t,1); //******************// Îïðåäåëåíèå òî÷åê ïðîðûâà
} //
if(iLow(NULL,0,t)<=Low[iLowest(NULL,0,1,BQuant,t+1)] && //
iLow(NULL,0,t)<iLow(NULL,0,t-1)) //
{ //
ExtrimLo[t] =iLow(NULL,0,t); //
Break_Detect(t,-1); //******************// Îïðåäåëåíèå òî÷åê ïðîðûâà
} //
} //
//*********//
return(0); //
} //
//
double Break_Detect(int a,int Signal) //***********************************// Îïðåäåëåíèå òî÷åê ïðîðûâà
{ //
for(int r=1; r<BQuant; r++) //
{ //
if(Signal==1 && iHigh(NULL,0,a+r)<High[iHighest(NULL,0,2,BQuant,a+r+1)]) //
{BreakHi[a] =Low[iLowest(NULL,0,1,r+2,a-1)]; r=BQuant;} //
if(Signal==-1 && iLow(NULL,0,a+r)>Low[iLowest(NULL,0,1,BQuant,a+r+1)]) //
{BreakLo[a] =High[iHighest(NULL,0,2,r+2,a-1)]; r=BQuant;} //
} //
//*********//
return(0); //
} //
//
//*****************************************************************************//
//**************************************************************************BS*//
//*****************************************************************************//
Comments