!_rdb_Thunder_4WD_EURGBP_v1





//+------------------------------------------------------------------+
//|                                  !_rdb_Thunder_4WD_EURGBP_v1.mq4 |
//|                                                    rahman_DGBeta |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "rahman_DGBeta (_rdb_)"
#property link      "abdulrahman_maros@yahoo.com"

//salam salut saya untuk semua mql coder...
//selain versi EURGBP ini masih banyak versi lain yang sudah siap share share kepada teman-teman semua...
//mohon kiranya jika anda menggunakan script ini... jangan menghapus baris permintaan donasi... salam coder... semoga sukses...

extern bool    Thunder_1 = TRUE;
extern bool    Thunder_2 = TRUE;
extern bool    Thunder_3 = TRUE;
extern bool    Thunder_4 = TRUE;
extern int     Hour_Start_Trade = 22;     //20;  //22;    22;   default 22; 2;   //Insta Terlambat 2 jam dari ATC... juara 1 trade di 21-05 (Insta 23 ATC 21)
extern int     Hour_Stop_Trade =  5;      //5;   //8;      4;

extern double  Lots = 0.1;
extern double  max_lot = 50;
extern bool    LotsOptimized = TRUE;
extern int     LotDecimal = 2; // MasterForex Micro = 1 / InstaTrader atau ibfx mini = 2
extern int     Risk = 50;
extern int     MaxTrades = 5;

extern bool    Virtual_TP = TRUE;
extern bool    Fractal_SL = TRUE;
extern double  StopLoss = 32.0;
extern double  TakeProfit = 5.0;
extern int     slippage = 3;
extern double  MaxSpread = 4;
extern int     FractalRange = 32;
extern int     ATR_Level = 15;
extern int     PriceFromFractal = 5;

extern bool    Time_Protection = TRUE;
extern int     MagicNumber1 = 371443;
extern int     MagicNumber2 = 3714431;
extern int     MagicNumber3 = 3714432;
extern int     MagicNumber4 = 3714433;

int LimitTime_1 = 60;
int pips_1 = 3;   //3;
int LimitTime_2 = 140;
int pips_2 = 2;   //2;
int LimitTime_3 = 170;
int pips_3 = 0;   //0;
int LimitTime_4 = 200;
int pips_4 = 1;   //1;
int LimitTime_5 = 240;
int pips_5 = 4;   //4;

extern bool   Volatility_Filter = TRUE;
extern double sec = 0.001;
extern double se2c = 0.001;
extern double se3c = 0.0012;
int           MinuteToStop = 55;

bool next_buy_1   = TRUE;
bool next_sell_1  = TRUE;
bool next_buy_2   = TRUE;
bool next_sell_2  = TRUE;
bool next_buy_3   = TRUE;
bool next_sell_3  = TRUE;
bool next_buy_4   = TRUE;
bool next_sell_4  = TRUE;

double minlot = 0.0;
double maxlot = 0.0;
int    LotSize = 0;
int    myLeverage = 0;
double mylotsi,mylotsi1;
double mypoint = 0.0;
//int  TakeProfit = 0.0;

int    Max_BuySell = 0;

int    openorders=0,openorders1=0,openorders2=0,openorders3=0,openorders4=0;
int    ordersell = 0.0,ordersell1 = 0.0,ordersell2 = 0.0,ordersell3 = 0.0,ordersell4 = 0.0;
int    orderbuy = 0.0,orderbuy1 = 0.0,orderbuy2 = 0.0,orderbuy3 = 0.0,orderbuy4 = 0.0;
double sell_open_price=0.0,sell_open_price1=0.0,sell_open_price2=0.0,sell_open_price3=0.0,sell_open_price4=0.0;
double buy_open_price=0.0,buy_open_price1=0.0,buy_open_price2=0.0,buy_open_price3=0.0,buy_open_price4=0.0;

double Range_TP_OP;
double Range_OP_TP;
double tp = 0, sl=0;

double LastUpFractal,LastDownFractal,TimeOfLastDownFractal,TimeOfLastUpFractal;
double LastUpFractal_H1,LastDownFractal_H1,TimeOfLastDownFractal_H1,TimeOfLastUpFractal_H1;

int    FractalEnvelope=0;
int    FractalEnvelope_H1=0;
double midFractal=0;
int    CurrentATR=0;

string ExpertName      = "!_rdb_Thunder4WD";
bool   ManageBy_Symbol = false;
bool   ManageBy_Magic  = false;

double longActive=0,shortActive=0,longActive1=0,shortActive1=0,longStop=0,shortStop=0,longLimit=0,shortLimit=0,longPending=0,shortPending=0,allLong=0,allShort=0;
double allActive=0,allActive1=0,allPending=0,grandTotal=0;
int    allActiveM1=0,allActiveM5=0,allActiveM15=0,allActiveM30=0,allActiveH1=0,allActiveH4=0,allActiveD1=0;
double actualProfitMonitor=0;
double actualProfitMonitor_pip=0;
double ShortProfit=0;
double LongProfit=0, myBalance;
double longActiveLot=0,  shortActiveLot=0, longActiveLot1=0,  shortActiveLot1=0;
double longStopLot=0,    shortStopLot=0;
double longLimitLot=0,   shortLimitLot=0;
double longPendingLot=0, shortPendingLot=0;
double allLongLot=0,     allShortLot=0;
double allActiveLot=0,allActiveLot1=0,   allPendingLot=0;
double grandTotalLot=0;   
double mylotbl=0,myloteq=0,Max_Lot1=0,Percen_Lot1=0,Percen_Lot2=0,Long_Active_Lot=0,Short_Active_Lot=0,Net_Lot=0,Percen_NetLot,
       Percen_LotB=0,Percen_LotS=0,Percen_LotBS=0,Profit_Loss=0,LotHere=0,AllLotPercen=0,MyLotPercen=0;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int init() {
   return (0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int deinit() {
   return (0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int start() {
   HideTestIndicators(TRUE);
   findMyOrders();
   onScreenComment(98);
   tp = TakeProfit;
   sl=0;
   mypoint=0;
   if (Digits == 5 || Digits == 3) {mypoint=10*(MarketInfo(OrderSymbol(),MODE_POINT));} else {mypoint=(MarketInfo(OrderSymbol(),MODE_POINT));}

   for(int a=1;a<Bars;a++){
      if(iFractals(NULL, PERIOD_M15, MODE_UPPER,a)!=0){
         LastUpFractal=iFractals(NULL, PERIOD_M15, MODE_UPPER,a);
         TimeOfLastUpFractal=Time[a];
         break;
         }//end if
      }//end for
   for(int s=1;s<Bars;s++){
      if(iFractals(NULL, PERIOD_M15, MODE_LOWER,s)!=0){
         LastDownFractal=iFractals(NULL, PERIOD_M15, MODE_LOWER,s);
         TimeOfLastDownFractal=Time[s];
         break;
         }//end if
      }//end for

   for(int v=1;v<Bars;v++){
      if(iFractals(NULL, PERIOD_H1, MODE_UPPER,v)!=0){
         LastUpFractal_H1=iFractals(NULL, PERIOD_H1, MODE_UPPER,v);
         TimeOfLastUpFractal_H1=Time[v];
         break;
         }//end if
      }//end for
   for(int w=1;w<Bars;w++){
      if(iFractals(NULL, PERIOD_H1, MODE_LOWER,w)!=0){
         LastDownFractal_H1=iFractals(NULL, PERIOD_H1, MODE_LOWER,w);
         TimeOfLastDownFractal_H1=Time[s];
         break;
         }//end if
      }//end for

   //ObjectDelete("Fractal Fibo Retracement");
   //ObjectCreate("Fractal Fibo Retracement",OBJ_FIBO,0,TimeOfLastUpFractal,LastUpFractal,TimeOfLastDownFractal,LastDownFractal);
   FractalEnvelope=MathRound((LastUpFractal-LastDownFractal)/mypoint);
   FractalEnvelope_H1=MathRound((LastUpFractal_H1-LastDownFractal_H1)/mypoint);
   midFractal=0;
   midFractal=(LastUpFractal-((LastUpFractal-LastDownFractal)/2));
   CurrentATR=MathRound(iATR(Symbol(), PERIOD_M15,4,0)/mypoint);

   bool FractalIsInsideEnvelope=false;
   if(Close[0]<=LastUpFractal_H1 && Close[0]>=LastDownFractal_H1){
      FractalIsInsideEnvelope=true;
      }//end if
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   openorders=0;openorders1=0;openorders2=0;openorders3=0;openorders4=0;
   ordersell = 0.0;ordersell1 = 0.0;ordersell2 = 0.0;ordersell3 = 0.0;ordersell4 = 0.0;
   orderbuy = 0.0;orderbuy1 = 0.0;orderbuy2 = 0.0;orderbuy3 = 0.0;orderbuy4 = 0.0;
   sell_open_price=0.0;sell_open_price1=0.0;sell_open_price2=0.0;sell_open_price3=0.0;sell_open_price4=0.0;
   buy_open_price=0.0;buy_open_price1=0.0;buy_open_price2=0.0;buy_open_price3=0.0;buy_open_price4=0.0;

   for (int d = 0; d < OrdersTotal(); d++) 
   {
      OrderSelect(d, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumber1 || OrderMagicNumber() == MagicNumber2 || OrderMagicNumber() == MagicNumber3 || OrderMagicNumber() == MagicNumber4)) 
      {
         openorders++;
         if (OrderType() == OP_BUY) {orderbuy++;buy_open_price = OrderOpenPrice();}
         if (OrderType() == OP_SELL) {ordersell++;sell_open_price = OrderOpenPrice();}
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber1) 
      {
         openorders1++;
         if (OrderType() == OP_BUY) {orderbuy1++;buy_open_price1 = OrderOpenPrice();}
         if (OrderType() == OP_SELL) {ordersell1++;sell_open_price1 = OrderOpenPrice();}
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber2) 
      {
         openorders2++;
         if (OrderType() == OP_BUY) {orderbuy2++;buy_open_price2 = OrderOpenPrice();}
         if (OrderType() == OP_SELL) {ordersell2++;sell_open_price2 = OrderOpenPrice();}
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber3) 
      {
         openorders3++;
         if (OrderType() == OP_BUY) {orderbuy3++;buy_open_price3 = OrderOpenPrice();}
         if (OrderType() == OP_SELL) {ordersell3++;sell_open_price3 = OrderOpenPrice();}
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber4) 
      {
         openorders4++;
         if (OrderType() == OP_BUY) {orderbuy4++;buy_open_price4 = OrderOpenPrice();}
         if (OrderType() == OP_SELL) {ordersell4++;sell_open_price4 = OrderOpenPrice();}
      }
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (Virtual_TP == TRUE) {
      for (int i = 0; i < OrdersTotal(); i++) {
         OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
         //TakeProfit = 0.0;
         //if (FractalEnvelope<FractalRange && CurrentATR<ATR_Level) TakeProfit=5; 
             //else {
               //if (FractalEnvelope<FractalRange && CurrentATR<ATR_Level) TakeProfit=12;
                  //}
         if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber1) {
            if (Bid >= OrderOpenPrice() + (TakeProfit) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);}}
         if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber2) {
            if (Bid >= OrderOpenPrice() + (TakeProfit-2) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);}}
         if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber3) {
            if (Bid >= OrderOpenPrice() + (TakeProfit-1) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);}}
         if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber4) {
            if (Bid >= OrderOpenPrice() + (TakeProfit-2) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);}}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber1) {
            if (Ask <= OrderOpenPrice() - (TakeProfit) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);}}
         if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber2) {
            if (Ask <= OrderOpenPrice() - (TakeProfit-2) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);}}
         if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber3) {
            if (Ask <= OrderOpenPrice() - (TakeProfit-1) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);}}
         if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber4) {
            if (Ask <= OrderOpenPrice() - (TakeProfit-2) * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);}}
      }
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (Time_Protection == TRUE) {
      for (int j = 0; j < OrdersTotal(); j++) {
         OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_BUY && (OrderMagicNumber() == MagicNumber1 || OrderMagicNumber() == MagicNumber2 || OrderMagicNumber() == MagicNumber3 || OrderMagicNumber() == MagicNumber4)) {
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_1 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_2 && Bid >= OrderOpenPrice() + pips_1 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);
               Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_2 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_3 && Bid >= OrderOpenPrice() + pips_2 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);
               Print("Prot. Level 2 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_3 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_4 && Bid >= OrderOpenPrice() - pips_3 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);
               Print("Prot. Level 3 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_4 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_5 && Bid >= OrderOpenPrice() - pips_4 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);
               Print("Prot. Level 4 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_5 && Bid >= OrderOpenPrice() - pips_5 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);
               Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (DayOfWeek() == 5 && Hour()>=19) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Orange);
               Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
         }
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         if (OrderType() == OP_SELL && (OrderMagicNumber() == MagicNumber1 || OrderMagicNumber() == MagicNumber2 || OrderMagicNumber() == MagicNumber3 || OrderMagicNumber() == MagicNumber4)) {
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_1 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_2 && Ask <= OrderOpenPrice() - pips_1 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
               Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_2 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_3 && Ask <= OrderOpenPrice() - pips_2 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
               Print("Prot. Level 2 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_3 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_4 && Ask <= OrderOpenPrice() + pips_3 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
               Print("Prot. Level 3 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_4 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_5 && Ask <= OrderOpenPrice() + pips_4 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
               Print("Prot. Level 4 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_5 && Ask <= OrderOpenPrice() + pips_5 * mypoint) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
               Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (DayOfWeek() == 5 && Hour()>=19) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
               Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(), 0) +
                  " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
         }
      }
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
   if (!Virtual_TP && Correction_Slippage_TP == TRUE) {
      for (int k = 0; k < OrdersTotal(); k++) {
         OrderSelect(k, SELECT_BY_POS, MODE_TRADES);
         Range_TP_OP = NormalizeDouble(OrderTakeProfit() - OrderOpenPrice(), 7);
         Range_OP_TP = NormalizeDouble(OrderOpenPrice() - OrderTakeProfit(), 7);
         if (OrderType() == OP_BUY && (OrderMagicNumber() == MagicNumber1 || OrderMagicNumber() == MagicNumber2 || OrderMagicNumber() == MagicNumber3 || OrderMagicNumber() == MagicNumber4) && Range_TP_OP != TakeProfit * mypoint) 
             OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - StopLoss * mypoint, OrderOpenPrice() + TakeProfit * mypoint, 0, Green);
         if (OrderType() == OP_SELL && (OrderMagicNumber() == MagicNumber1 || OrderMagicNumber() == MagicNumber2 || OrderMagicNumber() == MagicNumber3 || OrderMagicNumber() == MagicNumber4) && Range_OP_TP != TakeProfit * mypoint) 
             OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + StopLoss * mypoint, OrderOpenPrice() - TakeProfit * mypoint, 0, Red);
      }
   }
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (Volatility_Filter == TRUE) {
      if (iOpen(Symbol(), PERIOD_M5, 0) >= Ask + sec) return;
      if (iOpen(Symbol(), PERIOD_M5, 0) <= Bid - sec) return;
      if (iOpen(Symbol(), PERIOD_M5, 1) >= Ask + se2c) return;
      if (iOpen(Symbol(), PERIOD_M5, 1) <= Bid - se2c) return;
      if (iOpen(Symbol(), PERIOD_M5, 2) >= Ask + se3c) return;
      if (iOpen(Symbol(), PERIOD_M5, 2) <= Bid - se3c) return;
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
   if (Ask - Bid > MaxSpread * mypoint) return (0);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
   minlot = MarketInfo(Symbol(), MODE_MINLOT);
   maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
   myLeverage = AccountLeverage();
   LotSize = MarketInfo(Symbol(), MODE_LOTSIZE);
   mylotsi = MathMin(maxlot, MathMax(minlot, Lots));
   if (LotsOptimized && Risk > 0.0) mylotsi = MathMax(minlot, MathMin(maxlot, NormalizeDouble(Risk / 100.0 * AccountFreeMargin() / minlot / (LotSize / 100), 0) * minlot));
   mylotsi = MathMax(minlot, MathMin(maxlot, NormalizeDouble(mylotsi / minlot, 0) * minlot));
   mylotsi = NormalizeDouble(mylotsi, LotDecimal);
   if (AccountFreeMargin() < Ask * mylotsi * LotSize / myLeverage) {
      Print("Low Account Balance. Lots = ", mylotsi, " , Free Margin = ", AccountFreeMargin());
      Comment("Low Account Balance. Lots = ", mylotsi, " , Free Margin = ", AccountFreeMargin());
      return;
   }
*/
   Max_BuySell = NormalizeDouble(MaxTrades/2, 0);

   minlot = MarketInfo(Symbol(), MODE_MINLOT);
   maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
   myLeverage = AccountLeverage();
   LotSize = MarketInfo(Symbol(), MODE_LOTSIZE);
   mylotsi = MathMin(maxlot, MathMax(minlot, Lots));
   if (LotsOptimized && Risk > 0.0 && (AccountFreeMargin() > Ask * mylotsi * LotSize / myLeverage)) 
      { mylotsi = NormalizeDouble((AccountFreeMargin() * Risk / LotSize),LotDecimal) ;}
      else { mylotsi = minlot ;}
   mylotsi = MathMax(minlot, MathMin(maxlot, NormalizeDouble(mylotsi / minlot, 0) * minlot));
   mylotsi = NormalizeDouble((mylotsi/Max_BuySell), LotDecimal);
   if(mylotsi>max_lot) mylotsi=max_lot;
   if (AccountFreeMargin() < Ask * mylotsi * LotSize / myLeverage) {
      Print("Low Account Balance. Lots = ", mylotsi, " , Free Margin = ", AccountFreeMargin());
      Comment("Low Account Balance. Lots = ", mylotsi, " , Free Margin = ", AccountFreeMargin());
      return;
   }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      double close_M5   =iClose (Symbol(),PERIOD_M15,0);   
      double open_M5    =iOpen (Symbol(),PERIOD_M15,0);   
      double low_M5     =iLow (Symbol(),PERIOD_M15,0);   
      double high_M5    =iHigh (Symbol(),PERIOD_M15,0);   

      double rsi_M15    = iRSI(NULL, PERIOD_M15, 6, PRICE_CLOSE, 0);
      double rsi_M1     = iRSI(NULL, PERIOD_M1, 20, PRICE_CLOSE, 0);
      double MA_1       = NormalizeDouble(iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_WEIGHTED, 1), 4);
      double MA_2       = NormalizeDouble(iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_WEIGHTED, 1), 4);

      double CCI_M15    =iCCI (Symbol(),PERIOD_M15,14,PRICE_CLOSE,0);
      double CCI_M5     =iCCI (Symbol(),PERIOD_M5,42,PRICE_CLOSE,0);
      double CCI_M1     =iCCI (Symbol(),PERIOD_M1,210,PRICE_CLOSE,0);

      double CCI2_M1    =iCCI (Symbol(),PERIOD_M1,80,PRICE_CLOSE,0);

      double MM_M1      =iMomentum(Symbol(),PERIOD_M1,60,PRICE_CLOSE,0);
      double MM_M5      =iMomentum(Symbol(),PERIOD_M5,4,PRICE_CLOSE,0);
      double MM_M15     =iMomentum(Symbol(),PERIOD_M15,14,PRICE_CLOSE,0);

      double WPR_M1     =iWPR (Symbol(),PERIOD_M1,14,0);
      double WPR_M5     =iWPR (Symbol(),PERIOD_M5,14,0);
      double WPR_M15    =iWPR (Symbol(),PERIOD_M15,14,0);

      double FI_M5      =iForce(Symbol(),PERIOD_M5,13,MODE_SMA,PRICE_CLOSE,0);

      double bbP        = iBands(Symbol(),PERIOD_M5,20,2,0,PRICE_WEIGHTED,MODE_PLUSDI,1);
      double bbMid      = iBands(Symbol(),PERIOD_M5,20,2,0,PRICE_WEIGHTED,MODE_MAIN,1);
      double bbM        = iBands(Symbol(),PERIOD_M5,20,2,0,PRICE_WEIGHTED,MODE_MINUSDI,1);

      double MAHigh     =iMA(Symbol(),PERIOD_M5,1,0,MODE_EMA,PRICE_HIGH,0);
      double MAMid      =iMA(Symbol(),PERIOD_M5,1,0,MODE_EMA,PRICE_MEDIAN,0);
      double MALow      =iMA(Symbol(),PERIOD_M5,1,0,MODE_EMA,PRICE_LOW,0);

      double bbP_M1     = iBands(Symbol(),PERIOD_M5,20,2,0,PRICE_WEIGHTED,MODE_PLUSDI,0);
      double bbMid_M1   = iBands(Symbol(),PERIOD_M5,20,2,0,PRICE_WEIGHTED,MODE_MAIN,0);
      double bbM_M1     = iBands(Symbol(),PERIOD_M5,20,2,0,PRICE_WEIGHTED,MODE_MINUSDI,0);

      double MAHigh_M1  =iMA(Symbol(),PERIOD_M1,1,0,MODE_EMA,PRICE_HIGH,0);
      double MAMid_M1   =iMA(Symbol(),PERIOD_M1,1,0,MODE_EMA,PRICE_MEDIAN,0);
      double MALow_M1   =iMA(Symbol(),PERIOD_M1,1,0,MODE_EMA,PRICE_LOW,0);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (IsTradeTime() && openorders<MaxTrades && FractalIsInsideEnvelope)
   {
   if (!ExistPosition1() && Thunder_1==true) {
      if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour()>=14) return (0);
      //if (DayOfWeek() == 1 && Hour() < Hour_Start_Trade) return (0);
      if (rsi_M15 < 30 || rsi_M1 < 36.0 && MA_1 >= Ask + (mypoint*2)) {
         if (orderbuy1<1 && next_buy_1) {
            tp = 0; sl=0;
            if (!Virtual_TP) {tp = Ask + TakeProfit * mypoint;} //(NormalizeDouble((mylotsi+(mylotsi*0.3)),LotDecimal))
            sl=Ask - (StopLoss*mypoint); //StopLoss
            if(NormalizeDouble(mylotsi+(mylotsi/Max_BuySell),LotDecimal)<max_lot) mylotsi1=NormalizeDouble(mylotsi+(mylotsi/Max_BuySell),LotDecimal); else mylotsi1=mylotsi;
            OrderSend(Symbol(), OP_BUY, mylotsi1, Ask, slippage, sl, tp, "EURGBP_1", MagicNumber1, 0, Green);
            next_buy_1 = FALSE;
            next_sell_1 = TRUE;
         }
      }
      if (rsi_M15 > 70 || rsi_M1 > 64.0 && MA_2 <= Bid - (mypoint*2)) {
         if (ordersell1<1 && next_sell_1) {
            tp = 0; sl=0;
            if (!Virtual_TP) {tp = Bid - TakeProfit * mypoint;}
            sl=Bid + (StopLoss*mypoint); //StopLoss
            if(NormalizeDouble(mylotsi+(mylotsi/Max_BuySell),LotDecimal)<max_lot) mylotsi1=NormalizeDouble(mylotsi+(mylotsi/Max_BuySell),LotDecimal); else mylotsi1=mylotsi;
            OrderSend(Symbol(), OP_SELL, mylotsi1, Bid, slippage, sl, tp, "EURGBP_1", MagicNumber1, 0, Red);
            next_sell_1 = FALSE;
            next_buy_1 = TRUE;
         }
      }
      if (rsi_M15 < 60 && rsi_M15 > 40) {
         next_sell_1 = TRUE;
         next_buy_1 = TRUE;
      }
   }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (IsTradeTime() && FractalEnvelope<FractalRange && CurrentATR<ATR_Level && openorders<MaxTrades && FractalIsInsideEnvelope)
   {
   //Finish (jam 22-7)
   if (!ExistPosition2() && Thunder_2==true) {
      if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour()>=14) return (0);
      //if (DayOfWeek() == 1 && Hour() < Hour_Start_Trade) return (0);
      if ((CCI_M5<=-150) && (CCI_M1<=-120) || (CCI_M15<=-150) && (CCI_M1<=-120) && Bid<=midFractal-(PriceFromFractal*mypoint)) {  //!ExistPosition2() && 
         if (orderbuy<Max_BuySell && next_buy_2) {
            tp = 0; sl=0;
            if (Virtual_TP) tp = Ask + TakeProfit * mypoint;
            sl=Ask - (StopLoss*mypoint); //StopLoss
            //if (Fractal_SL) sl = LastDownFractal - (StopLoss* mypoint); else sl = Ask - StopLoss * mypoint;
            OrderSend(Symbol(), OP_BUY, mylotsi, Ask, slippage, sl, tp, "EURGBP_2", MagicNumber2, 0, Green);
            next_buy_2 = FALSE;
            next_sell_2 = TRUE;
         }
      }
      if ((CCI_M5>=150) && (CCI_M1>=120) || (CCI_M15>=150) && (CCI_M1>=120) && Ask>=midFractal+(PriceFromFractal*mypoint)) { //!ExistPosition2() && 
         if (ordersell<Max_BuySell && next_sell_2) {
            tp = 0; sl=0;
            if (Virtual_TP) tp = Bid - TakeProfit * mypoint;
            sl=Bid + (StopLoss*mypoint); //StopLoss
            //if (Fractal_SL) sl = LastDownFractal - (StopLoss*mypoint); else sl = Ask - (StopLoss*mypoint);
            OrderSend(Symbol(), OP_SELL, mylotsi, Bid, slippage, sl, tp, "EURGBP_2", MagicNumber2, 0, Red);
            next_sell_2 = FALSE;
            next_buy_2 = TRUE;
         }
      }
      if (CCI_M15 < 50 && CCI_M15 > -50) {
      //if (rsi_M15 < 60 && rsi_M15 > 40) {
         next_sell_2 = TRUE;
         next_buy_2 = TRUE;
      }
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (!ExistPosition3() && Thunder_3==true) {
      if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour()>=14) return (0);
      //if (DayOfWeek() == 1 && Hour() < Hour_Start_Trade) return (0);

      if ((MM_M5>=99.85) && (CCI2_M1<=-200) && Bid<=midFractal-(PriceFromFractal*mypoint)) {
         if (orderbuy<Max_BuySell && next_buy_3) {
            tp = 0; sl=0;
            if (Virtual_TP) tp = Ask + TakeProfit * mypoint;
            //sl=Ask - (FractalRange*mypoint); //StopLoss
            if (Fractal_SL) sl = LastDownFractal - (StopLoss*mypoint); else sl = Ask - (StopLoss*mypoint);
            OrderSend(Symbol(), OP_BUY, mylotsi, Ask, slippage, sl, tp, "EURGBP_3", MagicNumber3, 0, Green);
            next_buy_3 = FALSE;
            next_sell_3 = TRUE;
         }
      }
      if ((MM_M5<=100.15) && (CCI2_M1>=200) && Ask>=midFractal+(PriceFromFractal*mypoint)) {
         if (ordersell<Max_BuySell && next_sell_3) {
            tp = 0; sl=0;
            if (Virtual_TP) tp = Bid - TakeProfit * mypoint;
            //sl=Bid + (FractalRange*mypoint); //StopLoss
            if (Fractal_SL) sl = LastUpFractal + (StopLoss*mypoint); else sl = Bid + (StopLoss*mypoint);
            OrderSend(Symbol(), OP_SELL, mylotsi, Bid, slippage, sl, tp, "EURGBP_2", MagicNumber2, 0, Red);
            next_sell_3 = FALSE;
            next_buy_3 = TRUE;
         }
      }
      //if (MM_M5 >= 99.95 && MM_M5 <= 100.05) {
      if (CCI2_M1>=-50 && CCI2_M1<=50) {
         next_sell_3 = TRUE;
         next_buy_3 = TRUE;
      }
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (!ExistPosition4() && Thunder_4==true) {   
      if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour()>=14) return (0);
      //if (DayOfWeek() == 1 && Hour() < Hour_Start_Trade) return (0);
      if ((WPR_M5<=-90) && (MALow<bbM) && Ask<=midFractal-(PriceFromFractal*mypoint)) {
         if (orderbuy<Max_BuySell && next_buy_4) {
            tp = 0; sl=0;
            if (Virtual_TP) tp = Ask + TakeProfit * mypoint;
            //sl=Ask - (FractalRange*mypoint); //StopLoss
            if (Fractal_SL) sl=Ask - (FractalRange*mypoint); else sl = Ask - StopLoss * mypoint;
            OrderSend(Symbol(), OP_BUY, mylotsi, Ask, slippage, sl, tp, "EURGBP_4", MagicNumber4, 0, Green);
            next_buy_4 = FALSE;
            next_sell_4 = TRUE;
         }
      }
      if ((WPR_M5>=-10) && (MAHigh>bbP) && Bid>=midFractal+(PriceFromFractal*mypoint)) {
         if (ordersell<Max_BuySell && next_sell_4) {
            tp = 0; sl=0;
            if (Virtual_TP) tp = Bid - TakeProfit * mypoint;
            //sl=Bid + (FractalRange*mypoint); //StopLoss
            if (Fractal_SL) sl=Bid + (FractalRange*mypoint); else sl = Bid + (StopLoss*mypoint);
            OrderSend(Symbol(), OP_SELL, mylotsi, Bid, slippage, sl, tp, "EURGBP_2", MagicNumber2, 0, Red);
            next_sell_4 = FALSE;
            next_buy_4 = TRUE;
         }
      }
      //if (MM_M5 >= 99.95 && MM_M5 <= 100.05) {
      if (rsi_M15 < 60 && rsi_M15 > 40) {
         next_sell_4 = TRUE;
         next_buy_4 = TRUE;
      }
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   }
return (0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool IsTradeTime() {
   if (Hour_Start_Trade < Hour_Stop_Trade && TimeHour(TimeCurrent()) < Hour_Start_Trade || TimeHour(TimeCurrent()) >= Hour_Stop_Trade) return (FALSE);
   if (Hour_Start_Trade > Hour_Stop_Trade && (TimeHour(TimeCurrent()) < Hour_Start_Trade && TimeHour(TimeCurrent()) >= Hour_Stop_Trade)) return (FALSE);
   if (Hour_Stop_Trade == 0) Hour_Stop_Trade = 24;
   if (Hour() == Hour_Stop_Trade - 1 && Minute() >= MinuteToStop) return (FALSE);
   return (TRUE);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ExistPosition1() {
   bool myopen1 = FALSE;
   for (int l = 0; l < OrdersTotal(); l++) {
      if (OrderSelect(l, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber1) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               myopen1 = TRUE;
               break;
            }
         }
      }
   }
   return (myopen1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ExistPosition2() {
   bool myopen2 = FALSE;
   for (int m = 0; m < OrdersTotal(); m++) {
      if (OrderSelect(m, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber2) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               myopen2 = TRUE;
               break;
            }
         }
      }
   }
   return (myopen2);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ExistPosition3() {
   bool myopen3 = FALSE;
   for (int n = 0; n < OrdersTotal(); n++) {
      if (OrderSelect(n, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber3) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               myopen3 = TRUE;
               break;
            }
         }
      }
   }
   return (myopen3);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ExistPosition4() {
   bool myopen4 = FALSE;
   for (int n = 0; n < OrdersTotal(); n++) {
      if (OrderSelect(n, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber4) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               myopen4 = TRUE;
               break;
            }
         }
      }
   }
   return (myopen4);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void onScreenComment(int event) 
{               
      string draw = DoubleToStr(balanceDeviation(2), 2);
      string drup = DoubleToStr(balanceDeviation(1), 2);
      string prof = DoubleToStr(dollarCount(1), 2);
      string loss = DoubleToStr(dollarCount(2), 2);

      string header = "\n" + ExpertName + " run-time statistics : \n\n"; //\n\n";
      string manager, stopper, timer, breaker, trailer;
      string line = "\n";
                      
      if (Minute()<10)
         timer = Hour() + ":0" + Minute();
      else
         timer = Hour() + ":" + Minute();
                      
      string ordercount = "\n" +

             "Fractal Envelope    : "+FractalEnvelope+" pips\n"+
             "MidFractal             : "+DoubleToStr(midFractal,2)+" \n"+
             "ATR(5)                 : "+CurrentATR+" pips\n\n"+

             "Buy Active           :  " + DoubleToStr(longActiveLot1,2) + "   (" + DoubleToStr(Percen_LotB,2) + " %)" + "\n" +
             "Sell Active            :  " + DoubleToStr(shortActiveLot1,2)  + "   (" + DoubleToStr(Percen_LotS,2) + " %)" + "\n"  +
             "Total Here            :  " + DoubleToStr(allActiveLot1,2)  + "   (" + DoubleToStr(Percen_LotBS,2)  + ")   (" + DoubleToStr(longActive1,2) + " %)" + "\n" +
             "Grand Total          :  " + DoubleToStr(allActiveLot,2) + "   (" + DoubleToStr(AllLotPercen,2)  + ")   (" + DoubleToStr(shortActive1,2) + " %)" + "\n" + "\n" +
             
             "L O T S               :  " + DoubleToStr(mylotsi,2) + "\n" + 
             "E Q U I T Y         :  " + DoubleToStr(AccountEquity(),2) + "\n\n\n" + 

             "EA ini FREE dan terus dikembangkan..." + "\n" + 
             "Anda dapat konsultasi / diskusi cara penggunaan ataupun pengembangannya" + "\n" + 
             "sebagai wujud partisipasi anda dalam mendukung berlanjutnya kreatifitas kami......" + "\n" + 
             "diharapkan bantuan berupa donasi seikhlasnya... " + "\n" + 
             "hubungi : abdulrahman_maros@yahoo.com" + "\n" + 
             "Abdul Rahman ==> BCA : 7990026640 / LR : U7067895"
             ;
      string stats = 
             "Current Time         :  " + timer + "\n" +
             "Account Leverage   :  " + "1 : " + AccountLeverage() + "\n" + 
             "Account Type        :  " + AccountServer() + "\n" +              
             //line +
             //"Total Profit (Dollars):  "       + prof + "\n" +
             //"Total Profit (Pips):  "          + pipCount(1) + "\n" +
             //"Percentage Profit:  "            + drup + "%\n" +
             //line +
             //"Total Loss (Dollars):  "         + loss + "\n" +
             //"Total Loss (Pips):  "            + pipCount(2) + "\n" +
             "Drawdown            :  " + draw + "%\n"
             ;
      if (ManageBy_Magic==false && ManageBy_Symbol==false)
         manager = "Managing ALL orders in this terminal\n";

      switch (event)
      {
         case 91: Comment(ExpertName + " is waiting for the next tick to begin."); break;
         case 98: Comment(header + manager + trailer + breaker + stats + ordercount); break;
         case 99: Comment(" "); break;
      }
} //void onScreenComment(int event) 
   
