//+------------------------------------------------------------------+ //| Set of functions and testing script | //| ObjectGetValueByCurrent.mq4 | //| Aleksandr Pak, Alma-Ata | //| ekr-ap@mail.ru | //+------------------------------------------------------------------+ #property copyright "Aleksandr Pak, Alma-Ata" #property link "ekr-ap@mail.ru" //+------------------------------------------------------------------+ //|CORRECTED from 19-04-2008ã. | //+------------------------------------------------------------------+ /* Shows process of formation of bars on occurrence of a tic */ string d="Demo Line"; int init() { if(ObjectFind(d)!=0) ObjectCreate(d,OBJ_TREND,0, iTime(NULL,0,7),WindowPriceMax(0), iTime(NULL,0,0)+15*60*Period(),WindowPriceMin(0)); WindowRedraw(); } int deinit() { ObjectDelete("Demo"); ObjectDelete("Demo Line"); return (0); } int start() { double t2,t=TimeLocal()-5; int i=0; while(i<300) { if(IsStopped()) return(0); t2=TimeLocal(); if(t2-t>=5) { i+=1; t=TimeLocal(); RefreshRates(); double rb=ObjectGetValueByShift (d,0); if(rb!=0) rb+=ObjectGetDelta_PerBar(d); Print( "Time[0]=",iTime(Symbol(),0,0), " Line[0]=", ObjectGetValueByShift (d,0), " current value at formation 0 bars=",DoubleToStr(ObjectGetValue_ByCurrent (d,0),Digits+2), " Line (- 1)=",DoubleToStr(rb,Digits+2), " delta on (1) bar=",DoubleToStr(ObjectGetDelta_PerBar(d),Digits+2), " delta on (2) bar=",DoubleToStr(ObjectGetDelta_ByTimeShift(d,2*60*Period()),Digits+2)); } } Print("The end of demonstration"); return(0); } //+------------------------------------------------------------------+ //******************************* double ObjectGetValue_ByCurrent(string c, int shift) //Value of { double r=ObjectGetValueByShift (c,shift); if(r!=0) return(r+ObjectGetDelta_ByCurrent(c)); else return(0); } //******************************* double ObjectGetDelta_PerBar(string c) //Increment of Y-ordinate per Bar { double p= ObjectGet(c,OBJPROP_PRICE1); double p2= ObjectGet(c,OBJPROP_PRICE2); int b = ObjectGetShiftByValue(c,p); int b2= ObjectGetShiftByValue(c,p2); double z=b-b2; if(z!=0) { double delta=(p2-p)/z; } return(delta); } //*************************************** double ObjectGetDelta_ByCurrent(string c) { double t=TimeCurrent()-iTime(Symbol(),0,0); double tf=60*Period(); double delta=ObjectGetDelta_PerBar(c); double r=delta*(t/tf); /*For demonstration!!!!*/ Print(" Time of the (0)Bar=",DoubleToStr(100*t/tf,0),"%", /*For demonstration!!!!*/ " Value of correction of the price=",DoubleToStr(r,Digits+2)); return(r); } //**************************************************************************** double ObjectGetDelta_ByTimeShift(string c, double t) //double=datetime { double tf=60*Period(); double delta=ObjectGetDelta_PerBar(c); double r=delta*(t/tf); return(r); }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: