Ea that will open a buy order with one pair, and a sell order for another pair at the same time

 

Dear all,

I'm trying to developing ea that will open a buy order with one pair, and a sell order for another pair at the same time?

For example: I am overlaying two charts  EUR/USD and USD/CHF

When I visually see an entry point, I want to have the ea instantly open apposing orders at the lot size I specify: BUY 1.0 lot on the currency pair EUR/USD and a SELL 2.2 lot on currency pair USD/CHF.

(I need to be able to choose which one is long, and which one is short)

I found a piece of code but it's from mt4.

Can anyone help me convert it to mt5?

Please give me a help

Thank you very much

//+------------------------------------------------------------------+
//|                                                        trade.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "trading for all money"                                   |
//+------------------------------------------------------------------+
int start()
  {

   double alt_bid ;
   double alt_ask ;

//----
   if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price?    ", //stops accidental order placement
                 "Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);

   alt_bid = MarketInfo("EURUSD",MODE_BID);
   alt_ask = MarketInfo("EURUSD",MODE_ASK);

//----
   int ticket=OrderSend("EURUSD",OP_BUY,1.0,alt_ask,3,0,0,"expert comment",255,0,CLR_NONE); //Specific Currency pair must match broker's Symbol
   if(ticket<1)
     {
      int error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      return;
     }
//----
   alt_bid = MarketInfo("USDCHF",MODE_BID);
   alt_ask = MarketInfo("USDCHF",MODE_ASK);

   int ticket=OrderSend("USDCHF",OP_SELL,1.0,alt_bid,3,0,0,"expert comment",255,0,CLR_NONE); //Specific Currency pair must match broker's Symbol
   if(ticket<1)
     {
      int error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      return;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
  • www.mql5.com
Trade Orders in DOM - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Do not double post!

I have deleted your duplicate topic.

 
Keith Watford #:

Do not double post!

I have deleted your duplicate topic.

Im sorry :(
 
Le Quoc Tuan:

Dear all,

I'm trying to developing ea that will open a buy order with one pair, and a sell order for another pair at the same time?

For example: I am overlaying two charts  EUR/USD and USD/CHF

When I visually see an entry point, I want to have the ea instantly open apposing orders at the lot size I specify: BUY 1.0 lot on the currency pair EUR/USD and a SELL 2.2 lot on currency pair USD/CHF.

(I need to be able to choose which one is long, and which one is short)

I found a piece of code but it's from mt4.

Can anyone help me convert it to mt5?

Please give me a help

Thank you very much

29 errors when you compile in MQL5, mainly around MarketInfo and OrderSend- its some effort to go through each one, but not that hard really to look up the MQL5 equivalents and change the statements.

Are you a programmer?