[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 434

 

Help )

1.Instantaneous detection of a newly opened trade (not pending orders) order (manually opened and open with the help of an EA) If the system has detected an order which was not opened earlier. then it continues under number 2.

2. Any task is executed only once, just for this order.

After one more order has opened, the system starts working from point 1 to point 2 again.

Can you help someone who is new to programming?

Please help. How can we do this? I identify each new open order, with the subsequent task for 1-n time, just for this order, and so on forever, for each newly opened order.

Thank you.

There is an outline, but it does not index orders .

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{


//----

for (int k=OrdersTotal()-1;k>=0;k--)//Начинаем перебор всех открытых ордеров начиная с конца
{
RefreshRates();//Обновляем котировки, необходимо при модификации или закрытии ордеров
if (OrderSelect(k,SELECT_BY_POS,MODE_TRADES)==true&&OrderSymbol()==Symbol())//Выбираем ордер с номером из цикла, и проверяем, совпадает ли символ ордера с текущим
{
int cmd=OrderType();//В переменной cmd будем хранить тип ордера
if(cmd>1)//Нас интересуют только отложенные ордеры
{
//Что-то делаем
}
if (cmd==OP_BUY)//А вдруг на покупку ордер?
{
Alert (GetLastError());
}
if (cmd==OP_SELL)//Или на продажу?
{
Alert (GetLastError());
}
}
}
//----
return(0);
}

 

Hi all!

Can you tell me why this indicator does not plot every bar, I have to rearrange it to see the graph?

//+------------------------------------------------------------------+
//|                                                Ср.отклонение.mq4 |
//|                                                Copyright © 2011. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2011, Dimon"
#property  link      "todem5@gmail.com"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Lime
#property  indicator_level1  100
#property  indicator_style1  1
#property  indicator_level2  20
#property  indicator_style2  1
//#property  indicator_color2  Red
#property  indicator_width1  2
//---- indicator parameters
//---- indicator buffers
extern int period=24;
double     MacdBuffer[];
double     SignalBuffer[];
int tf, k;
string S;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   tf=Period();
   S=Symbol();
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   //SetIndexStyle(1,DRAW_LINE);
   
   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,MacdBuffer);
   //SetIndexBuffer(1,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Ср.отклонение.: "+period+", в %: ");
   SetIndexLabel(0,"MACD");
   //SetIndexLabel(1,"Signal");
//---- initialization done
      
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   if (!IsOptimization() && !IsTesting() && !IsVisualMode()) {
   k=WindowFind("Ср.отклонение.: "+period+", в %: ");
   ObjectDelete("OrdCr2");
   ObjectCreate("OrdCr2", OBJ_LABEL, k, 0, 0);
   ObjectSet("OrdCr2", OBJPROP_CORNER, 2);
   ObjectSet("OrdCr2", OBJPROP_XDISTANCE, 5);
   ObjectSet("OrdCr2", OBJPROP_YDISTANCE, 22);
   ObjectSet("OrdCr2", OBJPROP_COLOR, Red);
   ObjectSetText("OrdCr2", "Ср.откл.1", 10, "Arial Black", Moccasin);
   }      
   double sum, f;
   int limit;
   int P;
   if (Digits==5) {P=100000;}
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit-period; i++){
      sum=0;
      for (int k=i+1;k<=i+period;k++){
      if (iHigh(Symbol(),tf,k)>iLow(Symbol(),tf,k)) {f=(iHigh(Symbol(),tf,k)-iLow(Symbol(),tf,k));}
      if (iHigh(Symbol(),tf,k)<iLow(Symbol(),tf,k)) {f=(iLow(Symbol(),tf,k)-iHigh(Symbol(),tf,k));}
      sum=sum+(f*P);
      }   
      MacdBuffer[i]=sum/24; 
      }
   
   return(0);
  }
//+------------------------------------------------------------------+
Files:
 
Roman.:
Guys, can you tell me how to replace in Excel the division (recognition by the prog) of the fractional part of a number with a comma to a dot? Thank you for your help.


Control Panel - Languages and Regional Standards

Change the standard to English, for example - semicolon becomes a full stop.
Resolve data transfer problems - then change back to the standard

 
Roman.:
Guys, can you tell me how to replace in Excel the division (recognition by the prog) of the fractional part of a number with a comma to a dot? Thanks for the help.

The second option is to change the separator in the Excel settings
 
abolk:


Control panel - Languages to regional standards

Change the standard to e.g. English - the comma becomes a full stop.
Resolve data transfer problems - then change back to the standard


Thank you
 
sergeev:


the second option is to change the separator in the Excel setting itself

Thank you... I've already done so on the advice of the Club President... :-))) How to change the separator in the settings of excel itself - I haven't found it.
 
Roman.:

excel - I couldn't find it.
version of excel?
 
sergeev:
version of excel?


2003г
 
Roman.:

2003г

Service-Settings-International
 
sergeev:

Service-Settings-International

Yep, got it, got it. Thank you. Changed it there too.
Reason: