HiLo_Act_Next_Profi

//+------------------------------------------------------------------+
//|
HiLo_Act_Next_Profi2.mq4 |
//|
Copyright © 2005, MetaQuotes Software Corp. |
//|
Profi_R |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link
"Profi_R"
#property
#property
#property
#property

indicator_chart_window
indicator_buffers 2
indicator_color1 Teal
indicator_color2 Red

//---extern
extern
extern

input parameters
int Range=3;
int NextTF=60;
bool UseFullTF=1;

//---double
double
double
double

buffers
Up[];
Dn[];
UpMA[];
DnMA[];

int init_flag,d_b=0,no_dr_b;
//+------------------------------------------------------------------+
//| Custom indicator initialization function
|
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicators
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE,0,0);
SetIndexStyle(1,DRAW_LINE,0,0);
//SetIndexStyle(2,DRAW_LINE,0,2);
//SetIndexStyle(3,DRAW_LINE,0,2);
SetIndexBuffer(0,Up);
SetIndexBuffer(1,Dn);
SetIndexBuffer(2,UpMA);
SetIndexBuffer(3,DnMA);
SetIndexLabel(0,"Up");
SetIndexLabel(1,"Dn");
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
Page 1

TimeArray_c[].end_ba r. init_flag=0. } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(). IndicatorShortName(short_name). } else { if( Bars-1-counted_bars > Bars-1-no_dr_b) { limit=Bars-1-no_dr_b. } else { limit=Bars-1-counted_bars. } else { if( Bars-1-counted_bars < 0 ) { limit=0.i.0. //---return(0). datetime TimeArray[].sb_count.begin_time.cb.0).HiLo_Act_Next_Profi SetIndexEmptyValue(3.cb_count. //---if( init_flag!=1 ) { if( minit() < 0 ) { return(-1).limit.b_bar.bb_count. } Page 2 . //---short_name="HiLo_Act_Next_Profi2 ("+Range+".end_time. } } if( counted_bars<0 ) { return(-1).j.end_sbar.M"+NextTF+")".

0. if( UseFullTF==0 ) { if( Close[cb]>UpMA[cb] ) { Page 3 .MODE_ASCEND). //end_time=(MathCeil(TimeArray[ArrayBsearch( TimeArray.end_bar)) ).Symbol(). //begin_time=(MathCeil(TimeArray[ArrayBsearch( TimeArray.MODE_ASCEND)]/NextTF/60)*NextTF*60 > MathCeil(Time[cb]/Period()/60)*Period()*60) { b_bar =ArrayBsearch( TimeArray.Time[cb].PRICE_HIGH.Period().PRICE_LOW. DnMA[cb]=iMA(Symbol().NextTF.0.cb--) { if( MathCeil(TimeArray[ArrayBsearch( TimeArray.0. end_bar =ArrayBsearch( TimeArray.0.0. if( bb_count<=0 || cb_count<=0 ) { return(0). //end_time=MathCeil(TimeArray[ArrayBsearch( TimeArray.Time[cb].MODE_SMA.0.NextTF). //b_bar=ArrayBsearch( TimeArray_c.MODE_ASCEND)+1+Range.NextTF.0.0.Period()). UpMA[cb]=iMA(Symbol().PRICE_LOW.Time[cb].b_bar+1-end_bar. //end_sbar=ArrayBsearch( TimeArray_c. } else { b_bar =ArrayBsearch( TimeArray.end_time.0.MODE_ASCEND)+1.0. } for(cb=limit. end_bar =ArrayBsearch( TimeArray.0.0.Time[cb].0.Time[cb].MODE_SMA.0.Symbol().MODE_ASCEND)]/NextTF/60)*NextTF*60.0.HiLo_Act_Next_Profi } } bb_count=ArrayCopySeries(TimeArray.0.0.MODE_TIME.end_bar).0.NextTF.b_bar))+" ".MODE_ASCEND)+Range.begin_time. TimeToStr(iTime(NULL. TimeToStr(iTime(NULL.MODE_ASCEND)+1.end_bar).Time[cb].MODE_ASCEND)+2.0.NextTF.Time[cb].0.MODE_ASCEND)+1]/NextTF/60))*NextTF*60.MODE_TIME.MODE_SMA.end_bar).0.MODE_ASCEND)+Range]/NextTF/60))*NextTF*60.cb>=0.0. cb_count=ArrayCopySeries(TimeArray_c.0.b_bar+1-end_bar.Time[cb].Period(). //UpMA[cb]=iMA(Symbol(). //begin_time=(MathCeil(TimeArray[ArrayBsearch( TimeArray.Range. } //---------------------------------------------------------------------------------------------------------------------// //Alert( TimeToStr(Time[cb])+" ".end_bar).PRICE_HIGH.MODE_ASCEND)+1+Range]/NextTF/60))*NextTF*60.MODE_SMA.Time[cb].0.0. //DnMA[cb]=iMA(Symbol().Range.0.

} Page 4 .0. Dn[cb]=0. } } } } else { Print(TimeToStr(Time[cb])+" "+TimeToStr((MathCeil(TimeArray[end_bar]/NextTF/60)+1)*NextTF*60)+" "+TimeToStr((MathCeil(Time[cb]/Period()/60))*Period()*60)).0. if( Close[cb+1]>UpMA[cb+1] && (MathCeil(TimeArray[end_bar]/NextTF/60)+1)*NextTF*60==(MathCeil(Time[cb]/Period()/60 ))*Period()*60 ) { Dn[cb]=DnMA[cb]. Up[cb]=0.0. } if( Dn[cb+1]>0 ) { Dn[cb]=DnMA[cb]. Dn[cb]=0. Dn[cb]=0. Up[cb]=0. } else { if( Close[cb]<DnMA[cb] ) { Up[cb]=UpMA[cb].HiLo_Act_Next_Profi Dn[cb]=DnMA[cb].0. Up[cb]=0.0.0. } else { if( Close[cb+1]<DnMA[cb+1] && (MathCeil(TimeArray[end_bar]/NextTF/60)+1)*NextTF*60==(MathCeil(Time[cb]/Period()/60 ))*Period()*60 ) { Up[cb]=UpMA[cb]. } else { if( Up[cb+1]>0 ) { Up[cb]=UpMA[cb].

MODE_TIME. Page 5 .0. int bb_count. } } } } } //---return(0). Up[cb]=0. Dn[cb]=0. } //ïðîâåðêà íà íåîáõîäèìîñòü îáíîâëåíèÿ äàííûõ áîëüøåãî ò-ô if( MathCeil(TimeArray[0]/NextTF/60)*NextTF*60 < MathCeil(Time[0]/Period()/60)*Period()*60-NextTF*60 ) { Alert("Íåîáõîäèìî îáíîâèòü äàííûå Next òàéìôðåéìà!").cb. //---//ïîëó÷åíèå âðåìåíè íà÷àëà êàæäîãî áàðà ñ äðóãîãî òàéìôðåéìà bb_count=ArrayCopySeries(TimeArray. return(-1). } if( Dn[cb+1]>0 ) { Dn[cb]=DnMA[cb].HiLo_Act_Next_Profi else { if( Up[cb+1]>0 ) { Up[cb]=UpMA[cb]. } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Îïðåäåëåíèå íà÷àëüíîé òî÷êè îòðèñîâêè | //+------------------------------------------------------------------+ int minit() { datetime TimeArray[]. if( bb_count<1 ) { Alert("Îòñóòñòâóþò äàííûå Next òàéìôðåéìà!").Symbol(). return(-1). } //ïðîâåðêà íà íåîáõîäèìîñòü îáíîâëåíèÿ äàííûõ òåêóùåãî ò-ô if( MathCeil(TimeArray[0]/NextTF/60)*NextTF*60 > MathCeil(Time[0]/Period()/60)*Period()*60 ) { Alert("Íåîáõîäèìî îáíîâèòü äàííûå òåêóùåãî òàéìôðåéìà!").0.i.NextTF).

