Navigation:Home > Content >

ISEA_(for_4and5_digits_brokers).mq4

Time: 2015-03-18 | Download file:ISEA_(for_4and5_digits_brokers).mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.223.1a []
   Website: http://purebeam.biz
   E-mail : [email protected]
*/
#property copyright "Copyright © 2009, INVESTIVA"
#property link      "www.investiva.net"

int gi_76 = 5;
int gi_80 = 7;
int gi_84 = 2;
int g_period_88 = 16;
int gi_92 = 2;
extern int TradeVolume = 1;
extern bool UseHourTrade = FALSE;
extern int FromHourTrade = 6;
extern int ToHourTrade = 18;
int g_ticket_112;
int g_ticket_116;
int g_ord_total_120;
int gi_124 = 0;
int gi_128 = 0;
int gi_132 = 0;
int gi_136 = 0;
double g_price_140;
double gd_148;
double gd_156;
double gd_164;
double gd_172;
double gd_180;
double gd_188;
double gd_196;
double g_ima_204;
double gd_212;
double g_minlot_220;
int MultiplierPoint;
double DigitPoint;
//==================================================================================================================
void init()
{
//------------------------------------------------------
//Calculate for 4 or 5 digits broker
DigitPoint=MarketInfo(Symbol(),MODE_POINT);
MultiplierPoint=1;
if((MarketInfo(Symbol(),MODE_DIGITS)==3)||(MarketInfo(Symbol(),MODE_DIGITS)==5))
{
MultiplierPoint=10;
DigitPoint*=MultiplierPoint;
}
//------------------------------------------------------
   gd_172 = MarketInfo(Symbol(), MODE_STOPLEVEL)/MultiplierPoint;
   gd_172 = (gd_172 + 1.0) * DigitPoint;
   gd_148 = gi_80 * DigitPoint;
   gd_156 = gi_76 * DigitPoint;
   gd_164 = gi_84 * DigitPoint;
   gd_196 = gi_92 * DigitPoint;
   gd_212 = (Ask - Bid)/MultiplierPoint;
}
//==================================================================================================================
int start() {
   if (UseHourTrade) {
      if (!(Hour() >= FromHourTrade && Hour() <= ToHourTrade)) {
         Comment("This is not trading time.");
         return (0);
      }
   }
   g_ord_total_120 = OrdersTotal();
   gi_124 = FALSE;
   gi_128 = FALSE;
   gi_132 = FALSE;
   gi_136 = FALSE;
   for (int l_ord_total_12 = g_ord_total_120; l_ord_total_12 >= 0; l_ord_total_12--) {
      if (OrderSelect(l_ord_total_12, SELECT_BY_POS) == TRUE && OrderSymbol() == Symbol()) {
         if (OrderType() == OP_BUY) {
            gi_132 = TRUE;
            Close_B(OrderTicket(), OrderLots());
         }
         if (OrderType() == OP_SELL) {
            gi_136 = TRUE;
            Close_S(OrderTicket(), OrderLots());
         }
         if (OrderType() == OP_BUYLIMIT) {
            gd_180 = NormalizeDouble(OrderOpenPrice(), Digits);
            g_ticket_112 = OrderTicket();
            gi_124 = TRUE;
         }
         if (OrderType() == OP_SELLLIMIT) {
            gd_188 = NormalizeDouble(OrderOpenPrice(), Digits);
            g_ticket_116 = OrderTicket();
            gi_128 = TRUE;
         }
      }
   }
   g_ima_204 = iMA(NULL, 0, g_period_88, 0, MODE_LWMA, PRICE_TYPICAL, 0);
   Modify_order();
   Open_order();
   return/*(WARN)*/;
}
//==================================================================================================================
void Close_B(int a_ticket_0, double a_lots_4) {
   if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= gd_196) {
      OrderClose(a_ticket_0, a_lots_4, Bid, 1, Yellow);
      gi_132 = FALSE;
   }
}
//==================================================================================================================
void Close_S(int a_ticket_0, double a_lots_4) {
   if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= gd_196) {
      OrderClose(a_ticket_0, a_lots_4, Ask, 1, Yellow);
      gi_136 = FALSE;
   }
}
//==================================================================================================================
void Modify_order() {
   if (gi_124 == TRUE) {
      g_price_140 = g_ima_204 - gd_164;
      if (MathAbs(gd_180 - g_price_140) > Point / 2.0) OrderModify(g_ticket_112, g_price_140, g_price_140 - gd_148, g_price_140 + gd_156, 0, DeepSkyBlue);
   }
   if (gi_128 == TRUE) {
      g_price_140 = g_ima_204 + gd_212 + gd_164;
      if (MathAbs(gd_188 - g_price_140) > Point / 2.0) OrderModify(g_ticket_116, g_price_140, g_price_140 + gd_148, g_price_140 - gd_156, 0, Pink);
   }
}
//==================================================================================================================
void Open_order() {
   if (gi_132 == FALSE && gi_124 == FALSE) {
      g_price_140 = g_ima_204 - gd_164;
      if (g_price_140 > Ask - gd_172) g_price_140 = Ask - gd_172;
      g_price_140 = NormalizeDouble(g_price_140, Digits);
      OrderSend(Symbol(), OP_BUYLIMIT, Lots(), g_price_140, 3, g_price_140 - gd_148, g_price_140 + gd_156, "", 0, 0, Blue);
      gi_124 = TRUE;
   }
   if (gi_136 == FALSE && gi_128 == FALSE) {
      g_price_140 = g_ima_204 + gd_212 + gd_164;
      if (g_price_140 < Bid + gd_172) g_price_140 = Bid + gd_172;
      g_price_140 = NormalizeDouble(g_price_140, Digits);
      OrderSend(Symbol(), OP_SELLLIMIT, Lots(), g_price_140, 3, g_price_140 + gd_148, g_price_140 - gd_156, "", 0, 0, Red);
      gi_128 = TRUE;
   }
}
//==================================================================================================================
double Lots() {
   g_minlot_220 = NormalizeDouble(AccountEquity() * TradeVolume / 100.0 / 1000.0, 1);
   double l_minlot_0 = MarketInfo(Symbol(), MODE_MINLOT);
   if (g_minlot_220 == 0.0) g_minlot_220 = l_minlot_0;
   return (g_minlot_220);
}
//==================================================================================================================

Recommend