Navigation:Home > Content >

APS-Hedging_v.1.0~.mq4

Time: 2017-02-24 | Download file:APS-Hedging_v.1.0~.mq4

#property copyright "Copyright © 2008, WWW.FreeSignalForex.COM"
#property link "http://WWW.FreeSignalForex.COM"


extern string Website = "WWW.FreeSignalForex.COM";
extern string Pair = "USDCHF atau USDJPY";
extern double Lots = 0.1;
extern int TakeProfit = 100;
extern int StopLoss = 3000;
extern bool ConstantStop = true;
extern int Step1 = 100;
extern int TP1 = 100;
extern int Step2 = 100;
extern int TP2 = 100;
extern int Step3 = 100;
extern int TP3 = 100;
extern int Step4 = 100;
extern int TP4 = 100;
extern int Step5 = 100;
extern int TP5 = 100;
extern int Step6 = 100;
extern int TP6 = 100;
extern int Step7 = 100;
extern int TP7 = 100;
extern int Step8 = 100;
extern int TP8 = 100;
extern int Step9 = 100;
extern int TP9 = 100;
extern int Step10 = 10;
extern int TP10 = 10;
extern int StartHour = 0;
extern int EndHour = 24;
int gi1 = 3;
int gi2 = 2;
int gi3 = 111;
int gi4 = 1104562800;
// datetime gi4 = D'2005.01.01 07:00:00';
int gi5 = 1533279600;
// datetime gi5 = D'2018.08.03 07:00:00';
string gs1 = "Silahkan Trading Live";


int start()
{
int li1, li2, li3, li4, li5, li6, li7, li8;
double ld1, ld2, ld3, ld4, ld5, ld6, ld7, ld8, ld9, ld10, ld11, ld12, ld13, ld14, ld15, ld16, ld17, ld18;

/* !!! block begin */
if (((Year() > 2015) || (DayOfYear() > 360)) == 1)
{
  Alert( "EA-APS_Hedging Expaired, Please Contact WWW.FreeSignalForex.COM" );
  return( 0 );
}

li1 = 0;
li2 = 0;
li3 = 0;
li4 = 0;
li5 = 0;
li6 = 0;
ld5 = 0;
ld6 = 0;
ld7 = 0;
ld8 = 0;
ld9 = 0;
ld10 = 0;
ld11 = 0;
ld12 = 0;
ld13 = 0;
ld14 = 0;
ld15 = 0;
ld16 = 0;
for (li7 = 0;(li7 < OrdersTotal());li7 = li7+1) 
{  OrderSelect( li7, 0, 0 );
  if (((OrderSymbol() == Symbol()) && (OrderMagicNumber() == gi3)) == 1)
  {
    if (((OrderType() == 0) && (li1 < OrderTicket())) == 1)
    {
      ld5 = OrderLots();
      ld7 = OrderOpenPrice();
      li1 = OrderTicket();
      ld10 = OrderTakeProfit();
      if (OrderLots() == Lots) ld15 = (OrderOpenPrice() - (StopLoss * Point));
    }

    if (((OrderType() == 1) && (li2 < OrderTicket())) == 1)
    {
      ld6 = OrderLots();
      ld8 = OrderOpenPrice();
      li2 = OrderTicket();
      ld9 = OrderTakeProfit();
      if (OrderLots() == Lots) ld16 = (OrderOpenPrice() + (StopLoss * Point));
    }

    if (OrderType() == 2)
    {
      li3 = OrderTicket();
      ld13 = OrderLots();
    }

    if (OrderType() == 3)
    {
      li4 = OrderTicket();
      ld14 = OrderLots();
    }

    if (OrderType() == 4)
    {
      li5 = OrderTicket();
      ld11 = OrderLots();
    }

    if (OrderType() == 5)
    {
      li6 = OrderTicket();
      ld12 = OrderLots();
    }

  }

}
if (li1 == 0)
{
  if (li3 != 0) OrderDelete( li3 );
  if (li5 != 0) OrderDelete( li5 );
  ld2 = (Ask - (StopLoss * Point));
  if (StopLoss <= 0) ld2 = 0;
  if (((TimeHour( TimeCurrent() ) >= StartHour) && (TimeHour( TimeCurrent() ) < EndHour)) == 1)
  {
    if (((TimeCurrent() >= gi4) && (TimeCurrent() <= gi5)) == 1) {
         OrderSend( Symbol(), OP_BUY, Lots, Ask, gi1, ld2, (Ask + (TakeProfit * Point)), "APS_Hedging", gi3, 0, 16711680 );
    }
    else {
         Alert( gs1 );
    }

  }

}

if (li2 == 0)
{
  if (li4 != 0) OrderDelete( li4 );
  if (li6 != 0) OrderDelete( li6 );
  ld2 = (Bid + (StopLoss * Point));
  if (StopLoss <= 0) ld2 = 0;
  if (((TimeHour( TimeCurrent() ) >= StartHour) && (TimeHour( TimeCurrent() ) < EndHour)) == 1)
  {
    if (((TimeCurrent() >= gi4) && (TimeCurrent() <= gi5)) == 1) {
         OrderSend( Symbol(), OP_SELL, Lots, Bid, gi1, ld2, (Bid - (TakeProfit * Point)), "APS_Hedging", gi3, 0, 255 );
    }
    else {
         Alert( gs1 );
    }

  }

}

if (((li1 != 0) && (li3 == 0)) == 1)
{
  ld1 = (ld7 - (FinalStep( ld5 ) * Point));
  if (ConstantStop == 0) {
     ld2 = (ld1 - (StopLoss * Point));
  }
  else {
     ld2 = ld15;
  }

  if (StopLoss <= 0) ld2 = 0;
  OrderSend( Symbol(), OP_BUYLIMIT, NormalizeDouble( (2 * ld5), gi2 ), ld1, gi1, ld2, (ld1 + (FinalTP( ld5 ) * Point)), "APS_Hedging", gi3, 0, 16711680 );
}

if (((li2 != 0) && (li4 == 0)) == 1)
{
  ld1 = (ld8 + (FinalStep( ld6 ) * Point));
  if (ConstantStop == 0) {
     ld2 = (ld1 + (StopLoss * Point));
  }
  else {
     ld2 = ld16;
  }

  if (StopLoss <= 0) ld2 = 0;
  OrderSend( Symbol(), OP_SELLLIMIT, NormalizeDouble( (2 * ld6), gi2 ), ld1, gi1, ld2, (ld1 - (FinalTP( ld6 ) * Point)), "APS_Hedging", gi3, 0, 255 );
}

for (li7 = 0;(li7 < OrdersTotal());li7 = li7+1) 
{  OrderSelect( li7, 0, 0 );
  if (((((OrderSymbol() == Symbol()) && (OrderType() == 0)) && (li1 != 0)) && (OrderMagicNumber() == gi3)) == 1)
  {
    if (ConstantStop == 0) {
         ld2 = (ld7 - (StopLoss * Point));
    }
    else {
         ld2 = ld15;
    }

    if (StopLoss <= 0) ld2 = 0;
    if (li1 != OrderTicket()) {
         ld3 = ld10;
    }
    else {
         ld3 = OrderTakeProfit();
    }

    if (((ld3 != OrderTakeProfit()) || (ld2 != OrderStopLoss())) == 1) OrderModify( OrderTicket(), OrderOpenPrice(), ld2, ld3, 0, (-1) );
  }

  if (((((OrderSymbol() == Symbol()) && (OrderType() == 1)) && (li2 != 0)) && (OrderMagicNumber() == gi3)) == 1)
  {
    if (ConstantStop == 0) {
         ld2 = (ld8 + (StopLoss * Point));
    }
    else {
         ld2 = ld16;
    }

    if (StopLoss <= 0) ld2 = 0;
    if (li2 != OrderTicket()) {
         ld3 = ld9;
    }
    else {
         ld3 = OrderTakeProfit();
    }

    if (((ld3 != OrderTakeProfit()) || (ld2 != OrderStopLoss())) == 1) OrderModify( OrderTicket(), OrderOpenPrice(), ld2, ld3, 0, (-1) );
  }

}
return( 0 );
}

int FinalStep(double Pd1)
{
double ld2, ld3;

/* !!! block begin */
switch(NormalizeDouble( (Pd1 / Lots), 0 ))
  {
  case 1.0:
    return( Step1 );
  case 2.0:
    return( Step2 );
  case 4.0:
    return( Step3 );
  case 8.0:
    return( Step4 );
  case 16.0:
    return( Step5 );
  case 32.0:
    return( Step6 );
  case 64.0:
    return( Step7 );
  case 128.0:
    return( Step8 );
  case 256.0:
    return( Step9 );
  case 512.0:
    return( Step10 );
  }

return( Step10 );
}

int FinalTP(double Pd1)
{
double ld2, ld3;

/* !!! block begin */
switch(NormalizeDouble( (Pd1 / Lots), 0 ))
  {
  case 1.0:
    return( TP1 );
  case 2.0:
    return( TP2 );
  case 4.0:
    return( TP3 );
  case 8.0:
    return( TP4 );
  case 16.0:
    return( TP5 );
  case 32.0:
    return( TP6 );
  case 64.0:
    return( TP7 );
  case 128.0:
    return( TP8 );
  case 256.0:
    return( TP9 );
  case 512.0:
    return( TP10 );
  }

return( TP10 );
}

Recommend