EA that shows all charts in MW one by one

 
//+------------------------------------------------------------------+
//|                                                      DR_EA_1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
string Papeis[]={
"PETR4",
"VVAR3",
"OFSA3",
"POMO3",
"UCAS3",
"ETER3",
"FRAS3",
"PINE4",
"TASA3"
};

string CODNEG="";
int OnInit()
  {
  


for(int i=0; i<143;i++) {
Sleep(3000);
CODNEG=Papeis[i];

   if(!ChartSetSymbolPeriod(ChartID(), CODNEG, PERIOD_D1))
     {
      Print("Error:" + GetLastError());
// Error: 0
     }
}
   return(INIT_SUCCEEDED);   
  }
  

void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+

Friends, I made this code to go quickly through all stocks of interest. Have a look of 3 seconds in each one.

For some of them I would like to make a pause, for example by hitting space or clicking the chart. So the EA stops, I look more carefully then, it continues showing the charts of the next stocks in the list.

How can I do this ?

Thanks!

 
douglas14: I would like to make a pause,
  1. What happens when your posted code i becomes 8?

  2. Show us your code where you check for a space or a click? Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

 
douglas14 :

Friends, I made this code to go quickly through all stocks of interest. Have a look of 3 seconds in each one.

For some of them I would like to make a pause, for example by hitting space or clicking the chart. So the EA stops, I look more carefully then, it continues showing the charts of the next stocks in the list.

How can I do this ?

Thanks!

There are no pauses: clicking on the chart causes the symbol to change:

//+------------------------------------------------------------------+
//|                                             Scrolling Charts.mq5 |
//|                              Copyright © 2020, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Vladimir Karputov"
#property link      "https://www.mql5.com"
#property version   "1.00"
//--- service keys IDs
#define KEY_NUMPAD_5       12
#define KEY_LEFT           37
#define KEY_UP             38
#define KEY_RIGHT          39
#define KEY_DOWN           40
#define KEY_NUMLOCK_DOWN   98
#define KEY_NUMLOCK_LEFT  100
#define KEY_NUMLOCK_5     101
#define KEY_NUMLOCK_RIGHT 102
#define KEY_NUMLOCK_UP    104
//--- input parameters
input int      Input1=9;
//---
string   arr_symbols[3] = {"AUDUSD","USDJPY","EURUSD"};
int      m_last_index   = -1;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- left-clicking on a chart
   if(id==CHARTEVENT_CLICK)
     {
      int arr_size=ArraySize(arr_symbols);
      int index=m_last_index+1;
      if(index>=arr_size)
         index=0;
      if(ChartSetSymbolPeriod(0,arr_symbols[index],PERIOD_D1))
         m_last_index=index;
     }
  }
//+------------------------------------------------------------------+


Result:

  

Files: