Download MetaTrader 5
To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
jkmaks
36
jkmaks 2016.04.04 10:18 

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

?  

    

Ovo Cz
2956
Ovo Cz 2016.04.04 10:47  

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).

jkmaks
36
jkmaks 2016.04.04 15:16  

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)

Ovo Cz
2956
Ovo Cz 2016.04.04 15:24  
Neither I understand. What makes them disappear if not you?
Demos Stogios
184
Demos Stogios 2016.04.04 16:29  
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 

whroeder1
13597
whroeder1 2016.04.04 18:24  
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
jkmaks
36
jkmaks 2016.04.05 04:28  
I'm such a dumbass, I was starting it through metaeditor. 
/
To add comments, please log in or register