← Назад к списку файлов

c1_basicea full.mq4

Поиск по коду файла

#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

extern int MagicNumber = 12345;
extern bool SignalMail = False;
extern double Lots = 1.0;
extern int Slippage = 3;
extern bool UseStopLoss = True;
extern int StopLoss = 30;
extern bool UseTakeProfit = True;
extern int TakeProfit = 60;
extern bool UseTrailingStop = True;
extern int TrailingStop = 30;

int P = 1;
int Order = SIGNAL_NONE;
int Total, Ticket, Ticket2;
double StopLossLevel, TakeProfitLevel, StopLevel;

int init() {
      // код доступен только после оплаты
   }

int deinit() {
   return(0);
}

int start() {
      // код доступен только после оплаты
   }

   Total = OrdersTotal();
   Order = SIGNAL_NONE;

   double Buy1_1 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 2);
   double Buy1_2 = iMA(NULL, 0, 40, 0, MODE_SMA, PRICE_CLOSE, 2);
   double Buy2_1 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 1);
   double Buy2_2 = iMA(NULL, 0, 40, 0, MODE_SMA, PRICE_CLOSE, 1);

   double Sell1_1 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 2);
   double Sell1_2 = iMA(NULL, 0, 40, 0, MODE_SMA, PRICE_CLOSE, 2);
   double Sell2_1 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 1);
   double Sell2_2 = iMA(NULL, 0, 40, 0, MODE_SMA, PRICE_CLOSE, 1);

   StopLevel = (MarketInfo(Symbol(), MODE_STOPLEVEL) + MarketInfo(Symbol(), MODE_SPREAD)) / P; // Defining minimum StopLevel

   if (StopLoss < StopLevel) StopLoss = StopLevel;
   if (TakeProfit < StopLevel) TakeProfit = StopLevel;

   bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      Ticket2 = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {

            if(Sell1_1 > Sell1_2 && Sell2_1 <= Sell2_2) Order = SIGNAL_CLOSEBUY; // Rule to EXIT a Long trade

            if (Order == SIGNAL_CLOSEBUY) {
               Ticket2 = OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               IsTrade = False;
               continue;
            }

            if(UseTrailingStop && TrailingStop > 0) {                 
               if(Bid - OrderOpenPrice() > P * Point * TrailingStop) {
                  if(OrderStopLoss() < Bid - P * Point * TrailingStop) {
                     Ticket2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - P * Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
                     continue;
                  }
               }
            }
         } else {

            if (Buy1_1 < Buy1_2 && Buy2_1 >= Buy2_2) Order = SIGNAL_CLOSESELL; // Rule to EXIT a Short trade

            if (Order == SIGNAL_CLOSESELL) {
               Tic

Показано первые 50% кода (символов: 4120)

Как получить полную версию?

Введите ваш email и нажмите кнопку, чтобы перейти к оплате.