about saving location of the objects

 

Hello, everyone. 

I want to write a good EA for my purposes.  

 I create an object:

      ObjectCreate("[I]", OBJ_BITMAP, 0, X_TopRight(140), Y_TopRight());

      ObjectSetString(0, "[I]", OBJPROP_BMPFILE, "Imn.bmp");

      ObjectSet("[I]", OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);      

      ObjectSetInteger(0, "[I]", OBJPROP_SELECTABLE, true);              

   At location:


datetime X_TopRight(int fidge)  

   {

      return (Time[fidge - 10]);   

   }


double Y_TopRight() 

   {

      double   top=WindowPriceMax();

      double   bottom=WindowPriceMin();

      return (top - 0.8*(top-bottom));  

   }

 

And this works perfectly. However, the location is restarted, if I restart EA. So, I need somehow save location of object, then load it back with EA.  

 

I'm kind of sure that I have to create a .set file for saving all the data. But is there way to do it?

How can I save location of each object? How can I get location of each object? How do I back up location of each object? 

Is there some kind of command like

objectGetLocation then object SetLocation

?  

    

 

Why would you save objects layout if you can leave the objects on the chart?

void OnDeinit(const int reason)

The reason tells you why the EA resets. Clean the objects only if your EA gets detached. On the other hand, do not move objects when ObjectCreate fails (the object is already there).

 

I don't understand. My deint is empty:

void OnDeinit(const int reason){

   Print("deint happen");

 

However, if I stop a EA, or restart MT4, all the data disappears and when I start EA all the Objects are on the same spot. 

 

(Also I would like some objects show up on H4 and on H1 and some objects to show up only on H1. I made that and they reflect each other, however restarting the EA just removes all the objects)

 
Neither I understand. What makes them disappear if not you?
 
jkmaks:

I don't understand. My deint is empty:

void OnDeinit(const int reason){

   Print("deint happen");

 hello,

 

MetaTrader calls OnDeinit and passes "reason". So you have to write  Print(reason);

 

beset regards 

 
jkmaks: however restarting the EA just removes all the objects)

  1. Not possible. If your EA doesn't delete them, they stay there.
  2. If you also remove any indicators (by restarting the terminal) then they could call  ObjectsDeleteAll - Object Functions - MQL4 Reference and are the deleters
 
I'm such a dumbass, I was starting it through metaeditor. 
Reason: