EA Issues with Order Filling Modes for DJ30 Symbol

 

Subject: Issues with Order Filling Modes for DJ30 Symbol

Hello MQL5 Community,

I'm currently developing an Expert Advisor (EA) for trading the DJ30 symbol on MetaTrader 5. My EA needs to handle different order filling modes, and I want to ensure that it correctly supports the filling modes allowed for DJ30.

I've come across the following filling modes:

  1. Immediate or Cancel (IOC): Executes as much of the order as possible immediately, and cancels the remaining part if it can't be filled.
  2. Fill or Kill (FOK): Either fills the entire order immediately or cancels it.
  3. Return: For market or limit orders, processes the remaining volume if partially filled.

However, I'm experiencing issues with "unsupported filling mode" errors from my broker when trying to place orders.

 Here is a snippet of my current code:

  // Set the filling mode to FOK
            request.type_filling = ORDER_FILLING_FOK;

I've verified the filling modes using the following function:

bool IsFillingTypeAllowed(string symbol, int fill_type)
{
   int filling = (int)SymbolInfoInteger(symbol, SYMBOL_FILLING_MODE);
   return ((filling & fill_type) == fill_type);
}

Despite this, I still encounter errors with certain brokers. Could anyone provide insights or share experiences on handling filling modes, specifically for DJ30, across different brokers? Any advice on best practices or potential code adjustments would be greatly appreciated.

Thank you in advance for your help!




 

Have you looked at the specifications of that symbol (this is for Gold as I don't have DJ30):


Talk to your broker.

 
Carl Schreiber #:

Have you looked at the specifications of that symbol (this is for Gold as I don't have DJ30):


Talk to your broker.

thanks for your answer
where can I find this filling menu that specifies the filling methode


also another question is can an EA work with other symbols beside FOREX?
you mentioned you are working with Gold may i ask what symbol do you use?
 

Select the symbol in the Market Watch => right mouse klick for the context menu => click on Specification:


 
hello, anyone who can help me to correct only two errors please for EA ERRORS AT NUMBER 1&2, HERE IS THE CODE:  #include <MetaTrader5/MetaTrader5.mqh>
#include <string>

int OnInit()
{
    // Check the program type
    if(MQLInfoInteger(MQL_PROGRAM_TYPE) != PROGRAM_EXPERT)
    {
        Print("Error: This program is not an expert advisor.");
        return(INIT_FAILED);
    }

    // Print account information
    double balance = AccountInfoDouble(ACCOUNT_BALANCE);
    double equity = AccountInfoDouble(ACCOUNT_EQUITY);
    double margin = AccountInfoDouble(ACCOUNT_MARGIN);

    Print("Account Balance: ", balance);
    Print("Account Equity: ", equity);
    Print("Account Margin: ", margin);

    return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
    // Add any cleanup code here
}

void OnTick()
{
    // Retrieve the current market data
    MqlRates curr_rates[];
    int rates_count = CopyRates(Symbol(), Period(), 0, 1, curr_rates);
    if(rates_count != 1)
    {
        Print("Error: Failed to get current market data.");
        return;
    }

    // Implement your trading logic here
    if(curr_rates[0].close > curr_rates[0].open)
    {
        // Buy order
        MqlTradeRequest request = {};
        MqlTradeResult result = {};

        request.action = TRADE_ACTION_DEAL;
        request.symbol = Symbol();
        request.volume = 0.1;
        request.type = ORDER_TYPE_BUY;
        request.deviation = 5;

        if(!OrderSend(request, result))
        {
            Print("Error: Failed to place buy order. Error code: ", GetLastError());
        }
        else
        {
            Print("Buy order placed successfully. Order ticket: ", result.order);
        }
    }
    else
    {
        // Sell order
        MqlTradeRequest request = {};
        MqlTradeResult result = {};

        request.action = TRADE_ACTION_DEAL;
        request.symbol = Symbol();
        request.volume = 0.1;
        request.type = ORDER_TYPE_SELL;
        request.deviation = 5;

        if(!OrderSend(request, result))
        {
            Print("Error: Failed to place sell order. Error code: ", GetLastError());
        }
        else
        {
            Print("Sell order placed successfully. Order ticket: ", result.order);
        }
    }
}
 
Njabulo Mbuso Sibiya #:
hello, anyone who can help me to correct only two errors please for EA ERRORS AT NUMBER 1&2, HERE IS THE CODE:  #include <MetaTrader5/MetaTrader5.mqh>
#include <string>                                                      


just delete these lines. You don't need them.

replace with this:
#include <Trade.mqh>
 
 I'd suggest you maybe use the CTrade class as there's way too much code doing essentially the same thing rather ineffectively

This is assuming this is mql5 code, and if you don't understand something a certain class does you can just open the .mqh file easy available on your computer