[Scrivere un consulente gratis - pagina 21

 
Vinin >>:

Лучше убери. Смесь ломанного и еще неизвестно чего. Жуткая вещь получается. Хотя можешь в читабельный вид перевести.


L'Expert Advisor funziona solo in Buy.

Per favore, fatelo funzionare anche in Sell con gli ordini in sospeso.


L'essenza del lavoro: ad una distanza di 50 pps dal prezzo corrente impostare il Buy Stop e il Buy Limit con TP 100

due ordini a intervalli di 50 pps dal basso e 2 ordini dall'alto.

L'Expert Advisor funziona in modo tale che ci dovrebbero essere sempre almeno 2 ordini pendenti in entrambe le direzioni.


Grazie in anticipo :)
#property copyright "Slobodyan Oleg"
#property link      "http://www.metaquotes.net"

extern int Orders = 2;
extern double Lots = 0.01;
extern double StepLevel = 50.0;
extern int StopLoss = 3000;
extern int Profit = 100;
double gd_104 = 0.0;

int CheckBS() {
   double l_ord_open_price_12;
   double ld_20 = 0;
   int l_count_8 = 0;
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      if (OrderSelect( l_pos_4, SELECT_BY_POS, MODE_TRADES) == TRUE) {
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY || OrderType() == OP_BUYSTOP && OrderMagicNumber() == 1) {
            if (OrderOpenPrice() - Ask > ld_20 && OrderOpenPrice() - Ask > 0.0) {
               ld_20 = OrderOpenPrice() - Ask;
               l_ord_open_price_12 = OrderOpenPrice();
               l_count_8++;
            }
         }
      }
   }
   if ( l_count_8 == 0) {
      l_ord_open_price_12 = NormalizeDouble(Bid - StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_SELLSTOP, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 1, 0, Navy);
   }
   if ( l_count_8 < Orders && l_count_8 != 0) {
      l_ord_open_price_12 = NormalizeDouble( l_ord_open_price_12 + StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_SELLSTOP, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 1, 0, Navy);
   }
   return (1);
}

int CheckBL() {
   double l_ord_open_price_12;
   double ld_20 = 0;
   int l_count_8 = 0;
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      if (OrderSelect( l_pos_4, SELECT_BY_POS, MODE_TRADES) == TRUE) {
         if (OrderSymbol() == Symbol() && OrderType() == OP_SELL || OrderType() == OP_SELLLIMIT && OrderMagicNumber() == 2) {
            if (Bid - OrderOpenPrice() > ld_20 && Bid - OrderOpenPrice() > 0.0) {
               ld_20 = Bid - OrderOpenPrice();
               l_ord_open_price_12 = OrderOpenPrice();
               l_count_8++;
            }
         }
      }
   }
   if ( l_count_8 == 0) {
      l_ord_open_price_12 = NormalizeDouble(Ask - StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_BUYLIMIT, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 2, 0, Navy);
   }
   if ( l_count_8 < Orders && l_count_8 != 0) {
      l_ord_open_price_12 = NormalizeDouble( l_ord_open_price_12 - StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_BUYLIMIT, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 2, 0, Navy);
   }
   return (1);
}

int CheckBS_min() {
   double l_ord_open_price_12;
   double ld_20 = Ask;
   int l_count_8 = 0;
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      if (OrderSelect( l_pos_4, SELECT_BY_POS, MODE_TRADES) == TRUE) {
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY || OrderType() == OP_BUYSTOP && OrderMagicNumber() == 1) {
            if (OrderOpenPrice() - Ask < ld_20 && OrderOpenPrice() - Ask > 0.0) {
               ld_20 = OrderOpenPrice() - Ask;
               l_ord_open_price_12 = OrderOpenPrice();
               l_count_8++;
            }
         }
      }
   }
   if ( l_count_8 == 0) {
      l_ord_open_price_12 = NormalizeDouble(Ask + StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_BUYSTOP, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 1, 0, Navy);
   }
   if ( l_ord_open_price_12 - Ask >= 2.0 * StepLevel * Point && l_count_8 != 0) {
      l_ord_open_price_12 = NormalizeDouble( l_ord_open_price_12 - StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_BUYSTOP, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 1, 0, Navy);
   }
   return (1);
}

int CheckBL_min() {
   double l_ord_open_price_12;
   double ld_20 = Ask;
   int l_count_8 = 0;
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      if (OrderSelect( l_pos_4, SELECT_BY_POS, MODE_TRADES) == TRUE) {
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY || OrderType() == OP_BUYLIMIT && OrderMagicNumber() == 2) {
            if (Ask - OrderOpenPrice() < ld_20 && Ask - OrderOpenPrice() >= 0.0) {
               ld_20 = Ask - OrderOpenPrice();
               l_ord_open_price_12 = OrderOpenPrice();
               l_count_8++;
            }
         }
      
 
}
   }
   if ( l_count_8 == 0) {
      l_ord_open_price_12 = NormalizeDouble(Ask - StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_BUYLIMIT, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 2, 0, Navy);
   }
   if (Ask - l_ord_open_price_12 >= 2.0 * StepLevel * Point - 2.0 * (Ask - Bid) && l_count_8 != 0) {
      l_ord_open_price_12 = NormalizeDouble( l_ord_open_price_12 + StepLevel * Point, Digits);
      OrderSend(Symbol(), OP_BUYLIMIT, Lots, l_ord_open_price_12, 3, l_ord_open_price_12 - StopLoss * Point - 2.0 * gd_104, l_ord_open_price_12 + Profit * Point + gd_104, "", 2, 0, Navy);
   }
   return (1);
}

int init() {
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   gd_104 = 0;
   CheckBS();
   CheckBL();
   CheckBS_min();
   CheckBL_min();
   return (0);
}

File:
yolka_1.mq4  6 kb
 
Vinin писал(а) >>

Guarda qui. Sembra che funzioni bene.

Corretto un errore.

 
Vinin >>:

Ошибочку одну исправил

Grazie Victor, mi terrò in contatto se necessario

Gintaras

Vilnius.

 
Vinin >>:

Ошибочку одну исправил

Victor, quando hai tempo, per favore fai lo stesso per l'altra macchina.

Sinceramente.

 
dadi писал(а) >>

Victor, quando hai tempo, per favore fai lo stesso per l'altra macchina.

Con rispetto.

Ci proverò, ma è per questo.

 
Vinin >>:

Попробую, только вот зачем

Quando hai bisogno di orientarti, le vernici a senso unico ti risparmiano un sacco di problemi inutili.

 
Vedo che per qualche motivo ci sono lettere inutili aggiunte ai nomi...
 
dadi писал(а) >>

Io lavoro a mano, ho messo questo in cima e dà una buona entrata e uscita senza essere "incrociato". Quando hai bisogno di orientarti rapidamente, i colori unidirezionali risparmiano un'inutile confusione.

Allora forse i punti non sono affatto necessari.

 
dadi писал(а) >>

Se vuoi lavorare a mano, mettilo sopra e ottieni una buona entrata e uscita senza "in croce".