Hello everybody! Please advise the utility (expert Advisor or something else 🙂 to enable or disable the “Automatic trading” button in MT4 on a schedule ( by the hour within the day) with the ability to set this-the schedule itself, of course. The point is that not every expert Advisor has such a function ( work on a schedule), and I want to turn on the adviser exactly when it is necessary. Already “steamed up” to look in the Internet, something I can not find anything. Maybe, who knows… Thanks !Â
Share
egran
For, myself, Yes. Thank you for your answers. I will delve into it!
vdev
If you download AutoIt for yourself, and not in the Market, it’s easy to click on anything on the screen.
if(CheckForNewOrder(Symbol(), cmd))
    {
        if(cmd == 0)
            AU3_MouseClick("LEFT", CallX, CallY);
        else
            AU3_MouseClick("LEFT", PutX, PutY);       Â
    }
alexeyvik
Metaeditor is a text editor that can compile code into an executable file. (unlike Notepad). You can open an existing code or write a new one in it, and the format will be automatic. mq4 or mq5, depending on the terminal and your desire.
The instruction can be opened in the Metaeditor itselfÂ
egran
Eugene, do I understand correctly that the code should be placed in a file in Metaeditor and saved as an expert Advisor?
Only in what format to create a file? I tried everything, nothing works ))Â
Is there a place to read the instructions?
genino
This is the adviser. You don’t need to turn anything.
ssv-11
How do I make this code work?
nuolin
Thanks for the answer. Just sorry for the lack of enlightenment, maybe this branch is for initiates and I, being not from that caste, did not get there, but I do not understand programming, I can only use advisors. I, as an option, found a semi-automatic solution: I created my own MT4 profile for each day of the week, in which the necessary trading hours are enabled for each tab of the trading instrument, and the unnecessary ones are disabled. It remains only at the junction of the day to manually switch to the profile corresponding to the coming day of the week. And, as an option to fully automate this process, if possible, an expert Advisor for automatically switching to a given profile on a given day of the week and at a given time would help.
am2
Today just asked to do the same almost plus the closure of all positions:
#define VK_CONTROL 0x11 //CTRL key
#define KEY_CODEÂ Â 'E'
#import "user32.dll"
void  keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo);
#import
#include
//Object of the CTrade class
CTrade trade;
/ / Object of the CPositionInfo class
CPositionInfo position;
input int StartHour = 9;
input int StopHour  = 23;
//+------------------------------------------------------------------+
//| Expert initialization function                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//|Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
//+------------------------------------------------------------------+
void Key()
  {
  keybd_event(VK_CONTROL,0,0,0);
  Sleep(10);
  keybd_event(KEY_CODE,0,0,0);
  Sleep(10);
  keybd_event(KEY_CODE,0,2,0);
  Sleep(10);
  keybd_event(VK_CONTROL,0,2,0);
  }
//+------------------------------------------------------------------+
//|Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
//+------------------------------------------------------------------+
bool TimeSession(int aStartHour,int aStartMinute,int aStopHour,int aStopMinute,datetime aTimeCur)
  {
/ / - - - session start time
int StartTime=3600*aStartHour+60*aStartMinute;
/ / - - - session end time
int StopTime=3600*aStopHour+60*aStopMinute;
/ / - - - current time in seconds from the beginning of the day
  aTimeCur=aTimeCur%86400;
  if(StopTime// - - - going through midnight
      if(aTimeCur>=StartTime || aTimeCurreturn(true);
        }
    }
  else
    {
      / / - - - within one day
      if(aTimeCur>=StartTime && aTimeCurreturn(true);
        }
    }
  return(false);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                            |
//+------------------------------------------------------------------+
void OnTick()
  {
/ / closing by time
if(!TimeSession(StartHour,0,StopHour,0,TimeCurrent()))
    {
      for(int i=0; i<PositionsTotal(); i++)
        {
        if(position.Select(PositionGetSymbol(i)))
          {
            / / close an open position for this symbol
            trade.PositionClose(PositionGetSymbol(i));
          }
        }
    }
/ / enabling by time
if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)==0 & & TimeSession(StartHour,0, StopHour,0,TimeCurrent())) Key();
/ / disable by time
if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)==1 && !TimeSession(StartHour,0,StopHour,0,TimeCurrent())) Key();
  Comment("
Enable: ",TerminalInfoInteger(TERMINAL_TRADE_ALLOWED),
          "
Time: ",TimeCurrent());
  }
//+------------------------------------------------------------------+
vdev
I remembered)
And it was proposed to do all this in the mind, a task for concentration and memory
svalex
yeah…Advisor for managing advisors… so soon they will start looking for an Advisor to manage advisors by managing advisors…ugh..
nuolin
And there is such EA which can in the settings
another EA to put/remove a tick “to use the EA
trade”, that is, that the EA is trading off not at all
terminal button (Autotrading) and certain pairs (tabs) on a specified schedule. Does anyone know if there’s anything anywhere that matches this description?
dken
write to me in kaplickou doing such, you need to stipulate the details of the desired functionality
imelam
🙂 The problem is that I do not know this language. Before that, I studied a little javascript and use… Therefore, you need a utility or that someone wrote the code 🙂
mikalas
In order to stop trading, it is not necessary to click on the button.
Write a schedule in the expert Advisor and disable it according to this schedule.
void OnTick()
{
  if ( stop_trading ) return;
  //Your code....
}