//////////////////////////////////////////////////////////////////////////////////////////////////// ////tabs_SPECIFIC.mq4////v1.0////02-2010////cu6yu4////cu6yu4@gmail.com////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// #property show_inputs //---- parameters extern string Pair="EURUSD"; extern int ReboundTab=50; extern int InertiaTab=50; extern bool StartBuying=true; extern datetime EndDate = D'2010.06.01 00:00'; extern datetime InsertionDate = D'2009.06.01 00:00'; //////////////////////////////////////////////////////////////////////////////////////////////////// int init() { //// return(0); } //////////////////////////////////////////////////////////////////////////////////////////////////// int deinit() { //// return(0); } //////////////////////////////////////////////////////////////////////////////////////////////////// int start() { //---- formula variables int PairDigits,Converter,PresentInstant,FutureInstant; double RealInertiaTab,RealReboundTab,HighPrice,LowPrice,BasePrice; //---- result variables double WeekRemainder; //---- time variables string IniText,EndText,InsertionDay,EndDay,TimeBar; //---- formula counters int ISign,RSign,BarShift,LastShift,IEvent,REvent; //---- write variables int Handle; string Name,Sense,First; //---- new file //---- string times IniText=TimeToStr(InsertionDate,TIME_DATE); InsertionDay=StringConcatenate(StringSubstr(IniText,0,4),StringSubstr(IniText,5,2),StringSubstr(IniText,8,2)); EndText=TimeToStr(EndDate,TIME_DATE); EndDay=StringConcatenate(StringSubstr(EndText,0,4),StringSubstr(EndText,5,2),StringSubstr(EndText,8,2)); //---- name if(StartBuying) { First="1stBuy"; } else { First="1stSell"; } Name=StringConcatenate(Pair,"______",InsertionDay,"__",EndDay,"______",ReboundTab,"______",InertiaTab,"______",First,".xls"); Handle=FileOpen("/tabs_SPECIFIC_GAPS_2/"+Name,FILE_CSV|FILE_READ|FILE_WRITE,' '); FileWrite(Handle," ",Name,"","",""); FileWrite(Handle,"","","","","","","",""); //---- pre-formula //---- normal or jpy RealInertiaTab=InertiaTab; RealReboundTab=ReboundTab; PairDigits=MarketInfo(Pair,MODE_DIGITS); if (PairDigits==4||PairDigits==5) { Converter=10000; } if (PairDigits==2||PairDigits==3) { Converter=100; } RealInertiaTab=RealInertiaTab/Converter; RealReboundTab=RealReboundTab/Converter; //---- signs in first if(StartBuying) { ISign=1; RSign=-1; } else { ISign=-1; RSign=1; } //---- shifts BarShift=iBarShift(Pair,0,InsertionDate); if (TimeSeconds(InsertionDate)==0) { BarShift--; } LastShift=iBarShift(Pair,0,EndDate); //---- imput BasePrice=iOpen(Pair,PERIOD_M1,BarShift); PresentInstant=TimeDayOfWeek(iTime(Pair,PERIOD_M1,BarShift)); //---- formula while(BarShift>LastShift) { if((PresentInstant!=0)&&(PresentInstant!=6)) { //---- time TimeBar=TimeToStr(iTime(Pair,PERIOD_M1,BarShift),TIME_DATE|TIME_MINUTES); //---- prices HighPrice=iHigh(Pair,PERIOD_M1,BarShift); LowPrice=iLow(Pair,PERIOD_M1,BarShift); //---- operations if(ISign==1) { if (HighPrice>=BasePrice+ISign*RealInertiaTab) { BasePrice=BasePrice+ISign*RealInertiaTab; IEvent++; FileWrite(Handle,""); } } else { if (LowPrice<=BasePrice+ISign*RealInertiaTab) { BasePrice=BasePrice+ISign*RealInertiaTab; IEvent++; FileWrite(Handle,""); } } if(RSign==1) { if (HighPrice>=BasePrice+RSign*RealReboundTab) { BasePrice=BasePrice+RSign*RealReboundTab; ISign=1; RSign=-1; REvent++; FileWrite(Handle,""); } } else { if (LowPrice<=BasePrice+RSign*RealReboundTab) { BasePrice=BasePrice+RSign*RealReboundTab; ISign=-1; RSign=1; REvent++; FileWrite(Handle,""); } } //// } //---- weekend gaps FutureInstant=TimeDayOfWeek(iTime(Pair,PERIOD_M1,BarShift-1)); if(PresentInstant==5&&FutureInstant!=5) { WeekRemainder=BasePrice-iClose(Pair,PERIOD_M1,BarShift); } if(PresentInstant!=1&&FutureInstant==1) { BasePrice=iOpen(Pair,PERIOD_M1,BarShift-1)+WeekRemainder; } PresentInstant=FutureInstant; //---- go forward BarShift--; //// } //---- closing the file FileWrite(Handle,"
Event",Pair,"PriceTime
","GAPS","
",InsertionDay,"
",EndDay,"
",First,"
",ReboundTab,InertiaTab,"

","=CONTAR(B10:B20000)","

","III"," ","1"," ",BasePrice," ",TimeBar,"
","III"," ","-1"," ",BasePrice," ",TimeBar,"
","RRR"," ","1"," ",BasePrice," ",TimeBar,"
","RRR"," ","-1"," ",BasePrice," ",TimeBar,"

 

 

"); FileClose(Handle); //// return(0); } //////////////////////////////////////////////////////////////////////////////////////////////////// ////tabs_SPECIFIC.mq4////v1.0////02-2010////cu6yu4////cu6yu4@gmail.com////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////