Questions from Beginners MQL4 MT4 MetaTrader 4 - page 264

 

Hello,

 

I am new to Metatrader. I would like to test run a simple code for EURUSD.

 

At 08:00m on a Wednesday, if the previous Monday was an up day (i.e close 24:00 >open 00:00), then buy 1 contract. If the previous Monday was a down day, then sell 1 contract.

At 20:00, close the position.

 

Repeat for Thursday.

If the previous Tuesday was an up day (i.e close 24:00 >open 00:00), then buy 1 contract. If the previous Tuesday was a down day, then sell 1 contract.

At 20:00, close the position.

 

Can you assist here?

 

Thank you.

CC

 
czap1 #: Can you assist here?

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. (2004)
          Prune pointless queries.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Try asking at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017)

 
William Roeder #:

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. (2004)
          Prune pointless queries.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Try asking at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017)

Hello William, thank you for your helpful comments. As said, I am new to metatrader. I have previously used excel VB forums where programmers helped me with building an application. Clearly this is not the case here. I will try the 'coding help' and 'Freelancer' links that you provided.
 

I have written an MQL4 Expert Advisor code: It should open a BUY position, if the EMA12 crosses above the EMA28, and then a SELL position, when the EMA12 crosses below the EMA28. EMA values are rounded to 5 decimals. It examines this condition at the close of every 1 minute candle. Only one BUY and one SELL should be traded, so I used a flag variable to achieve that. When EMA12 gets equal to EMA28, it is also considered a crossing. The EA should only operate from a begin time. This is only a test code, so instead of trade orders, only alert messages are sent. When I compile the code and run it on MT4, it does not work! It should give an alert message at the beginning of every minute "one minute has passed", but it does not do that. It should also give an alert message on BUY and SELL, but it does not do that! Why is that? Please, help!

Refer to "GDAX EMA Cross[26,12] by stefano89" indicator on TradingView, since this EA was inspired by and should work like that indicator.

Here is the code, which I have written:

//+------------------------------------------------------------------+
//|                                           EMA_12_26_crossing.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
extern datetime BeginTime = D'2023.05.25 17:01:00'; // trading should begin at this time; only one cross up and one cross down of EMA12 and EMA28 should be traded afterwards
extern double BaseATRMultiplier = 3; // these are not used in current probe version
extern double StopATRMultiplier = 1.15; // these are not used in current probe version
extern double ProfitATRMultiplier = 2.05; // these are not used in current probe version

int OnInit()
  {  
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+

// This expert advisor should only be started when the EMA12 is below the EMA28; an opposite expert advisor should be written and used for the other case

void OnTick()
  {

    static bool SignalForBuy = false; // this is a flag to track if there has already been and upward EMA crossing; we use this to make sure we only trade one such crossing
    static bool SignalForSell = false; // this is a flag to track if there has already been and downward EMA crossing; we use this to make sure we only trade one such crossing
    double ExponentialMovingAverage12[2];
    double ExponentialMovingAverage28[2];
    static datetime OneMinuteCandleTime = BeginTime;
 
       if (TimeCurrent() >= BeginTime)
   
          {

            if(OneMinuteCandleTime != iTime(Symbol(),PERIOD_M1,0)) // new candle on the 1 minute timeframe
            
               {
                                                       
                     Alert("One minute has passed.");
                     OneMinuteCandleTime = iTime(Symbol(),PERIOD_M1,0);
         
                     ExponentialMovingAverage12[1] = NormalizeDouble(iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,1),5);
                     ExponentialMovingAverage12[2] = NormalizeDouble(iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,2),5);
                     ExponentialMovingAverage28[1] = NormalizeDouble(iMA(NULL,0,28,0,MODE_EMA,PRICE_CLOSE,1),5);
                     ExponentialMovingAverage28[2] = NormalizeDouble(iMA(NULL,0,28,0,MODE_EMA,PRICE_CLOSE,2),5);
   
                     
                     if (SignalForBuy == false) // if there has't been an upward EMA crossing, we will trade; we only want to trade the first downward crossing
         
                         {

                              if (ExponentialMovingAverage12[2] - ExponentialMovingAverage28[2] < 0 && ExponentialMovingAverage12[1] - ExponentialMovingAverage28[1] >= 0 )
                  
                               {
              
                                     SignalForBuy = true;  // we set this to "true", so that only one upward EMA crossing is traded
                                     Alert("We will BUY at this time.");
                     
                               }
                  
                         }  
          
       
                     if (SignalForSell == false) // if there has't been a downward EMA crossing, we will trade; we only want to trade the first upward crossing
         
                         {

                              if ((ExponentialMovingAverage12[2] - ExponentialMovingAverage28[2] > 0 && ExponentialMovingAverage12[1] - ExponentialMovingAverage28[1] <= 0 ) || (ExponentialMovingAverage12[2] - ExponentialMovingAverage28[2] == 0 && ExponentialMovingAverage12[1] - ExponentialMovingAverage28[1] < 0 ))
                  
                               {
              
                                     SignalForSell = true; // we set this to "true", so that only one downward EMA crossing is traded
                                     Alert("We will SELL at this time");
                       
                               }
                  
                         }
             
    
    
               }

   
          }
      
      
  }
 

