Last idea (((. - page 6

 
Pyxlik2009 писал(а) >>
how to open position when arrow appears indicator code on first page .
In the EA code insert the name and extern variables (string variables do not work in EA) into iCustom(...,...,"...", ..., ....,...) of your indicator. Good luck Gbvth
Files:
 
which code says to open buy and which one closed (and the question is where you can read or advise how to attach an alter indicator to make a window pop up when the arrow
 
Pyxlik2009 писал(а) >>
which code points to open buy and which one to open sell ( and the question is where you can read or advise how to stick an alter indicator that would pop up when the arrow
Buy, Sell - buy, sell.
Alert() will slow down much. better a beep() in the indicator
Files:
 
nikost >>:
Buy, Sell- покупка, продажа.
Alert() будет сильно тормозить.Лучше звуковой сигнал.Пример ф-ия Beep() в индикаторе

I meant what indicator code points to profit and buy, more exactly how to open a position to profit, what to point to in the robot, what part of the code of the indicator for it to open, that's what I meant))))
 

The Expert Advisor will open an order on the signal of your indicator, the main thing is not to get confused with iCustom(..., ..., " ...", ..., ...).Read the articles by Rosh

 
nikost >>:

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


Thank you very much I will try it now)))
 
//+------------------------------------------------------------------+
//|                                          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);
  }
when copying errors (I know I'm a moron, but I'd like everyone to explain what's wrong)
 

Yeah, I got it. I deleted the wrong code. I'll try it now without errors.

//+------------------------------------------------------------------+
//|                                          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);
  }
 
now it even opens orders ))))
nikost >>:

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

Thanks for explaining everything I'll use visualization to see how it opens them now I understand it's not that complicated )))))
 

If the arrow has appeared, it opens an order, takes 20 pips, e.g. it shuts down and waits until a new arrow appears,

I would like the arrow to open an order and wait for the new arrow to show and close at stop and not at take profit.

nikost >>:

I couldn't have done it without you ))))

i have to change it if i want it to open only when arrow appears ?

Reason: