//+------------------------------------------------------------------+ //| Charter.mq5 | //| Copyright 2026, MasterOfPuppets | //| https://forge.mql5.io/masterofpuppets/mql5 | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Includes | //+------------------------------------------------------------------+ #include #include #include #include #include #include "Action.mqh" //+------------------------------------------------------------------+ //| Properties | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, MasterOfPuppets" #property description "Multi-Chart Analytical Engine" #property link "https://forge.mql5.io/masterofpuppets/mql5" #property version "1.00" //+------------------------------------------------------------------+ //| Inputs | //+------------------------------------------------------------------+ input group "Action keys" MASTER_OF_PUPPETS_ACTION_KEY_MAPPINGS(MASTER_OF_PUPPETS_LIB_GENERATE_INPUT) //+------------------------------------------------------------------+ //| Variables | //+------------------------------------------------------------------+ Actions actions; string actionsUsage; int periodIndex = 4; int periods[11] = { PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_H8, PERIOD_H12, PERIOD_D1, PERIOD_W1, PERIOD_MN1 }; CSymbolInfo symbolInfo; bool tradeHistoryEnabled; //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int32_t id, const long &lparam, const double &dparam, const string &sparam) { if(id != CHARTEVENT_KEYDOWN) { return; } Action action = (Action) actions.GetAction(lparam); switch(action) { MASTER_OF_PUPPETS_ACTION_KEY_MAPPINGS(MASTER_OF_PUPPETS_LIB_GENERATE_CASE) } } //+------------------------------------------------------------------+ //| On decrease period function | //+------------------------------------------------------------------+ void OnDECREASE_PERIOD(const Action action) { ChangePeriod(action); } //+------------------------------------------------------------------+ //| On increase period function | //+------------------------------------------------------------------+ void OnINCREASE_PERIOD(const Action action) { ChangePeriod(action); } //+------------------------------------------------------------------+ //| On set period M1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_M1(const Action action) { SetPeriod(PERIOD_M1); } //+------------------------------------------------------------------+ //| On set period M5 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_M5(const Action action) { SetPeriod(PERIOD_M5); } //+------------------------------------------------------------------+ //| On set period M15 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_M15(const Action action) { SetPeriod(PERIOD_M15); } //+------------------------------------------------------------------+ //| On set period M30 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_M30(const Action action) { SetPeriod(PERIOD_M30); } //+------------------------------------------------------------------+ //| On set period H1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_H1(const Action action) { SetPeriod(PERIOD_H1); } //+------------------------------------------------------------------+ //| On set period H4 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_H4(const Action action) { SetPeriod(PERIOD_H4); } //+------------------------------------------------------------------+ //| On set period H8 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_H8(const Action action) { SetPeriod(PERIOD_H8); } //+------------------------------------------------------------------+ //| On set period H12 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_H12(const Action action) { SetPeriod(PERIOD_H12); } //+------------------------------------------------------------------+ //| On set period D1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_D1(const Action action) { SetPeriod(PERIOD_D1); } //+------------------------------------------------------------------+ //| On set period W1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_W1(const Action action) { SetPeriod(PERIOD_W1); } //+------------------------------------------------------------------+ //| On set period MN1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_MN1(const Action action) { SetPeriod(PERIOD_MN1); } //+------------------------------------------------------------------+ //| On set period H1 default function | //+------------------------------------------------------------------+ void OnSET_PERIOD_H1_DEFAULT(const Action action) { SetPeriod(PERIOD_H1); } //+------------------------------------------------------------------+ //| On set period H1 1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_H1_1(const Action action) { SetPeriod(PERIOD_H1); } //+------------------------------------------------------------------+ //| On set period D1 1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_D1_1(const Action action) { SetPeriod(PERIOD_D1); } //+------------------------------------------------------------------+ //| On set period W1 1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_W1_1(const Action action) { SetPeriod(PERIOD_W1); } //+------------------------------------------------------------------+ //| On set period MN1 1 function | //+------------------------------------------------------------------+ void OnSET_PERIOD_MN1_1(const Action action) { SetPeriod(PERIOD_MN1); } //+------------------------------------------------------------------+ //| On show trade history function | //+------------------------------------------------------------------+ void OnSHOW_TRADE_HISTORY(const Action action) { tradeHistoryEnabled = !tradeHistoryEnabled; ChartSetInteger(0, CHART_SHOW_TRADE_HISTORY, tradeHistoryEnabled); } //+------------------------------------------------------------------+ //| Change period function | //+------------------------------------------------------------------+ void ChangePeriod(const Action action) { SynchronizePeriodIndex(); switch(action) { case Action::DO_DECREASE_PERIOD: periodIndex--; if(periodIndex < 0) { periodIndex = (int) periods.Size() - 1; } break; case Action::DO_INCREASE_PERIOD: periodIndex++; if(periodIndex >= (int) periods.Size()) { periodIndex = 0; } break; } ChartSetSymbolPeriod(0, _Symbol, (ENUM_TIMEFRAMES) periods[periodIndex]); } //+------------------------------------------------------------------+ //| Synchronize period index with current chart period | //+------------------------------------------------------------------+ void SynchronizePeriodIndex() { for(int i = 0; i < (int) periods.Size(); i++) { if(periods[i] == _Period) { periodIndex = i; return; } } } //+------------------------------------------------------------------+ //| Set period function | //+------------------------------------------------------------------+ void SetPeriod(const ENUM_TIMEFRAMES enumTimeframes) { ChartSetSymbolPeriod(0, _Symbol, enumTimeframes); } //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if(!symbolInfo.Name(_Symbol)) { return(INIT_FAILED); } InitActions(); if(!IsKeyMappingCorrect(actions)) { return(INIT_PARAMETERS_INCORRECT); } actionsUsage = actions.Usage(); Comment(actionsUsage); Print(actionsUsage); SynchronizePeriodIndex(); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Actions initialization function | //+------------------------------------------------------------------+ void InitActions() { actions.Clear(); MASTER_OF_PUPPETS_ACTION_KEY_MAPPINGS(MASTER_OF_PUPPETS_LIB_GENERATE_ADD_ACTION) } #include #undef MASTER_OF_PUPPETS_ACTION_KEY_MAPPINGS //+------------------------------------------------------------------+