- Close By - Trade - MetaTrader 5 for Android
- Close By - Trade - MetaTrader 5 for iPhone
- Request Execution - Opening and Closing Positions - Trade - MetaTrader 5 for iPhone
- You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button)
and state the nature of your problem.
No free helpOr pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum - Since Brokers use a variety of time zones, You have to have inputs to specify what you need.
- You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button)
and state the nature of your problem.
No free helpOr pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum - Since Brokers use a variety of time zones, You have to have inputs to specify what you need.
I will tell you the truth William Roeder.
Opening the reply messages and seeing that you write such a thing is truly starving. No help or advice is refused to anyone ... never. If I had asked for the whole code I could understand your reaction, but I only asked a question: it is likely that someone had the same problem and if I give some indication I will solve it myself.
I reply so because you did the same thing on another recent post. You didn't give anything just things that I already knew and that didn't explain how to solve. You probably live on this, ok I understand it. BUT THE NEXT TIME, YOU AVOID ENTERING IN DISCUSSIONS IF YOU DON'T WANT TO HELP.
Anyway, do me a courtesy; in the future, when you read a message posted by me, do not write anything, do not reply, because of your help = zero I don't know what to do with it.
post your "code" if you need help.
Here is a demo Expert Advisor to close all positions, 5 minutes before Friday 10 pm GMT (Forex close time)
//+------------------------------------------------------------------+ //| FridayCloseExpert.mq5 | //| Copyright © 2018, Amr Ali | //| https://www.mql5.com/en/users/amrali | //+------------------------------------------------------------------+ #property copyright "Copyright © 2018, Amr Ali" #property link "https://www.mql5.com/en/users/amrali" #property version "1.000" #property description "project description." //--- Includes #include <Trade\Trade.mqh> #include <Trade\PositionInfo.mqh> //--- CTrade m_trade; // trading object CPositionInfo m_position; // position info object //--- Input parameters | input bool InpFridayCloseTrades = false ; // FridayCloseTrades input string InpFridayCloseTimeGMT = "21:55" ; // FridayCloseTimeGMT //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- initialize common information m_trade.SetAsyncMode(true); m_trade.SetDeviationInPoints(INT_MAX); m_trade.SetMarginMode(); m_trade.LogLevel(LOG_LEVEL_ERRORS); //--- Initialization completed successfully return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(InpFridayCloseTrades && PositionsTotal() > 0 && FridayTimeIsActive()) { CloseAllPositions(); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool FridayTimeIsActive() { MqlDateTime dt; datetime gmtTime = TimeGMT(dt); datetime endTime = StringToTime(TimeToString(gmtTime,TIME_DATE) + " " + InpFridayCloseTimeGMT); if(dt.day_of_week==(ENUM_DAY_OF_WEEK)FRIDAY && gmtTime >= endTime) { return(true); } return(false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseAllPositions() { //--- close market positions for(int i=PositionsTotal()-1; i>=0 && !IsStopped(); i--) { if(m_position.SelectByIndex(i)) { //--- trading object m_trade.SetExpertMagicNumber(m_position.Magic()); m_trade.SetTypeFillingBySymbol(m_position.Symbol()); //--- close positions if(m_trade.PositionClose(m_position.Ticket()) && (m_trade.ResultRetcode()==TRADE_RETCODE_DONE || m_trade.ResultRetcode()==TRADE_RETCODE_PLACED)) PrintFormat("Position #%I64u on %s to be closed",m_position.Ticket(),m_position.Symbol()); else PrintFormat("> Error closing position #%I64u on %s (%s)",m_position.Ticket(),m_position.Symbol(),m_trade.ResultComment()); } } } //+------------------------------------------------------------------+
Here is a demo Expert Advisor to close all positions, 5 minutes before Friday 10 pm GMT (Forex close time)
Thanks amrali, you have been very kind.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use