no_dr_b+1).no_dr_b+1).i>=0. init_flag=1. SetIndexDrawBegin(1.HiLo_Act_Next_Profi return(-1).no_dr_b+1).cb>=0. init_flag=1.cb--) { if( MathCeil(Time[Bars-1]/Period()/60)*Period()*60 >= MathCeil(TimeArray[cb]/NextTF/60)*NextTF*60 && MathCeil(Time[Bars-1]/Period()/60)*Period()*60 < MathCeil(TimeArray[cb-1]/NextTF/60)*NextTF*60 ) { for( i=Bars-1.i-.. Page 6 .cb>=0. no_dr_b=Bars-1-d_b. } } if( d_b>0 ) { break.no_dr_b+1). SetIndexDrawBegin(0. SetIndexDrawBegin(1. SetIndexDrawBegin(0.) { if( MathCeil(Time[i]/Period()/60)*Period()*60 >= MathCeil(TimeArray[cb-Range]/NextTF/60)*NextTF*60 ) { d_b=i. if( MathCeil(Time[cb]/Period()/60)*Period()*60 >= MathCeil(TimeArray[bb_count-1-Range]/NextTF/60)*NextTF*60 ) { d_b=cb..cb--) { //åñëè âðåìÿ áàðà áîëüøå èëè ðàâíî âðåìåíè áàðà ñ êîòîðîãî íà÷èíàåì îòðèñîâêó. break. } } } } else { for(cb=Bars-1. } //åñëè áàðû íà òåêóùåì ò-ô íà÷èíàþòñÿ ñ ìîìåíòà îòðèñîâêè áàðîâ áîëüøåãî ò-ô èëè ïîçæå if( MathCeil(Time[Bars-1]/Period()/60)*Period()*60 >= MathCeil(TimeArray[bb_count-1]/NextTF/60)*NextTF*60 ) { for( cb=bb_count-1. no_dr_b=Bars-1-d_b.

} //---return(0). } //+------------------------------------------------------------------+ Page 7 .HiLo_Act_Next_Profi break. } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---//---return(0). } } } if( d_b<1 ) { return(-1).

Sign up to vote on this title
UsefulNot useful