Ultima idea ((((. - pagina 6

 
Pyxlik2009 писал(а) >>
come aprire la posizione quando appare la freccia codice indicatore sulla prima pagina .
Nel codice EA inserisci il nome e le variabili esterne (le variabili stringa non funzionano in EA) in iCustom(...,...,"...", ..., ....,...) del tuo indicatore. Buona fortuna Gbvth
File:
 
quale codice dice di aprire buy e quale chiuso (e la domanda è dove si può leggere o consigliare come allegare un indicatore alter per far apparire una finestra quando la freccia
 
Pyxlik2009 писал(а) >>
quali punti di codice per aprire l'acquisto e quale per aprire la vendita (e la domanda è dove si può leggere o consigliare come attaccare un indicatore di alterazione che apparirebbe quando la freccia
Buy, Sell - comprare, vendere.
Alert() rallenterà molto. meglio un beep() nell'indicatore
File:
 
nikost >>:
Buy, Sell- покупка, продажа.
Alert() будет сильно тормозить.Лучше звуковой сигнал.Пример ф-ия Beep() в индикаторе

Intendevo quale codice indicatore punta a comprare e vendere, più precisamente ho chiesto come aprire una posizione a profitto, cosa puntare nel robot, quale parte del codice dell'indicatore per farlo aprire, ecco cosa intendevo)))
 

L'Expert Advisor aprirà un ordine sul segnale del tuo indicatore, la cosa principale è non confondersi con iCustom(..., ..., " ...", ..., ...).Leggi gli articoli di Rosh

 
nikost >>:

Советник сам откроет ордер по сигналу вашего индикатора,Главное не запутайтесь в ф-ии iCustom(..., ..., " ...", ..., ... ).Почитайте статьи автора Rosh


Grazie mille lo proverò ora)))
 
//+------------------------------------------------------------------+
//|                                          Arrows and Curves EA.mq4 |
//|           Простой эксперт использующий индикатор Стрелки и Линии |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006"
#property link      "kolas@list.ru"

// Параметры торговли для H4 EURUSD
extern double TrailingStop = 30;
extern double TakeProfit   = 30;
extern double StopLoss     = 80;

// Параметры  моего индикатора индикатора 
extern int Length = 20;
extern int Deviation = 1;
extern double MoneyRisk = 1.0;
extern int Signal = 1;
extern int Line = 1;
extern int Nbars = 10000;
extern bool SoundON = TRUE;

// Идентификация эксперта
extern string NameEA       = "Arrows and Curves";
extern int MAGICNUM        = 123;

double Lots;
double Sloss, Tprof;
bool Buy = false, Sell = false;
static int PrevBar = 0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() 
  {return(0);}
  
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() 
  {return(0);}
  
//+------------------------------------------------------------------+
//|  Получение сигналов на покупку и продажу                         |
//+------------------------------------------------------------------+
void Indicators() 
   {                  
      Buy = (iCustom(Symbol(),0,"BBANDS~1", Length, Deviation, MoneyRisk, Signal, Line, Nbars, SoundON, 0, 1) > 0) && (Time[0] != PrevBar);
      Sell = (iCustom(Symbol(),0,"BBANDS~1", Length, Deviation, MoneyRisk, Signal, Line, Nbars, SoundON, 1, 1) > 0) && (Time[0] != PrevBar);
   }
   
//+------------------------------------------------------------------+
//|  Вывод предупреждения об отправке ордера                         |
//+------------------------------------------------------------------+
void prtAlert(string str = "") 
  {
      Print(str);
      Alert(str);
  }
  
//+------------------------------------------------------------------+
//|  Расчет размера ордера                                           |
//+------------------------------------------------------------------+
void LotsSize()
   {
      Lots = FixedLots;
      if (PropotinalLots) Lots = MathCeil(AccountFreeMargin() / 10000 * PercentLots) / 10;
      if (Lots > 10000) Lots = 10000;
   }  
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() 
  {
   // Проверка истории
   if(Bars < SSP) 
     {
       Print("Not enough bars for this strategy - ", NameEA);
       return(-1);
     }
   // Расчет значений индикатора
   Indicators();
   
   // Расчет желаемого размера ордера
   LotsSize();   

   // Трейлинг и разворот
   int totalOrders = OrdersTotal();
   int numPos = 0;

   for(int i = 0; i < totalOrders; i++) 
     {
       OrderSelect(i, SELECT_BY_POS);    
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGICNUM) 
         {
           numPos++;
           // Проверяем покупку
           if(OrderType() == OP_BUY) 
             {
               // Закрываем при развороте
               if (Sell) 
               {
                  OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, Blue); 
                  numPos--;
               }
               else
               // Трейлинг стоп
               if(TrailingStop > 0) 
                 {
                   if(Bid - OrderOpenPrice() > TrailingStop*Point) 
                     {
                       if(OrderStopLoss() < (Bid - TrailingStop*Point))
                           OrderModify(OrderTicket(), OrderOpenPrice(), 
                                       Bid - TrailingStop*Point, OrderTakeProfit(), 0, Blue);
                     }
                 }
               
             } 
           else 
             // Проверяем продажу
             {
               // Закрываем при развороте
               if (Buy) 
               {
                  OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, Red);
                  numPos--;
               }
               else
               // Трейлинг стоп
               if(TrailingStop > 0) 
                 {
                   if(OrderOpenPrice() - Ask > TrailingStop*Point)
                     {
                       if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStop*Point)
                           OrderModify(OrderTicket(), OrderOpenPrice(), 
                                       Ask + TrailingStop*Point, OrderTakeProfit(), 0, Red);
                     }           
                 }
             }
         }
     }
     
   // Открываем новые ордера
   if(numPos < 1)
     {   
       // Если размер депозита устраивает
       if(AccountFreeMargin() < MinDepo)
         {
           Print("Not enough money to trade ", Lots, " lots. Strategy:", NameEA);
           return(0);
         }
       // Если есть сигнал на покупку
       if (Buy)
         {
           Sloss = Ask - StopLoss * Point;
           Tprof = Bid + TakeProfit * Point;
           PrevBar = Time[0];
            OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Sloss, Tprof, NameEA + CurTime(), 
                     MAGICNUM, 0, Green);
           prtAlert("Buying"); 
         }
       // Если есть сигнал на продажу
       if (Sell) 
         {
           Sloss = Bid + StopLoss * Point;
           Tprof = Ask - TakeProfit * Point;
           PrevBar = Time[0];
            OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Sloss, Tprof, NameEA + CurTime(), 
                     MAGICNUM, 0, Red);
           prtAlert("Selling"); 
         }
     } 

   return(0);
  }
