Compiled script of Graphical Object not visible

 

Hello,

I have compiled a script without any errors for a graphical object (see attached file 'research grafobjects.txt').

But the graphical object is not visible on the graph I load it on. My journal displays messages that 1) it loaded successfully the script on graph, and 2) it was removed (the same second).

I am reading on graphical objects with 1)  Creating Graphical Objects and Changing Their Properties, 2) Deleting Graphical Objects, and 3) Modifying Graphical Objects. 

How can I keep the object on the graph, so that it doesn't get removed immediately?

Thank you for your help. 

Files:
 
zeno1:

Hello,

I have compiled a script without any errors for a graphical object (see attached file 'research grafobjects.txt').

But the graphical object is not visible on the graph I load it on. My journal displays messages that 1) it loaded successfully the script on graph, and 2) it was removed (the same second).

deinit() is called when the script finishes,  and what does deinit() do in your script ?  yep,  deletes the Object . . .

ObjectDelete("Label_Obj_MACD");
 
RaptorUK:

deinit() is called when the script finishes,  and what does deinit() do in your script ?  yep,  deletes the Object . . .

 

 


I took out the deinit() section. Now I can see the 1-time result. In the Journal, I still see that the Object is removed as before though ...

Would you suggest to write a different deinit() section? I'm in the process of studying this ...

I'm making a similar exercise with Modifying Graphical Objects. But in this case, after canceling (graying out) the deinit section, the object does not appear on the chart? Why does it in the 1st case but not in this one? I attach file 'research_moveobjects.txt'.

Thanks so much. 

Files:
 
zeno1:


I took out the deinit() section. Now I can see the 1-time result. In the Journal, I still see that the Object is removed as before though ...

Would you suggest to write a different deinit() section? I'm in the process of studying this ...

I'm making a similar exercise with Modifying Graphical Objects. But in this case, after canceling (graying out) the deinit section, the object does not appear on the chart? Why does it in the 1st case but not in this one? I attach file 'research_moveobjects.txt'. 


It looks like your Object is drawn at a price of 0.0 . . .  so is off sccren,  try drawing it at current price, i.e.  Bid
 

I changed the following line in section 6-7 of file 'research_moveobjects.txt':

   ObjectCreate("Obj_Reg_Ch",OBJ_REGRESSION,0,T1,Bid,T2,Ask);// Creation

With F1 I saw the prices location of ObjectCreate and changed 0 of t1 and t2 to Bid and Ask. 

However, still no line/object appears on the chart? 

 

Not sure what you are doing . . . I tried your code (with the Bid & Ask change) and it works fine . . .

The code . . .

//--------------------------------------------------------------------
// moveobjects.mq4
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
extern int   Len_Cn=50;              // Channel length (bars)
extern color Col_Cn=Orange;          // Channel color
//--------------------------------------------------------------- 1 --
int init()                             // Special function init()
  {
   Create();                           // Calling user-def. func. of creation
   return;                             // Exit init()
  }
//--------------------------------------------------------------- 2 --
int start()                            // Special function start()
  {
   datetime T2;                        // Second time coordinate
   int Error;                          // Error code
//--------------------------------------------------------------- 3 --   
   T2=ObjectGet("Obj_Reg_Ch",OBJPROP_TIME2);// Requesting t2 coord.
   Error=GetLastError();               // Getting an error code
   if (Error==4202)                    // If no object :(
     {
      Alert("Regression channel is being managed",
            "\n Book_expert_82_2. deletion prohibited.");
      Create();                        // Calling user-def. func. of creation
      T2=Time[0];                      // Current value of t2 coordinate
     }
//--------------------------------------------------------------- 4 --
   if (T2!=Time[0])                    // If object is not in its place
     {
      ObjectMove("Obj_Reg_Ch", 0, Time[Len_Cn-1],0); //New t1 coord.
      ObjectMove("Obj_Reg_Ch", 1, Time[0],       0); //New t2 coord.
      WindowRedraw();                  // Redrawing the image  
     }
   return;                             // Exit start()
  }
//--------------------------------------------------------------- 5 --
/*            //ETI: cancel deinit
int deinit()                           // Special function deinit()
  {
   ObjectDelete("Obj_Reg_Ch");         // Deleting the object
   return;                             // Exit deinit()
  }
*/            //ETI: cancel deinit
//--------------------------------------------------------------- 6 --
int Create()                           // User-defined function..
  {                                    // ..of object creation
   datetime T1=Time[Len_Cn-1];         // Defining 1st time coord.
   datetime T2=Time[0];                // Defining 2nd time coord.
   ObjectCreate("Obj_Reg_Ch",OBJ_REGRESSION,0,T1,Bid,T2,Ask);// Creation
   ObjectSet(   "Obj_Reg_Ch", OBJPROP_COLOR, Col_Cn);    // Color
   ObjectSet(   "Obj_Reg_Ch", OBJPROP_RAY,   false);     // Ray
   ObjectSet(   "Obj_Reg_Ch", OBJPROP_STYLE, STYLE_DASH);// Style
   ObjectSetText("Obj_Reg_Ch","Created by the EA moveobjects",10);
   WindowRedraw();                     // Image redrawing 
  }
//--------------------------------------------------------------- 7 --

 the result . . .

 

 

It's working. 

Cheers! 

Reason: