Need Help For My EA

 
Hello,

I need a program for MQL4 EA which is certainly not difficult, but
which may complicate when it comes to the relationship between 2 platform,
a demo account and live account.

A summary of the EA I'm looking to program:

Platform demo account:

Open trades one by one in this order:

Buy
Buy
Buy

Sale
Sale
Sale

Buy
Buy
Buy

Sale
Sale
Sale

Buy
etc. ...

and that as the expert advisor is enabled

Real Account Platform:



If (the last 3 trades are winning and if the final closed position was a Buy
position)
{
open Sell position on my real account
}

If (the last 3 trades are winning and
if the final closed position was a Sell position)
{
open Buy position on my real account
}

I am trading with 2 account metatrader, a virtual account and a real account.


Do you think it is possible to do that???

I need help for doing this script.


Thank you

 
anzaisensei:
Hello,

I need a program for MQL4 EA which is certainly not difficult, but
which may complicate when it comes to the relationship between 2 platform,
a demo account and live account.

A summary of the EA I'm looking to program:

Platform demo account:

Open trades one by one in this order:

Buy
Buy
Buy

Sale
Sale
Sale

Buy
Buy
Buy

Sale
Sale
Sale

Buy
etc. ...

and that as the expert advisor is enabled

Real Account Platform:



If (the last 3 trades are winning and if the final closed position was a Buy
position)
{
open Sell position on my real account
}

If (the last 3 trades are winning and
if the final closed position was a Sell position)
{
open Buy position on my real account
}

I am trading with 2 account metatrader, a virtual account and a real account.


Do you think it is possible to do that???

everything is possible in this century

I need help for doing this script.

no problem show your code


Thank you

 
anzaisensei:
Hello,

I need a program for MQL4 EA which is certainly not difficult, but
which may complicate when it comes to the relationship between 2 platform,
a demo account and live account.

A summary of the EA I'm looking to program:

Platform demo account:

Open trades one by one in this order:

Buy
Buy
Buy

Sale
Sale
Sale

Buy
Buy
Buy

Sale
Sale
Sale

Buy
etc. ...

and that as the expert advisor is enabled

Real Account Platform:



If (the last 3 trades are winning and if the final closed position was a Buy
position)
{
open Sell position on my real account
}

If (the last 3 trades are winning and
if the final closed position was a Sell position)
{
open Buy position on my real account
}

I am trading with 2 account metatrader, a virtual account and a real account.


Do you think it is possible to do that???

I need help for doing this script.


Thank you


i have good experience with following system (if both run in the same pc)

Plattform a write some Command to registry f.e. somthing like "Buy Now EurUsd"

Plattform b read the registry, if find the correct command - fullfill the command and delete registry entry

brgds, EADeveloper

 

The Demo account EA could write instructions to a File for the real account EA to follow.

So the Demo account EA would write to a file "BUY" or "SELL" or "LEAVE"

The Live account will read the file, after a small pause, and then remove either the "BUY" or "SELL" instruction replace these words with the instruction "LEAVE" and then place the Order as required.

 

Hello,

Sorry for the late answer i did ot receive the

email notification from the forum.

Thank you for your help.


It open one by one positions but only for

one symbol. I mean if it open one trade to

EUR/USD, when the trade close the next

trade will open with another symbol like GBP/USD.


The first thing i want to do is to open the

positions one by one for all symbol separely.

If EUR/USD position is open, when it close another

EUR/USD trade will open and the gbp/usd will

open only if the first trade with gbp/usd was close.


thank you for your help.


I have the follow script for my EA :

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
extern bool  isTradeLong = true;
extern int   tradesInRow = 3;
extern int   stoploss = 15;
extern int   takeprofit = 25;
extern double lot = 0.1;

int magic = 20110307;
int buy_counter = 0;
int sell_counter = 0;
bool first = true;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
  return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
  return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   
   if (first) {
      if (isTradeLong) {
         openLong(Symbol(), Ask, Bid, Point);
      } else {
          openShort(Symbol(), Ask, Bid, Point);
        }
      first = false;
   }
 
   if(OrdersTotal() == 0) {
     if (buy_counter == 0 && (sell_counter > 0 && sell_counter < tradesInRow)) {
         openShort(Symbol(), Ask, Bid, Point);
         return(0);
     }
     if (buy_counter == tradesInRow) {
         openShort(Symbol(), Ask, Bid, Point);   
         buy_counter = 0;
         return(0);
     }
     if (sell_counter == 0 && (buy_counter > 0 && buy_counter < tradesInRow)) {
         openLong(Symbol(), Ask, Bid, Point);
         return(0);
     }
     if (sell_counter == tradesInRow) {
         openLong(Symbol(), Ask, Bid, Point);   
         sell_counter = 0;
         return(0);
     }         
   }

   return(0);
}

//------------------------------------------------------------------------- 

void openLong(string sym, double ask, double bid, double pip) {

   double sl,tp;

   if (stoploss == 0) sl = 0; else sl = bid - stoploss*pip;
   if (takeprofit == 0) tp = 0; else tp = ask + takeprofit*pip;
   RefreshRates();   
   OrderSend(sym, OP_BUY, lot, ask, 3, sl, tp, "", magic, Blue);   
   Sleep(1000);
   RefreshRates();
   
   buy_counter++;
   
   return;
}

void openShort(string sym, double ask, double bid, double pip) {
   double sl,tp;

   if (stoploss == 0) sl = 0; else sl = ask + stoploss*pip;
   if (takeprofit == 0) tp = 0; else tp = bid - takeprofit*pip;
   RefreshRates();
   OrderSend(sym, OP_SELL, lot, bid, 3, sl, tp, "", magic, Red);   
   Sleep(1000);
   RefreshRates();
  
   sell_counter++;
   
   return;
}
Reason: