Modify and EA

Big Dog.mq4.zip (1.94 KB)

Hello everyone,
I’ve found a very good expert advisor which, if well modified can made a lot of pips.
The EA is called Big Dog, and unfortunately I can’t find who made it.
The EA is quite easy you just put a time box and he took the low and the high and put a sell order under the low and a buy order over the high, so as you understood is a brake-out EA.
The only problem is that it hasn’t a lot of features.
It has:

First Take Profit
Second Take Profit
Trailing Stop
Use Stop Loss (yes or no)
Stop Loss
Lots
Slippage
WindowStart
WindowEnd
Use Money Management (yes or no)
Account Is Micro (yes or no)
Risk

Now… the second stop loss don’t work, would be good to fix it… and I would like to add:

first take profit 30%
second take profit 30%
third take profit 30%
fourth take profit 10%
at each take profit reach move stop loss to the previous one.
BE automatically
orders 3 or 4 pips over/under the high/low
Delate opposite orders when take profit is hit

If we can modify this EA with this features I can guarantee that putting the time 07/09 gmt with the pairs EURUSD, GBPUSD, AUDUSD, NZDUSD, USDCHF, USDCAD we can have really nice profits and if the first take profit is low at 15pips, is almost always hit.
You can google big dog brake-out.
If anyone is interested and know how to modify this EA please comment, would be a great help for everyone.
Have a nice day!

Here is the code:

//±-----------------------------------------------------------------+
//| Big Dog.mq4 |
//| Copyright © 2008, LEGRUPO |
//| legrupo.com |
//| Version: 1.0 |
//| History: |
//| 1.0 => Release version to the public |
//±-----------------------------------------------------------------+
#property copyright “Copyright © 2008, LEGRUPO”
#property link “http://www.legrupo.com
//±-----------------------------------------------------------------+
//| EX4 imports |
//±-----------------------------------------------------------------+
#include <stderror.mqh>
#include <stdlib.mqh>

//---- input parameters
extern int ExpertID = 458388;
extern int FirstTakeProfit=30;
extern int SecondTakeProfit=50;
extern int TrailingStop=0;
extern bool useStopLoss = true;
extern int StopLoss=30;
extern double Lots=5.0;
extern int Slippage = 3;

extern int WindowStart = 11;
extern int WindowEnd = 13;

extern bool UseMoneyManagement = false;
extern bool AccountIsMicro = false;
extern int Risk = 10; // risk in percentage % (10% of risk in this case)
int MagicNumber = 0;

