Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 72

 
//+------------------------------------------------------------------+
//| shetchik_barov.mq4 |
//| Copyright © 2012, FOX.RM |
//| fox.rm@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, FOX.RM"
#property link "http://www.niochem.net"

extern int LimitBar = 10;

double col_bar;
datetime ctat_SB=0;
//+------------------------------------------------------------------+
//| Custom indicator initialisation function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Dell();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+

int start() {
Dell();
string name_1;
int limit, i=0;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars;
limit=Bars-counted_bars;
if(ctat_SB==0) ctat_SB=Time[0];
if(limit>0) limit=0;
for(i=limit; i>=0; i--)
{
col_bar = iBarShift(NULL,0,ctat_SB)-iBarShift(NULL,0,Time[i]); //-- count the number of bars
if(iBarShift(NULL,0,ctat_SB)-iBarShift(NULL,0,Time[i])>=LimitBar) //-- limit by the specified number of bars
{
ctat_SB=Time[i]; //-- reset counter
}
//---- hang it on the chart
name_1 = "shetchik_barov";
SetText1(name_1,DoubleToStr(col_bar,0),Blue,14);
}
return(0);
}

//----
void Dell(string name_n = "shetchik_barov")
{
string vName;
for(int i=ObjectsTotal()-1; i>=0;i--)
{
vName = ObjectName(i);
if (StringFind(vName,name_n) !=-1) ObjectDelete(vName);
}
}
void SetText1(string name,string text, color c, int size)
{
ObjectCreate(name,OBJ_LABEL,0,0,0,0;)
ObjectSet(name,OBJPROP_XDISTANCE, 1100);
ObjectSet(name, OBJPROP_YDISTANCE, 20);
ObjectSetText(name,text,8, "Arial Black",c);

}

here's a tribute or tribute to the odmins, I don't know why he needs it

but please help me write some lines of code

condition when you open a new bar to display an alert new bar

I don't need to count them no need to multiply them no need to divide them no need such complicated code

 
sannin:

//--------------------------------------------------------------------
// newbar.mq4  
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------

bool New_Bar=false;                             // Флаг нового бара
//--------------------------------------------------------------------
int start()                                     // Спец. функция start
  {
   
//--------------------------------------------------------------------
   Fun_New_Bar();                               // Обращение к ф-ии
   if (New_Bar)                                 // Новый бар
      {
    //Ваши действия
      }
   return;                                      // Выход из start()
  }
//--------------------------------------------------------------------
void Fun_New_Bar()                              // Ф-ия обнаружения ..
  {                                             // .. нового бара
   static datetime New_Time=0;                  // Время текущего бара
   New_Bar=false;                               // Нового бара нет
   if(New_Time!=Time[0])                        // Сравниваем время
     {
      New_Time=Time[0];                         // Теперь время такое
      New_Bar=true;                             // Поймался новый бар
     }
  }
//--------------------------------------------------------------------
We read the textbook.
 
r772ra:
Read the textbook.


greatest thanks to the honour of honour and gratitude

I've honestly been looking all day.

 
if (OrderType()==OP_BUYSTOP ) OrderDelete(OrderTicket());

could you please add this line to it so that it closes orders only with a certain magician

 
sannin:
if (OrderType()==OP_BUYSTOP ) OrderDelete(OrderTicket());

could you please add this line to it so that it closes orders only with a certain magician

if (OrderType()==OP_BUYSTOP ) if (OrderMagicNumber()==MagicNumber ) OrderDelete(OrderTicket());
 
PapaYozh:


I CERTAINLY COULD HAVE GUESSED IT MYSELF...

THANK YOU SO MUCH.

 

Guys, help me close the code, how to do it please

tell me where to get the info!!!!!

 
laveosa:

Guys, help me close the code, how to do it please

tell me where to get the info!!!!!


If you have written the code then you can put restrictions on it yourself.
 
Good afternoon. How can I calculate a single Stop Loss for a series of orders with exact magic numbers so that this series of orders can close at breakeven. For example, there are 3 orders: 1 Buy lot 1.3320 with magic 1, 1 Buy lot 1.3345 with magic 2 and 1 Buy lot 1.3360 with magic 3. How do I calculate the total Stop Loss for all orders, so that when the order moves against the price it closes at breakeven?
 

Dear Gurus! I've encountered a problem with the EA looping. I have added the variable "t" to the code,

static datetime t;


if (MA_1_t >= 1.00035)
      {
      Opn_B = true; 
      t=Time[0];
      }
if(MA_2_t >= 1.0002)
  {
    if(Time[0]>t)
      {                                      
      Cls_B=true;                 
      }
   }

to exit a position after the bar at which the position was opened. I have a problem now: I want to exit after two bars after the signal. Can you please explain the problem?

Reason: