ObjectGetValuue_ByCurrent_





//+------------------------------------------------------------------+
//|  Íàáîð ôóíêöèé è òåñòèðóþùèé ñêðèïò                              |
//|                                      ObjectGetValueByCurrent.mq4 |
//|                                          Aleksandr Pak, Alma-Ata |
//|                                                   ekr-ap@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Aleksandr Pak, Alma-Ata"
#property link      "ekr-ap@mail.ru"

//+------------------------------------------------------------------+
//| ÈÑÏÐÀÂËÅÍÎ îò 19 àïðåëÿ 2008ã.                                 |
//+------------------------------------------------------------------+
/*
Êîñâåííî äåìîíñòðèðóåò ïðîöåññ ôîðìèðîâàíèÿ áàðîâ ïî ïðèõîäó òèêà
*/

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( "Âðåìÿ[0]=",iTime(Symbol(),0,0), 
      " ëèíèÿ[0]=", ObjectGetValueByShift (d,0),
      " òåêóùåå çíà÷åíèå âíóòðè 0 áàðà=",DoubleToStr(ObjectGetValue_ByCurrent (d,0),Digits+2),
      " ëèíèÿ (- 1)=",DoubleToStr(rb,Digits+2),
      " delta íà (1) áàð=",DoubleToStr(ObjectGetDelta_PerBar(d),Digits+2),
      " delta íà (2) áàðà=",DoubleToStr(ObjectGetDelta_ByTimeShift(d,2*60*Period()),Digits+2));
     
      }
   }  
   Print("Êîíåö äåìîíñòðàöèè");
   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);
/*Äëÿ äåìîíñòðàöèè*/      Print("              Ïðîöåíò âðåìåíè Áàðà=",DoubleToStr(100*t/tf,0),"%", 
/*Äëÿ äåìîíñòðàöèè*/      "                                 ïîïðàâêà öåíû ëèíèè=",DoubleToStr(r,Digits+2));

 return(r);
 
}
//****************************************************************************
double ObjectGetDelta_ByTimeShift(string c, double t) //t=TimeShift â ñåêóíäàõ
{ 
      double tf=60*Period();
      double delta=ObjectGetDelta_PerBar(c);
      double r=delta*(t/tf); 
 return(r);
 
}










Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: