Certainly does with 1045.
{
string text="";
//---
switch(reasonCode)
{
case REASON_ACCOUNT:
text="Account was changed";break;
case REASON_CHARTCHANGE:
text="Symbol or timeframe was changed";break;
case REASON_CHARTCLOSE:
text="Chart was closed";break;
case REASON_PARAMETERS:
text="Input-parameter was changed";break;
case REASON_RECOMPILE:
text="Program "+__FILE__+" was recompiled";break;
case REASON_REMOVE:
text="Program "+__FILE__+" was removed from chart";break;
case REASON_TEMPLATE:
text="New template was applied to chart";break;
default:text="Another reason";
}
//---
Print("reason text ", text);
return text;
}
{
GlobalVariableSet("AskDistanceTemp", AskDistance);
GlobalVariableSet("OrderSpacingTemp", OrderSpacing);
GlobalVariableSet("ProfitLevelTemp", ProfitLevel);
GlobalVariableSet("LossLevelTemp", LossLevel);
GlobalVariableSet("LotTemp", Lot);
GlobalVariableSet("LotStepTemp", LotStep);
GlobalVariableSet("ArithmeticOrGeometricTemp", ArithmeticOrGeometric);
GlobalVariableSet("NestTemp", Nest);
}
macpee:
I mean changing a chart to the current chart when there are several of them. I do not mean changing chart periodicity. I hope I am right. By the way when is the following example code meant to execute. What is sopposed to call it. |
|
|
Third and last time, your code is not reasonable, because it is not running, because you don't call it, because you didn't understand the documentation.
I have done a little research on this Initialization thing and I have modified the program and it is now running.
extern string enter = "STRING"; void init(){ //void OnInit(){ int reas; reas = UninitializeReason(); getUninitReasonText(reas); } string getUninitReasonText(int reasonCode) { string text=""; //--- switch(reasonCode) { case REASON_ACCOUNT: //Prints even when EA is not attached to the current chart. Does not print when trying to change to the current EA text="Account was changed";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ", REASON_ACCOUNT);break; case REASON_CHARTCHANGE: //Prints only when EA is on current chart text="Symbol or timeframe was changed";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ",REASON_CHARTCHANGE);break; case REASON_CHARTCLOSE: //Prints only when EA is on closed chart text="Chart was closed";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ",REASON_CHARTCLOSE);break; case REASON_PARAMETERS: //Prints only when the input parameters section of the input parameter window is viewed //(even without changing any parameter) and OK clicked text="Input-parameter was changed";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ",REASON_PARAMETERS);break; case REASON_RECOMPILE: //Prints even if EA is not on current chart text="Program "+__FILE__+" was recompiled";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ",REASON_RECOMPILE);break; case REASON_REMOVE: //Prints fine text="Program "+__FILE__+" was removed from chart";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ",REASON_REMOVE);break; case REASON_TEMPLATE: text="New template was applied to chart";Print("reason text ", text, ", Uninit Number ", UninitializeReason(), " Check Number ",REASON_TEMPLATE);break; // default:text="Another reason"; } //--- return text; }
My concern is why there is no inclusion of REASON_PROFILE for change of profile.
It seems to stand between REASON_CHARTCHANGE and REASON_ACCOUNT yet no inclusion of it. It is between these two because chart is changed within the same profile and profile is changed within the same account. Now I need it to solve a certain problem.
You ask why I need it? I am developing an EA where a part of the task is to input trading parameters via the parameter window and allow the use of such parameters in other profiles, unless such parameters are changed in those profiles.
I will first have to save those parameters to global variables (Immediately it is input in the parameter window, using REASON_PARAMETER in the conditional statement) , then get the values of the global variables in other profiles.
You are asking where the REASON_PROFILE comes in? Ok see, it comes in because I need to get the trading parameters from the global variables immediately a profile is changed, and not wait until a new tick arrives.
By so doing those parameters can be made use of (say showing them on some chart objects) even without the EA connected, and without clicking at any button.
NOTE that I can perform this task with REASON_ACCOUNT and REASON_CHARTCHANGE and with any other reason that there is in the documentation for MT4.
- www.mql5.com
Third and last time, your code is not reasonable, because it is not running, because you don't call it, because you didn't understand the documentation.
An idea on how to go about it, for which you may come in, is as follows:
Since changing a profile entails closing all charts (REASON_CHARTCHANGE) in the outgoing profile and opening profile (initialization) in the current profile, an idea is to code the EA by asking that
if (UninitializeReason() == REASON_CHARTCLOSE && init())
{
blah blah blah;
}
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use