Home Forums MT4/MT5 Connection How to connect MT5 strategy with AlgoDelta’s Custom Bridge?

How to connect MT5 strategy with AlgoDelta’s Custom Bridge?

  • Author
    Posts
    • At present, I am running and executing my strategy in MT5.

      Now what I want is that whenever a Buy or Sell signal comes from MT5, the order should be executed in the Futures contracts through AlgoDelta.

      Is this possible? If yes, how can I set it up?

    • Yes sir, you can definitely do that with AlgoDelta.

      For this, you can use either the Custom Bridge or the JSON Bridge.

      For simplicity, let’s take the example of the Custom Bridge.

      Step 1:

      Go to the Custom Bridge page and create a Custom Bridge if you don’t already have one.

      Step 2:

      Configure the Upside Execution.

      Example:

      Exchange: NFO

      Symbol: NIFTY

      Product: Carry Forward

      Script Type: Future

      Order Lot: 1

      Expiry Gap: 0

      Transaction Type: Buy

      Exit on Opposite Signal: Enable (Optional)

      Click on Submit.

      Step 3:

      Similarly, configure the Downside Execution according to your requirements.

      Step 4:

      Copy the webhook URL.

      You can find it using the yellow copy icon either from the Custom Bridge listing page or from inside the Custom Bridge itself.

      Step 5:

      Now open MT5 and whitelist the webhook URL.

      Go to:

      Tools -> Options -> Expert Advisors

      Enable:

      “Allow WebRequest for listed URL”

      Click on the green “+” button and paste your webhook URL.

      Click OK.

      Note: This setup works through Expert Advisors because only EAs can make WebRequest calls.

      Step 6:

      Open your strategy code in MetaEditor and add the following function:

      string StrategyUrl = "Webhook URL";
      void SendSignalToWebhook1(string signal_side) {
          Print(signal_side);
          string headers = "Content-Type: text/plain\r\n";
          char post[], result[];
          int timeout = 20000;
          StringToCharArray(signal_side, post, 0, StringLen(signal_side));
          ResetLastError();
          int res = WebRequest( "POST", StrategyUrl, headers, timeout, post, result, headers );
          if (res == -1) {
              Print("WebRequest Error: ", GetLastError());
          } else {
              Print("Webhook Response: ", CharArrayToString(result));
          }
      }

      Step 7:

      Now call this function whenever your strategy generates a signal.

      For Upside Execution:

      SendSignalToWebhook1(“UP”);

      For Downside Execution:

      SendSignalToWebhook1(“DOWN”);

      Example Buy Condition:

      bool breakoutBuy = ema1 > ema2;
      if(breakoutBuy)
      {
         SendSignalToWebhook1("UP");
         trade.Buy( LotSize, _Symbol, 0, S1, R1 + (R1 - P), "Breakout Buy" );
         Print("BUY BREAKOUT");
      }
      

      Example Sell Condition:

      bool breakoutSell = ema2 > ema1;
      if(breakoutSell)
      {
         SendSignalToWebhook1("DOWN");
         trade.Sell( LotSize,  _Symbol, 0, R1, S1 - (P - S1), "Breakout Sell" );
         Print("SELL BREAKOUT");
      }
      

      That’s it.

      Now whenever your MT5 strategy sends: “UP” the configured Upside Execution in AlgoDelta will be triggered. “DOWN” the configured Downside Execution in AlgoDelta will be triggered.

      So, your MT5 strategy can continue generating signals, while AlgoDelta handles the actual order execution according to the configuration you’ve set in the bridge.

    • Thanks for the answer, sir. This is exactly what I am looking for and with the images and detailed explanation it’s super easy to understand.

Viewing 2 reply threads
×

Start a Discussion

Get help from the AlgoDelta community.

×

Welcome Back!

Enter your email to sign in or create an account. No passwords needed.

Pending Approval

⚠️

Delete This?

Are you sure you want to delete this? This action is permanent and cannot be undone.

Scroll to Top