How can i find FIbo Expansion Price Value?

 

I can get the Price_value from Fibonacci with 2 parameters, with the following code...


void OnTick()
  {
  
ObjectDelete(0,Symbol());


   datetime time1,time2;
   double price1,price2;
   int chart_ID= 0;
   string name = Symbol();
   double fib_values[13]={0.0,.236,.382,.500,.550,.618,.786,1.000,1.272,1.411,1.618,2.618,4.236};

   
   
   time1 = iTime(NULL,0,1);
   time2 = iTime(NULL,0,2);
   
   price1 = iLow(Symbol(),NULL,1);
   price2 = iHigh(Symbol(),NULL,2);

   if(!ObjectCreate(chart_ID,name,OBJ_FIBO,0,time1,price1,time2,price2))Print("Error");
   
   ObjectSetInteger(chart_ID,name,OBJPROP_FIBOLEVELS,13);

 double range=MathAbs(price1-price2);
   for( int i=0;i<13;i++)
     {

      ObjectSetDouble(chart_ID,name,OBJPROP_FIRSTLEVEL+i,fib_values[i]);
      ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,DoubleToString(100*fib_values[i],1));

          double Price_value=(price2>price1)?price2-range*fib_values[i]:price2+range*fib_values[i];
           Print(fib_values[i]," " , Price_value); 

     }
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,Magenta);
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,1);
   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,False);
   

  }

How can i get the  Price_value  for  Fibonacci EXPANSION, that has 3 parameters , for the following code?

void OnTick()
    {   
     
    ObjectDelete(0,Symbol());
    
   datetime time1,time2,time3;
   double price1,price2,price3;
   int chart_ID= 0;
   string name = Symbol();
   double fib_values[13]={0.0,.236,.382,.500,.550,.618,.786,1.000,1.272,1.411,1.618,2.618,4.236};

   time1 = iTime(NULL,0,3);
   time2 = iTime(NULL,0,2);
   time3 = iTime(NULL,0,1);
   
   price1 = iLow(Symbol(),NULL,3);
   price2 = iHigh(Symbol(),NULL,2);
   price3 = iLow(Symbol(),NULL,1);
   
       if(!ObjectCreate(chart_ID,name,OBJ_EXPANSION,0,time1,price1,time2,price2,time3,price3)) Print("error");
     
     ObjectSetInteger(chart_ID,name,OBJPROP_LEVELS,13);
   for(int i=0;i<13;i++)
     {
      ObjectSetDouble(chart_ID,name,OBJPROP_LEVELVALUE,i,fib_values[i]);
      ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,"FE "+DoubleToString(100*fib_values[i],1));
     }
       ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,Magenta);
       ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,STYLE_SOLID);
       ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,1);
       ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,False);

     }
     
 
Ioannis Christopoulos:

I can get the Price_value from Fibonacci with 2 parameters, with the following code...


How can i get the  Price_value  for  Fibonacci EXPANSION, that has 3 parameters , for the following code?

you are not being clear, none of your code is getting the price values from the object.

try looking at ObjectGetDouble.

if you mean how to set them then look at the documented example

https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_expansion

https://www.mql5.com/en/docs/objects/objectgetdouble

Documentation on MQL5: Object Functions / ObjectGetDouble
Documentation on MQL5: Object Functions / ObjectGetDouble
  • www.mql5.com
ObjectGetDouble - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Paul Anscombe #:

you are not being clear, none of your code is getting the price values from the object.

try looking at ObjectGetDouble.

Hi.Thank you for your answer.

I tried the following code but i cannot get the  property of the fibo levels..

The 

OBJPROP_PRICE

returns the prices from Expansion lines. i also tried OBJPROP_LEVELVALUE but i get zero return.

Can you see what i am doing wrong?

void OnTick()
    {   
     
    ObjectDelete(0,Symbol());
    
   datetime time1,time2,time3;
   double price1,price2,price3;
   int chart_ID= 0;
   string name = Symbol();
   double fib_values[13]={0.0,.236,.382,.500,.550,.618,.786,1.000,1.272,1.411,1.618,2.618,4.236};

   time1 = iTime(NULL,0,3);
   time2 = iTime(NULL,0,2);
   time3 = iTime(NULL,0,1);
   
   price1 = iLow(Symbol(),NULL,3);
   price2 = iHigh(Symbol(),NULL,2);
   price3 = iLow(Symbol(),NULL,1);
   
       if(!ObjectCreate(chart_ID,name,OBJ_EXPANSION,0,time1,price1,time2,price2,time3,price3)) Print("error");
     
     ObjectSetInteger(chart_ID,name,OBJPROP_LEVELS,13);
   for(int i=0;i<13;i++)
     {
      ObjectSetDouble(chart_ID,name,OBJPROP_LEVELVALUE,i,fib_values[i]);
      ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,"FE "+DoubleToString(100*fib_values[i],1));
          

         
  
     Print(fib_values[i]," ",ObjectGetDouble(chart_ID,name,OBJPROP_PRICE,fib_values[i]));
      
     }
       ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,Magenta);
       ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,STYLE_SOLID);
       ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,1);
       ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,False);



 

     }
 
Ioannis Christopoulos #:

Hi.Thank you for your answer.

I tried the following code but i cannot get the  property of the fibo levels..

The 

returns the prices from Expansion lines. i also tried OBJPROP_LEVELVALUE but i get zero return.

Can you see what i am doing wrong?

use an integer for the level you require not the value of the level.

ObjectGetDouble(chart_ID,name,OBJPROP_PRICE,fib_values[i]))