//±-----------------------------------------------------------------+
//| expert initialization function |
//±-----------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//±-----------------------------------------------------------------+
//| expert deinitialization function |
//±-----------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//±-----------------------------------------------------------------+
//| expert start function |
//±-----------------------------------------------------------------+
int start()
{
//----
MagicNumber = MakeMagicNumber();
if(UseMoneyManagement==true) {
Lots = DefineLotSize(); //Adjust the lot size total
}

if (Hour() >= WindowStart || Hour() <= WindowEnd) {
ObjectDelete(“WindowStart-horas”);
ObjectDelete(“WindowEnd-horas”);
double day_open = iOpen(Symbol(),PERIOD_H1,0);
datetime data8 = StrToTime(TimeYear(TimeCurrent())+"."+TimeMonth(TimeCurrent())+"."+TimeDay(TimeCurrent())+" “+WindowStart+”:00");
datetime data10 = StrToTime(TimeYear(TimeCurrent())+"."+TimeMonth(TimeCurrent())+"."+TimeDay(TimeCurrent())+" “+WindowEnd+”:00");
ObjectCreate(“WindowStart-horas”,OBJ_VLINE,0,data8, day_open);
ObjectSet(“WindowStart-horas”, OBJPROP_COLOR, Pink);
ObjectCreate(“WindowEnd-horas”,OBJ_VLINE,0,data10, day_open);
ObjectSet(“WindowEnd-horas”, OBJPROP_COLOR, Pink);
}
if (Hour() == WindowEnd && Minute() == 15) {
ObjectDelete(“high”);
ObjectDelete(“low”);
double high = High[iHighest(Symbol(),0,MODE_HIGH,9,0)];
ObjectCreate(“high”,OBJ_HLINE,0,0, high);
ObjectSet(“high”, OBJPROP_COLOR, Pink);

  double low = Low[iLowest(Symbol(),0,MODE_LOW,9,0)];
  ObjectCreate("low",OBJ_HLINE,0,0, low);
  ObjectSet("low", OBJPROP_COLOR, Pink);
  int ticket = 0;
  datetime expire = StrToTime("23:59");
  
  int distance = 0;
  if (Digits == 2) {
     distance = (high - low)*100;
  } else {
     distance = (high - low)*10000;
  }
  if (distance &gt;= 50) {
     return(0);
  }
  
  if (CountLongs(MagicNumber) == 0 && CountShorts(MagicNumber) == 0) {
     ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,high,Slippage,low,high+FirstTakeProfit*Point,WindowExpertName(),MagicNumber,expire,CLR_NONE);
     ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,high,Slippage,low,high+SecondTakeProfit*Point,WindowExpertName(),MagicNumber,expire,CLR_NONE);
     ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,low,Slippage,high,low-FirstTakeProfit*Point,WindowExpertName(),MagicNumber,expire,CLR_NONE);
     ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,low,Slippage,high,low-SecondTakeProfit*Point,WindowExpertName(),MagicNumber,expire,CLR_NONE);
  }

}
//----
return(0);
}
//±-----------------------------------------------------------------+
int MakeMagicNumber()
{
int SymbolCode = 0;
int PeriodCode = 0;
int MagicNumber = 0;

//---- Symbol Code
if( Symbol() == “AUDCAD” || Symbol() == “AUDCADm” ) { SymbolCode = 1000; }
else if( Symbol() == “AUDJPY” || Symbol() == “AUDJPYm” ) { SymbolCode = 2000; }
else if( Symbol() == “AUDNZD” || Symbol() == “AUDNZDm” ) { SymbolCode = 3000; }
else if( Symbol() == “AUDUSD” || Symbol() == “AUDUSDm” ) { SymbolCode = 4000; }
else if( Symbol() == “CHFJPY” || Symbol() == “CHFJPYm” ) { SymbolCode = 5000; }
else if( Symbol() == “EURAUD” || Symbol() == “EURAUDm” ) { SymbolCode = 6000; }
else if( Symbol() == “EURCAD” || Symbol() == “EURCADm” ) { SymbolCode = 7000; }
else if( Symbol() == “EURCHF” || Symbol() == “EURCHFm” ) { SymbolCode = 8000; }
else if( Symbol() == “EURGBP” || Symbol() == “EURGBPm” ) { SymbolCode = 9000; }
else if( Symbol() == “EURJPY” || Symbol() == “EURJPYm” ) { SymbolCode = 1000; }
else if( Symbol() == “EURUSD” || Symbol() == “EURUSDm” ) { SymbolCode = 1100; }
else if( Symbol() == “GBPCHF” || Symbol() == “GBPCHFm” ) { SymbolCode = 1200; }
else if( Symbol() == “GBPJPY” || Symbol() == “GBPJPYm” ) { SymbolCode = 1300; }
else if( Symbol() == “GBPUSD” || Symbol() == “GBPUSDm” ) { SymbolCode = 1400; }
else if( Symbol() == “NZDJPY” || Symbol() == “NZDJPYm” ) { SymbolCode = 1500; }
else if( Symbol() == “NZDUSD” || Symbol() == “NZDUSDm” ) { SymbolCode = 1600; }
else if( Symbol() == “USDCAD” || Symbol() == “USDCADm” ) { SymbolCode = 1700; }
else if( Symbol() == “USDCHF” || Symbol() == “USDCHFm” ) { SymbolCode = 1800; }
else if( Symbol() == “USDJPY” || Symbol() == “USDJPYm” ) { SymbolCode = 1900; }

//---- Calculate MagicNumber
MagicNumber = ExpertID+SymbolCode;
return(MagicNumber);
}

double DefineLotSize() {
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;
if(AccountIsMicro==false) { //normal account
if (lotMM < 0.1) lotMM = Lots;
if ((lotMM > 0.5) && (lotMM < 1)) lotMM=0.5;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
} else { //micro account
if (lotMM < 0.01) lotMM = Lots;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
}
return (lotMM);
}
//±-----------------------------------------------------------------+
//| Calculate concurrent Long position |
//±-----------------------------------------------------------------+
int CountLongs(int MagicNumber)
{
int count=0;
int trade;
int trades=OrdersTotal();
for(trade=0;trade<trades;trade++)
{
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if( OrderSymbol()!=Symbol() || OrderMagicNumber() != MagicNumber )
continue;

if(OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP)
count++;
}//for
return(count);
}
//±-----------------------------------------------------------------+
//| Calculate concurrent short position |
//±-----------------------------------------------------------------+
int CountShorts(int MagicNumber)
{
int count=0;
int trade;
int trades=OrdersTotal();
for(trade=0;trade<trades;trade++)
{
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber() != MagicNumber )
continue;

if(OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT || OrderType()==OP_SELLSTOP)
count++;
}//for
return(count);
}

how have you got on with this EA ?