Dear friends,

i'm a new MT4 user and i would like to know if P2P (peer-to-peer) was possible on a market (OTHER than cryptocurrencies ones).

I mean : i would like to buy 10000 Yen to my friend Kenzo for only 50 euros. Is this trade possible if we use the same broker and same interface (MT4) ?

Or, maybe, can it be done on another exchange market, not necessary the EURJPY.

Can i answer to a trade if i know the # of the order ? Ex : 96852160

Any method for P2P exchange is welcome.

Thanks for all


 
Hi ,  i need your help on this.  please see attachment below. the chart of EU did not updated as expected for some time frames. then i go to Tools=>History center. I see some data is not updated, it is "jumped". after i delete the new data, it works fine for time frame M1,M5..., it will update as usual. but, this is not happened to time frame D1 (the chart looks so strange ... ).
Please look at image: the data of date 20-07-2023 is moved to the right ...  , and this cause the candles only shown up at top of chart ...
as we can see at other image, the data in history center is actually there ....
and if i add moving averages lines there, it seems that there is other data with zero (0) value ???
how to solve this ?
thank you in advance ...
 

Good day.

Please recommend high quality education program to learn programming on MQL4.

Thank you. 

 
Hello, I'm working on a custom indicator. It has some parameters that the user can configure. I also want to be able to control some parameters from the program, based on other parameter combinations that the user chooses. For this reason I'm using extern variables, not input variables. When I programmatically change the value of a parameter (extern variable), I don't see the change in the indicator configuration window. Is there any way to change the behavior so that the parameter value that's being displayed in the indicator configuration window actually reflects the value of the extern variable?

I've spent a couple of hours searching for some way to do this but can't find any. Someone wrote that there is a one way communication between the indicator configuration window and the extern variables. A user can update the extern variables via the window, but a program can't update the values in the window (except at startup of the indicator, I guess). Is this true?

Below are some code snippets and an attached pic of the indicator configuration window. Any help would be greatly appreciated.

extern string Overall_Settings_PPW = "-------------------------"; //--- Overall Settings -------------------
extern string ExtSymbol_PPW = "EURUSD";             // Symbol
extern bool inverted_PPW = false;                   // Invert lines
extern ENUM_APS_CONTROL_MODE APS_Ctrl_Mode_PPW = APS_ALL_MAGAPOP;  // Alternative Parameters Control Mode
//extern bool Use_Compile_Override_Params_PPW = true; // Use compile time values for input parameters
extern bool UseBaseColor_PPW = true;                // Use same color for all lines
extern color BaseColor_PPW = Red;                 // Base Color
// extern parameter_set paramSet_PPW = PPW_VALUES;         // Main source of configuration parameters

// Indicator line settings 

// Price Line
extern string Price_Line_Settings_PPW = "-------------------------"; //--- Price Line Settings ----------------
extern bool Show_Price_Line_PPW = true;             // Show Price Line
extern ENUM_APS Show_Price_Line_APS_PPW = NONE;          // Show Price Line (APS)
extern color Price_Line_Color_PPW = Red;                    // Price Line Color
extern ENUM_LINE_STYLE Price_Line_Style_PPW = STYLE_SOLID;                // Price Line Style
extern ENUM_APS Price_Line_Style_APS_PPW = NONE;                // Price Line Style (APS)
extern int Price_Line_Width_PPW = 3;                          // Price Line Width
extern ENUM_APS Price_Line_Width_APS_PPW = NONE;                          // Price Line Width (APS)

// MA Line (MA = Moving Average)
extern string MA_Line_Settings_PPW = "-------------------------"; //--- MA Line Settings -------------------

int OnInit()
{

   if (UseBaseColor_PPW)
   {
      Price_Line_Color_PPW = BaseColor_PPW;
      MA_Line_Color_PPW = BaseColor_PPW;
      Zero_Start_MA_Line_Color_PPW = BaseColor_PPW;
      PO_Line_Color_PPW = BaseColor_PPW;
      MAPC_Line_Color_PPW = BaseColor_PPW;
      MAGAPO_Line_Color_PPW = BaseColor_PPW;
   }
Files:
 
Hi guys, i have a simple technical indicator i created for MT4 using MQL4. I thought i followed all the guidelines to properly upload it to the CodeBase, but it is not letting me move forward to complete the process. Excuse me if the question is totally newbie, but how do i get the code fully uploaded into the codebase so that i can share it with people/community? This screenshot was taken when i was on step 1, but i've tried a couple times and i can get to step 4, but every time i get to step 4, i can't move forward. There is nothing i can do, it just sits there. I can't share the link to the file or anything. Please lemme know. Thanks!
 

Hi - I use MT4 platform and am having                   


Hi - new to the MT4 platform.  I'll try to be concise and precise.

After loading all my pairs, a grey Account Information rectangle appeared

in the upper left corner of my charts.

I can't find a way to close it - I don't want it to show at all.

Also, as shown in the attached photo, the information is scrunched up

and unreadable.  If I could see it clearly, it might be useful.

So:  1) how do I close the Account Information box, and

       2) how do I un-scrunch the data in the box?

Thanks for any help!

Scott

Files:
Reason: