Download MetaTrader 5

ObjectCreate OBJ_FIBO (problem MOVE)

To add comments, please log in or register
fly7680
636
fly7680  

Hello, I have created the Fibonacci object without problems, but at each new Bar, the coordinates slip automatically forward of a Bar. I also inserted ObjectMove but it does not work.


if(Count2==48){  

   // coordinate Fibo                                                              
   ObjectCreate     ("Fibo",OBJ_FIBO,0,Time[K],iCustom(0,0,"Heiken Ashi",3,K),Time[K],High[K]);
   ObjectCreate     ("N"+Y,OBJ_TEXT,0, Time[K],iCustom(0,0,"Heiken Ashi",1,K+100*Point));
   ObjectSetString(0,"N"+Y,OBJPROP_TEXT,Numero[Y]); 
   ObjectSet        ("N"+Y,OBJPROP_FONTSIZE,12); 
   ObjectSet        ("N"+Y,OBJPROP_COLOR,White);
   // property Fibo
   ObjectSet("Fibo",OBJPROP_RAY,true );
   ObjectSet("Fibo",OBJPROP_BACK,true);
   ObjectSet("Fibo",OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("Fibo",OBJPROP_FIBOLEVELS,  6);
   ObjectSet("Fibo",OBJPROP_FIRSTLEVEL+0,0.000);
   ObjectSet("Fibo",OBJPROP_FIRSTLEVEL+1,1.000);
   ObjectSet("Fibo",OBJPROP_FIRSTLEVEL+2,1.427);
   ObjectSet("Fibo",OBJPROP_FIRSTLEVEL+3,4.236);
   ObjectSet("Fibo",OBJPROP_FIRSTLEVEL+4,-1.382);
   ObjectSet("Fibo",OBJPROP_FIRSTLEVEL+5,8.472);
   ObjectSetFiboDescription ("Fibo", 0, "0.0");
   ObjectSetFiboDescription ("Fibo", 1, "100");
   ObjectSetFiboDescription ("Fibo", 2, "142.7");
   ObjectSetFiboDescription ("Fibo", 3, "423.6");
   ObjectSetFiboDescription ("Fibo", 4, "Stop");
   ObjectSetFiboDescription ("Fibo", 5, "847.2");
   // Moving Fibo
   ObjectMove(0,"Fibo",K,Time[K],High[K]);
  // forced chart redraw
   ChartRedraw(current_chart_id);

}
                                    
                                                                     
                                  
whroeder1
15925
whroeder1  

fly7680:

but at each new Bar, the coordinates slip automatically forward of a Bar.

I also inserted ObjectMove but it does not work.

  1. You created the object, nothing is going to change. Do you mean you want to automatically move it?
  2.    ObjectCreate     ("Fibo",OBJ_FIBO,0,Time[K],iCustom(0,0,"Heiken Ashi",3,K),Time[K],High[K]);
       :
       ObjectMove(0,"Fibo",K,Time[K],High[K]);
    A Fib has two coordinates. Coordinate 0 is your Time[K],Heiken price[K], and coordinate 1 is Time[K],High[K]. There is no coordinate K, so of course "it doesn't work." You would know that had you bothered to check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
fly7680
636
fly7680  
I would like Fibo's coordinates to remain unchanged and not move, so I thought I would leave K.
Fibo moves to each new candle forward, while I would like it to always stay at the first coordinate.
whroeder1
15925
whroeder1  
You created the object, nothing is going to change unless you move it or delete and recreate it.
To add comments, please log in or register