How to return price value after EA restart.
I want to do this:
There is a line on the chart, I get price from it. After Ea restart I want this line get back in that price, which it was before restart.
Can I do this without saving the price in the file?
If can't do, so how to save it to file, that doesn't overwrite prices, because this EA will be in more than one file.
Thank you.
I face to one problem, if I delete this line in deinit() function, after deletion, my global variable gets 0 value.
double test; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- ObjectCreate("Entry", OBJ_HLINE, 0,0,test ); ObjectSet("Entry", OBJPROP_COLOR, Green); // Color ObjectSet("Entry", OBJPROP_RAY, true); // Ray //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("Entry"); //If I add this line: when EA restarts, global variable "test" gets value 0. //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- double EntryPrice; EntryPrice=ObjectGet("Entry",OBJPROP_PRICE1); string value=DoubleToStr(EntryPrice, Digits); EntryPrice=NormalizeDouble(StrToDouble(value),Digits); string pav="Eggo_"+Symbol(); test=GlobalVariableSet(pav , EntryPrice); //---- return(0); } //+------------------------------------------------------------------+
Can I do this without saving the price in the file?
- IF the terminal is properly shutdown and restarted (and options -> Charts -> keep personal settings,) then the line will be there on a restart.
- IF the terminal is properly shutdown and restarted, "You could use a GlobalVariable to save the price value." and it will be there on a restart. Sorry RaptorUK.
- IF the terminal is NOT properly shutdown, you can't assume the latest value will be there. You must write a file (persistent storage) when anything saved has changed, each time.
ObjectDelete("Entry"); //If I add this line: when EA restarts, global variable "test" gets value 0.
string pav="Eggo_"+Symbol(); test=GlobalVariableSet(pavYou have a Global Variable Eggo_EURUSD and a globally declared variable that you never initialize
double test; int init(){ ObjectCreate("Entry", OBJ_HLINE, 0,0,test );
I face to one problem, if I delete this line in deinit() function, after deletion, my global variable gets 0 value.
I want to do this:
There is a line on the chart, I get price from it. After Ea restart I want this line get back in that price, which it was before restart.
Can I do this without saving the price in the file?
If can't do, so how to save it to file, that doesn't overwrite prices, because this EA will be in more than one file.
Thank you.