//+---------------------------------------------------- ******** || ********* ------------------------------------------------+
void findMyOrders() 
{
   actualProfitMonitor=0; 
   actualProfitMonitor_pip=0;
   ShortProfit=0; 
   LongProfit=0;

   longActive=0;  shortActive=0;
   longActive1=0;  shortActive1=0;
   longStop=0;    shortStop=0;
   longLimit=0;   shortLimit=0;
   longPending=0; shortPending=0;
   allLong=0;     allShort=0;
   allActive=0;   allPending=0; allActive1=0;
   grandTotal=0;   

   longActiveLot=0;  shortActiveLot=0;  longActiveLot1=0;  shortActiveLot1=0;
   longStopLot=0;    shortStopLot=0;
   longLimitLot=0;   shortLimitLot=0;
   longPendingLot=0; shortPendingLot=0;
   allLongLot=0;     allShortLot=0;
   allActiveLot=0;   allActiveLot1=0; allPendingLot=0;
   grandTotalLot=0;   

   for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
   {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
         if (OrderType()==OP_BUY)
            {
            longActive++; 
            actualProfitMonitor += OrderProfit();
            actualProfitMonitor_pip += ( (OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_BID)) / (MarketInfo(OrderSymbol(),MODE_POINT)) );
            longActiveLot += OrderLots();
            }
         if(Symbol()==Symbol() && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUY))
            {longActive1++; longActiveLot1 += OrderLots(); LongProfit += OrderProfit();}
            
         else 
         if (OrderType()==OP_SELL)
            {
            shortActive++; 
            actualProfitMonitor += OrderProfit();
            actualProfitMonitor_pip += ( (OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK)) / (MarketInfo(OrderSymbol(),MODE_POINT)) );
            shortActiveLot += OrderLots();
            }
         if(Symbol()==Symbol() && (OrderSymbol()==Symbol()) && (OrderType()==OP_SELL))
            {shortActive1++; shortActiveLot1 += OrderLots(); ShortProfit += OrderProfit();}

         else 
         if (OrderType()==OP_BUYSTOP)
            longStop++;
         else 
         if (OrderType()==OP_SELLSTOP)
            shortStop++;
         else 
         if (OrderType()==OP_BUYLIMIT)
            longLimit++;
         else 
         if (OrderType()==OP_SELLLIMIT)
            shortLimit++;
   }//for
   longPending  = longStop + longLimit;
   shortPending = shortStop + shortLimit;
   allPending   = longPending + shortPending;
   allActive    = longActive + shortActive;
   allLong      = longStop + longLimit + longActive;
   allShort     = shortStop + shortLimit + shortActive;
   grandTotal   = allActive + allPending;

   longPendingLot  = longStopLot + longLimitLot;
   shortPendingLot = shortStopLot + shortLimitLot;
   allPendingLot   = longPendingLot + shortPendingLot;
   allLongLot      = longStopLot + longLimitLot + longActiveLot;
   allShortLot     = shortStopLot + shortLimitLot + shortActiveLot;
   grandTotalLot   = allActiveLot + allPendingLot;
     
   allActiveLot    = longActiveLot + shortActiveLot;
   allActive1      = longActive1 + shortActive1;
   allActiveLot1   = longActiveLot1 + shortActiveLot1;
   LotSize = MarketInfo(Symbol(), MODE_LOTSIZE);
   mylotbl          = AccountBalance()/LotSize;
   myloteq          = AccountEquity()/LotSize;
   
   Long_Active_Lot  = longActiveLot1;     
   Short_Active_Lot = shortActiveLot1;           
   Net_Lot          = longActiveLot1-shortActiveLot1;           

   Percen_LotB      = (Long_Active_Lot/myloteq);//*100;           
   Percen_LotS      = (Short_Active_Lot/myloteq);//*100;          //0.1/2*100 =5%
   Percen_LotBS     = ((Long_Active_Lot+Short_Active_Lot)/myloteq);//*100;
   if(longActiveLot1-shortActiveLot1>0)   Percen_NetLot = ((longActiveLot1-shortActiveLot1)/myloteq)*100; else
   if(longActiveLot1-shortActiveLot1<0)   Percen_NetLot = (((longActiveLot1-shortActiveLot1)*(-1))/myloteq)*100;

   Profit_Loss      = LongProfit+ShortProfit;
   LotHere          = Long_Active_Lot+Short_Active_Lot;

   AllLotPercen     = (allActiveLot/myloteq);//*100;
   MyLotPercen      = (myloteq/mylotbl);//*100;

} //void findMyOrders() 
//+---------------------------------------------------- ******** || ********* ------------------------------------------------+
double balanceDeviation(int mode)
{
   double val;
   if (mode==2) { val = ( ((AccountEquity()/AccountBalance()) -1) * (-100) ); if (val>0) return (val); else return (0); }
   if (mode==1) { val = ( ((AccountEquity()/AccountBalance()) -1) * (100) ); if (val>0) return (val); else return (0); }
}
//+---------------------------------------------------- ******** || ********* ------------------------------------------------+
double dollarCount(int mode)
{
   if (mode==1) { if (actualProfitMonitor>0) return (actualProfitMonitor); else return (0);}    
   if (mode==2) { if (actualProfitMonitor<0) return (MathAbs(actualProfitMonitor)); else return (0); }
}
//+---------------------------------------------------- ******** || ********* ------------------------------------------------+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
Series array that contains close prices for each bar
Series array that contains open prices of each bar


Indicator Curves created:


Indicators Used:

Fractals
Indicator of the average true range
Relative strength index
Moving average indicator
Momentum indicator
Force index
Bollinger bands indicator


Custom Indicators Used:

Order Management characteristics:

Checks for the total of open orders
It Closes Orders by itself
It can change open orders parameters, due to possible stepping strategy
It automatically opens orders when conditions are reached

Other Features:

BackTest : EURUSD on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-05-01 to 2010-05-31 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-06-01 to 2010-06-30 Profit Factor:0.00 Total Net Profit:0.00

Request Backtest for !_rdb_Thunder_4WD_EURGBP_v1


From : (yyyy/mm/dd) To: (yyyy/mm/dd)

Pair: Period: