43 lines
2.2 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| VZ_TogglePause.mq5 — hotkey switch for the profitgtx entry pause |
| |||
//| |
| |||
//| Flips a terminal global variable that RiskGuardsAllowEntry() |
| |||
//| checks first on every entry attempt (RiskGuards.mqh). Open |
| |||
//| positions keep being managed; only new entries / re-entries stop.|
| |||
//| |
| |||
//| Bind to a key: Navigator -> Scripts -> right-click -> Set hotkey.|
| |||
//| Drop two copies (Scope 0 and 1) if you want both on hotkeys. |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "VizionAI"
| |||
#property version "1.00"
| |||
#property script_show_inputs
| |||
#property description "Toggle profitgtx new-entry pause (this symbol or all charts)."
| |||
| |||
enum ENUM_VZ_PAUSE_SCOPE { SCOPE_THIS_SYMBOL = 0, SCOPE_ALL_CHARTS = 1 };
| |||
input ENUM_VZ_PAUSE_SCOPE Scope = SCOPE_THIS_SYMBOL; // what to pause / resume
| |||
input bool Force_State = false; // true: set to Value instead of toggling
| |||
input bool Value = true; // used only with Force_State
| |||
| |||
void OnStart()
| |||
{
| |||
string key = (Scope == SCOPE_ALL_CHARTS) ? "VZ_PAUSE_ALL" : ("VZ_PAUSE_" + _Symbol);
| |||
bool cur = GlobalVariableCheck(key) && GlobalVariableGet(key) > 0.0;
| |||
bool next = Force_State ? Value : !cur;
| |||
| |||
if(next)
| |||
GlobalVariableSet(key, 1.0);
| |||
else if(GlobalVariableCheck(key))
| |||
GlobalVariableDel(key);
| |||
| |||
// Show what is in force now, both scopes, so a single key press is unambiguous.
| |||
bool all_paused = GlobalVariableCheck("VZ_PAUSE_ALL") && GlobalVariableGet("VZ_PAUSE_ALL") > 0.0;
| |||
string sym_key = "VZ_PAUSE_" + _Symbol;
| |||
bool sym_paused = GlobalVariableCheck(sym_key) && GlobalVariableGet(sym_key) > 0.0;
| |||
| |||
string msg = "profitgtx entries: " + (next ? "PAUSED" : "RESUMED") + " [" + key + "]"
| |||
+ " | all=" + (all_paused ? "paused" : "live")
| |||
+ " | " + _Symbol + "=" + (sym_paused ? "paused" : "live");
| |||
Print(msg);
| |||
Alert(msg);
| |||
}
| |||
//+------------------------------------------------------------------+
|