//+------------------------------------------------------------------+ //| Breakout EA //| //+------------------------------------------------------------------+ extern double Lots = 0.1; extern int Slippage = 3; extern int EntryHour = 8; //Broker feed time extern int EntryMin = 30; extern bool DSTAutoAdjust = FALSE; //Automatically adjusts "EntryHour" according to DST extern int Expire = 8; //If neither Buy Stop or Sell Stop order are hit after "Expire" delete both extern double LongStopLossPips = 200; extern double ShortStopLossPips = 200; extern double LongProfitPips = 90; extern double ShortProfitPips = 90; extern double ChannelWidthPips = 80; //Stop orders are placed at +/- 50% of ChannelWidthPips extern int AddSpreadLong = 0; //Add this many pips to entry extern int AddSpreadShort = 0; int ordB; int ordS; int numord; int numpend; int MagicNumber = 12345; datetime timeprev = 0; double myPoint; int init() { MagicNumber = MagicfromSymbol(); myPoint = SetPoint(Symbol()); return(0); } int deinit() { return(0); } int start() { datetime expiration; double LongEntry, ShortEntry, LongStopLoss, LongTakeProfit, ShortStopLoss, ShortTakeProfit, AdjustedEntryHour; numpend = 0; numord = 0; //determine if we are currently in any trades, and if there are any pending orders for (int i=0;i 0) { LongEntry = NormalizeDouble(LongEntry, Digits); ShortEntry = NormalizeDouble(ShortEntry, Digits); LongStopLoss = NormalizeDouble(LongStopLoss, Digits); LongTakeProfit = NormalizeDouble(LongTakeProfit, Digits); ShortStopLoss = NormalizeDouble(ShortStopLoss, Digits); ShortTakeProfit = NormalizeDouble(ShortTakeProfit, Digits); } //Long ordB = OrderSend(Symbol(), OP_BUYSTOP, Lots, LongEntry, Slippage, LongStopLoss, LongTakeProfit, NULL, MagicNumber, 0, Green); //Shrt ordS = OrderSend(Symbol(), OP_SELLSTOP, Lots, ShortEntry, Slippage, ShortStopLoss, ShortTakeProfit, NULL, MagicNumber, 0, Red); } }//Open Pending return(0); } int MagicfromSymbol() { int magic = 0; string var1 = TimeToStr(CurTime(), TIME_DATE|TIME_SECONDS); for (int i = 0; i < 6; i++) { magic = magic * 7 + StringGetChar(Symbol(), i); } // magic=magic*3+Period(); magic = magic + StrToInteger(var1); return(magic); } int DSTAdjustment(int HourUsed) { int DST = 0; if (Month() > 3 && Month() < 10) { DST = 1; } else if (Month() == 3) { if (Day() + (7 - DayOfWeek()) > 31) { DST = 1; } } else if (Month() == 10) { if (Day() + (7 - DayOfWeek()) <= 31) { DST = 1; } } if (DST == 1) { return (HourUsed - 1); } else { return (HourUsed); } } double SetPoint(string mySymbol) { double mPoint, myDigits; myDigits = MarketInfo (mySymbol, MODE_DIGITS); if (myDigits < 4) mPoint = 0.01; else mPoint = 0.0001; return(mPoint); }