MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
MetaTrader Market: we have 650 Expert Advisors for algorithmic trading!

EA for Opening and Closing Multiple Orders at the same time

Back to topics list To post a new topic, please log in or register
avatar
123
mrchuckw 2011.04.13 23:26
 

Does anyone know of a free ea that will open a buy order with one pair, and a sell order for another pair at the same time?

And also close the two orders at the same time when the right time comes?

For example: I am overlaying two charts... (could be any two charts, like EURUSD /CHFJPY, or GBPJPY/USDJPY etc..)

When I visually see an entry point, I want to have the ea instantly open apposing orders at the lot size I specify.

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

When I visually see an exit point, I want to have the ea close the two orders at the same time.

Anything out there like that?

MrChuck

 
FANN2MQL Neural Network Tutorial
FANN2MQL Neural Network Tutorial
Julien | 26 november 2009, 09:54
This article has been made to show you how to use neural networks, via FANN2MQL, using an easy example: teaching a simple pattern to the neuralnetwork, and testing it to see if it can recognize patterns it has never seen.
avatar
438
forexCoder 2011.04.14 02:41 #
 
Not free since it's a very specific task that you'd like to the EA to perform, but not difficult to create as it doesn't really need any logic to it, just a simple task. I'm sure some1 will be willing to help you out with it.
 
avatar
791
Ickyrus 2011.04.14 04:20 #
 

You could modifiy the Trade Script shown below

//+------------------------------------------------------------------+
//|                                                        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()
  {
//----
   if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price?    ",
                 "Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----
   int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,CLR_NONE);
   if(ticket<1)
     {
      int error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      return;
     }
//----
   OrderPrint();
   return(0);
  }
//+------------------------------------------------------------------+

make two of these one for buy situation and one for sell and get the script to send two trades

for example

//+------------------------------------------------------------------+
//|                                                        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()
  {
//----
   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);
//----
   int ticket=OrderSend("EURUSD",OP_BUY,1.0,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;
     }
//----
   int ticket=OrderSend("USDCHF",OP_SELL,1.0,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);
  }
//+------------------------------------------------------------------+

Not tested above example

 
avatar
123
mrchuckw 2011.04.14 05:29 #
 

OK... I need help with it. I started writing my own ea... but I am a newbie at Forex, and MT4 programing.

Right now I'm stuck on how to reference the price of the overlay data. where it plots on the chart, is not what the actual price is.

But I need to know how to reference, in my ea code, the price that is showing on the chart... not the actual price.

Any ideas.?

 
avatar
40
sty671 2011.04.14 16:07 #
 

can someone help me edit sar ohlc to use heiken ashi ohlc

Hi, I have an MTF indicator that uses sar, however I'd like the sar to calculate heiken ashi ohlc, and not the normal type

Can you tell me how I can do this, my mtf indicator calls to the sar indicator to calculate sar formula, I think it is calling to the internal indicator in mt4 that can not edit

you can skype or email if you can assist and like to talk about it

skype sty671

email sty671@gmail.com

I can also supply the original file that I'm trying to use heiken ashi ohlc for

 
avatar
9806
WHRoeder 2011.04.14 18:14 #
 
sty671:

can someone help me edit sar ohlc to use heiken ashi ohlc

http://forum.mql4.com/40270#460867
avatar
123
mrchuckw 2011.04.16 03:29 #
 
Ickyrus:

You could modifiy the Trade Script shown below

make two of these one for buy situation and one for sell and get the script to send two trades

for example

Not tested above example


OK... I've been working with this one. I cant get it to open both positions... it only opens the one for the chart that is open at the time.

Am I missing something? Is there a way to have it open both, and then stick around to close both at the same time with the push of one button?

 
avatar
791
Ickyrus 2011.04.16 05:01 #
 

Sorry there is a small error which occured because of the speed of reply it lies in the "Ask" and The "Bid" prices.

You need the Ask and Bid price of the alternate currency otherwise the OrderSend will reject the order.

To get the price of a symbol/currency pair not belonging to the chart you are using (i.e off chart) use:-

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

so modifying my previous suggestion we get

//+------------------------------------------------------------------+
//|                                                        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);
  }
//+------------------------------------------------------------------+

The above (not tested) should place a BUY on the currency pair EUR/USD and a SELL on currency pair USD/CHF and should not care what chart you place the script on.

If you use Symbol() then you are using the default currency pair of the chart you place the script on and the Ask and Bid prices will be those of the Chart you are using - please accept my appology for the stupid error.

 
Back to topics list  

To add comments, please log in or register