quando si copiano gli errori (so di essere un idiota, ma vorrei che tutti spiegassero cosa c'è di sbagliato)
 

Sì, ho capito, ho cancellato il codice sbagliato, ora provo senza errori.

//+------------------------------------------------------------------+
//|                                          Arrows and Curves EA.mq4 |
//|           Простой эксперт использующий индикатор Стрелки и Линии |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006"
#property link      "kolas@list.ru"

// Параметры торговли для H4 EURUSD
extern double TrailingStop = 30;
extern double TakeProfit   = 30;
extern double StopLoss     = 80;

// Параметры  моего индикатора индикатора 
extern int Length = 20;
extern int Deviation = 1;
extern double MoneyRisk = 1.0;
extern int Signal = 1;
extern int Line = 1;
extern int Nbars = 10000;
extern bool SoundON = TRUE;
extern int SSP             = 6; 

// Параметры MM
extern double Slippage     = 3;
extern bool PropotinalLots = false; // Реинвестирование
extern double MinDepo      = 100;   // Минимальный депозит
extern double FixedLots    = 0.1;   // Фиксированный размер ордера
extern double PercentLots  = 10;    // Процент реинвестирования

// Идентификация эксперта
extern string NameEA       = "Arrows and Curves";
extern int MAGICNUM        = 123;

double Lots;
double Sloss, Tprof;
bool Buy = false, Sell = false;
static int PrevBar = 0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() 
  {return(0);}
  
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() 
  {return(0);}
  
//+------------------------------------------------------------------+
//|  Получение сигналов на покупку и продажу                         |
//+------------------------------------------------------------------+
void Indicators() 
   {                  
      Buy = (iCustom(Symbol(),0,"BBANDS~1", Length, Deviation, MoneyRisk, Signal, Line, Nbars, SoundON, 0, 1) > 0) && (Time[0] != PrevBar);
      Sell = (iCustom(Symbol(),0,"BBANDS~1", Length, Deviation, MoneyRisk, Signal, Line, Nbars, SoundON, 1, 1) > 0) && (Time[0] != PrevBar);
   }
   
//+------------------------------------------------------------------+
//|  Вывод предупреждения об отправке ордера                         |
//+------------------------------------------------------------------+
void prtAlert(string str = "") 
  {
      Print(str);
      Alert(str);
  }
  
//+------------------------------------------------------------------+
//|  Расчет размера ордера                                           |
//+------------------------------------------------------------------+
void LotsSize()
   {
      Lots = FixedLots;
      if (PropotinalLots) Lots = MathCeil(AccountFreeMargin() / 10000 * PercentLots) / 10;
      if (Lots > 10000) Lots = 10000;
   }  
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() 
  {
   // Проверка истории
   if(Bars < SSP) 
     {
       Print("Not enough bars for this strategy - ", NameEA);
       return(-1);
     }
   // Расчет значений индикатора
   Indicators();
   
   // Расчет желаемого размера ордера
   LotsSize();   

   // Трейлинг и разворот
   int totalOrders = OrdersTotal();
   int numPos = 0;

   for(int i = 0; i < totalOrders; i++) 
     {
       OrderSelect(i, SELECT_BY_POS);    
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGICNUM) 
         {
           numPos++;
           // Проверяем покупку
           if(OrderType() == OP_BUY) 
             {
               // Закрываем при развороте
               if (Sell) 
               {
                  OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, Blue); 
                  numPos--;
               }
               else
               // Трейлинг стоп
               if(TrailingStop > 0) 
                 {
                   if(Bid - OrderOpenPrice() > TrailingStop*Point) 
                     {
                       if(OrderStopLoss() < (Bid - TrailingStop*Point))
                           OrderModify(OrderTicket(), OrderOpenPrice(), 
                                       Bid - TrailingStop*Point, OrderTakeProfit(), 0, Blue);
                     }
                 }
               
             } 
           else 
             // Проверяем продажу
             {
               // Закрываем при развороте
               if (Buy) 
               {
                  OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, Red);
                  numPos--;
               }
               else
               // Трейлинг стоп
               if(TrailingStop > 0) 
                 {
                   if(OrderOpenPrice() - Ask > TrailingStop*Point)
                     {
                       if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStop*Point)
                           OrderModify(OrderTicket(), OrderOpenPrice(), 
                                       Ask + TrailingStop*Point, OrderTakeProfit(), 0, Red);
                     }           
                 }
             }
         }
     }
     
   // Открываем новые ордера
   if(numPos < 1)
     {   
       // Если размер депозита устраивает
       if(AccountFreeMargin() < MinDepo)
         {
           Print("Not enough money to trade ", Lots, " lots. Strategy:", NameEA);
           return(0);
         }
       // Если есть сигнал на покупку
       if (Buy)
         {
           Sloss = Ask - StopLoss * Point;
           Tprof = Bid + TakeProfit * Point;
           PrevBar = Time[0];
            OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Sloss, Tprof, NameEA + CurTime(), 
                     MAGICNUM, 0, Green);
           prtAlert("Buying"); 
         }
       // Если есть сигнал на продажу
       if (Sell) 
         {
           Sloss = Bid + StopLoss * Point;
           Tprof = Ask - TakeProfit * Point;
           PrevBar = Time[0];
            OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Sloss, Tprof, NameEA + CurTime(), 
                     MAGICNUM, 0, Red);
           prtAlert("Selling"); 
         }
     } 

   return(0);
  }
 
ora apre anche gli ordini ))))
nikost >>:

Советник сам откроет ордер по сигналу вашего индикатора,Главное не запутайтесь в ф-ии iCustom(..., ..., " ...", ..., ... ).Почитайте статьи автора Rosh

Grazie per aver spiegato tutto, userò la visualizzazione per vedere come si apre ora capisco che non è così complicato )))))
 

Se la freccia è apparsa, apre un ordine, prende 20 pips, per esempio si chiude e aspetta che appaia una nuova freccia,

Vorrei che la freccia aprisse un ordine e aspettasse che la nuova freccia si mostri e chiudesse allo stop e non al take profit.

nikost >>:

Non avrei potuto farlo senza di te ))))

Devo cambiarlo se voglio che si apra solo quando appare la freccia?

Motivazione: