[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 116

 
Roman.:

Guys, can you tell me why there might be an error about not being able to open an indicator in an EA?

This condition is met:

-List of parameters (if necessary). Transmitted parameters must match the order of declaration and type of external (extern) variables of the custom indicator.


You should check the name of the indicator. It could be
 
Vinin:

I would have to check the indicator name. I do not know what it may be.


I checked the name. It's OK. Figuring it out...

P.S. I set up a five-digit DC terminal, moved everything there, double-checked everything again, lots of code edits, no such error occurs anymore.

 
O MQL programming gurus, help a newcomer solve a problem. The program doesn't work correctly, it doesn't do what it's supposed to do. Could you please tell me what is my error? The program needs:
1. Open an order and assign the opening price value to the PriceBuy variable and display a message about it.
2. Open a new order with the same conditions when TakeProfit is reached.
Here is the program code:

extern double PriceBuy = 0;
extern bool Buy = true;
extern bool number = false;

int start()
{
if(Buy)
{
int ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-100*Point,Bid+100*Point);
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)
PriceBuy=OrderOpenPrice();
Alert("Buy Price = ",PriceBuy);
Buy = false;
number = true;}

if (Bid+100*Point<=PriceBuy && number)
{PriceBuy = 0;
number = false;
Buy=true;}


return;
}
Thanks in advance
 
OTPOK:

O MQL programming gurus, help a newcomer solve a problem. The program doesn't work correctly, it doesn't do what it's supposed to do. Could you please tell me what is my error? The program needs to:
1. open an order and assign the open price value to the PriceBuy variable and display a message about it.
To open a new order with the same conditions when TakeProfit is reached.
Here is the program code:


extern double PriceBuy = 0;
extern bool Buy = true;
extern bool number = false;

int start()
{
if(Buy)
{
int ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-100*Point,Ask+100*Point);
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
PriceBuy=OrderOpenPrice();
Alert("Buy Price = ",PriceBuy);
Buy = false;
number = true;}

if(Bid+100*Point<=PriceBuy && number)
{PriceBuy = 0;
number = false;
Buy=true;}


return;
}
Thanks in advance

Bid>=PriceBuy+100*Point
 

I want to connect CreateNamedPipe() function from kernel32.dll. I need to prescribe flags of Dword type.

I'm doing it this way:

#define ACCESS_SYSTEM_SECURITY 0x01000000L

Naturally, the compiler swears at the L at the end. Would you tell me what to do?

 
Vinin:

I have to check the indicator name. It may be.


Yes, really, Victor, my mistake was that I tried to address it automatically... :-))) to the indicator via

...
string short_name;
...
short_name="NonLagMA";
IndicatorShortName(short_name);
...

... I have not found the "short" and "normal" names, when addressing to the indicator values through iCustom(), i.e. when they don't coincide, the indicator should be addressed only by its "normal" name.

Thank you.

 

Hello.

Please help me find an error.

The code is designed to close all positions when the price crosses the line drawn on the chart. Most of the time it does. But periodically there are 2 glitches: 1. Price crosses the line, but positions are not closed. 2. The line intersects the current price level (at an angle), but does not coincide with it (does not affect the current candle), while all positions are closed (which should not happen).

int start() {
//============== Закрытие по линии Close ========================================
   int bar1,bar2,bar3;
   if (Draw_Close && ObjectFind("LINES CLOSE")==-1)
   {
      bar3 = searcFR(0,1);bar2 = searcFR(bar3,-1);bar1 = searcFR(bar2,1);
      drawline("LINES CLOSE",Color_Close,Time[bar1],High[bar1]+15*Point,Time[bar3],High[bar3]+15*Point);
   }
   string order = checkapp();
   if (order=="LINES CLOSE")
   {DeleteAllOtlozh_b();
    CloseAll_b(DeleteOtlozh,Proskalz);
    ObjectDelete("LINES CLOSE");
    ObjectDelete("LINES CLOSE n");
    Draw_Close  = false;
    if(UseAlert){
    Alert("Уровень достигнут, заблокирован");
    } 
   } 
}     
//==================================================================================


//=========== Вычисление линии Close  =================================================================
int searcFR(int bar, int UP_DN)
{  while(true)//ищем 1 фрактал после bar
   {  bar++;
      if (Fractal(bar) == UP_DN) return(bar);} 
   return(0);  
}
//--------------------------------------------------------------------------
int Fractal(int br)
{  if (br <= 2) return(0);
   if (High[br] >= High[br+1] && High[br] > High[br+2] && High[br] >= High[br-1] && High[br] > High[br-2]) return( 1);
   if (Low [br] <= Low [br+1] && Low [br] < Low [br+2] && Low [br] <= Low [br-1] && Low [br] < Low [br-2]) return(-1);
   return(0);
}
//-------------------------------------------------------------------
int drawline(string Name, color col,int X1,double Y1,int X2,double Y2)
{
   if (ObjectFind(Name)==0)return; //Если обьект существует
   int X1g=Time[0];
   int X2g=Time[0]+Period()*1200;
   double Y1g=Y1+(Y2-Y1)*(X1g-X1)/(X2-X1);
   double Y2g=Y1+(Y2-Y1)*(X2g-X1)/(X2-X1);
   ObjectCreate(Name, OBJ_TREND, 0,X1g,Y1g,X2g,Y2g);
   ObjectSet   (Name, OBJPROP_COLOR, col);
   ObjectSet   (Name, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet   (Name, OBJPROP_WIDTH, 2);
   ObjectSet   (Name, OBJPROP_BACK,  false);
   ObjectSet   (Name, OBJPROP_RAY,   false);
   return;
}
//----------------------------------------------------------------------- проверка всех линий
string checkapp()
{
   int X_1,X_2,X_3;
   double Y_1,Y_2,Y_3;
   double shift_Y = (WindowPriceMax()-WindowPriceMin()) / 50;
   color col;
   for(int n=ObjectsTotal()-1; n>=0; n--) 
   {
      string Obj_N=ObjectName(n);
      if (ObjectType(Obj_N)!=OBJ_TREND) continue;
      if (StringFind(Obj_N,"LINES ",0)!=-1)//найден обьект-тренд к которому вычисляется приближение
      {
         X_1 = ObjectGet(Obj_N, OBJPROP_TIME1); 
         X_2 = ObjectGet(Obj_N, OBJPROP_TIME2); 
         ObjectDelete (Obj_N+" n");
         if (X_1>X_2 ||  X_2<Time[0]) {continue;}//ObjectDelete(Obj_N);
         Y_1 = ObjectGet(Obj_N, OBJPROP_PRICE1);
         Y_2 = ObjectGet(Obj_N, OBJPROP_PRICE2);
         col= ObjectGet(Obj_N, OBJPROP_COLOR);
         ObjectCreate (Obj_N+" n", OBJ_TEXT,0,X_1-Period()*60,Y_1+shift_Y,0,0,0,0);
         ObjectSetText(Obj_N+" n",StringSubstr(Obj_N,6,5) ,7,"Arial");
         ObjectSet    (Obj_N+" n", OBJPROP_COLOR, col);
         if (X_1<=Time[0] && X_2>=Time[0])//попадает во временной диапазон
         {
            X_3=Time[0];Y_3=Y_1+(Y_2-Y_1)*(X_3-X_1)/(X_2-X_1);//уравнение прямой
            if (Y_3>=Bid&&Y_3<=Ask)
            { 
               return(Obj_N);
            }
         }
      }
   }
}

I thank you in advance.

 
nemo811:

Please help me find the error.

Withdrawing the question, I've figured it out.

 
toropchin:

I want to connect CreateNamedPipe() function from kernel32.dll. I need to prescribe flags of Dword type.

I'm doing it this way:

#define ACCESS_SYSTEM_SECURITY 0x01000000L

Naturally, the compiler swears at the L at the end. What do you suggest?

Zhunko:

Remove the digit. There can only be 8 bits. MQL4 does not work with big ones.

You need to remove an extra zero. Try it like this: 0x1000000L


It doesn't work like this. Compiler gives error '0x1000000L' - invalid number
 
toropchin:

It does not work like that. The compiler generates the error '0x1000000L' - invalid number

Not thinking at all at night... :-)) There is no such number in the 16 bit system. It is an identifier of a constant type.

L should be removed:0x01000000

Reason: