Questions from Beginners MQL4 MT4 MetaTrader 4 - page 2

 
Vladimir Karputov:

As you suggested, the compiler swears.

{
   Ticket=OrderSend(NULL,OP_BUY,Lot,Ask,slippage,0,0,NULL,magic,0,Blue);
   if(!Ticket>0)Print(GetLastError());
   else
   {
    if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)==true)
    if((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()))
    {
     TP=NormalizeDouble(Bid+TakeProfit*Point,Digits);
     bool modify=OrderModify(OrderTicket(),OrderOpenPrice(),TP,0,0);
      return;
    }
   }

Doesn't work.

 
Nickolay72:

As you suggested, the compiler swears.

{
   Ticket=OrderSend(NULL,OP_BUY,Lot,Ask,slippage,0,0,NULL,magic,0,Blue);
   if(!Ticket>0)Print(GetLastError());
   else
   {
    if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)==true)
    if((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()))
    {
     TP=NormalizeDouble(Bid+TakeProfit*Point,Digits);
     bool modify=OrderModify(OrderTicket(),OrderOpenPrice(),TP,0,0);
      return;
    }
   }

It doesn't work.

Here is your code:

if(! Ticket>0)Print(GetLastError()) --- Ticket is an integer number, i.e. "2354865". Now a question: can an integer not be ( !2354865) An integer can either be greater than "> 0" or less than "< 0" . This bool value can be false/true ( ! )

Further, this construction:if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)==true) --- it enumerates parameters by ticket, and if you view a concrete ticket, it makes no sense to check its magic number or symbol, i.e. it is obviously unnecessary:if((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()))

And lastly, such constructs are better bracketed to explicitly specify the order of mathematical tasks:NormalizeDouble(Bid+( TakeProfit*Point),Digits);
 
Vitaly Muzichenko:


And lastly, it is better to bracket such constructions to explicitly specify the order of matrix tasks:NormalizeDouble(Bid+( TakeProfit*Point),Digits);

No, you can do it without brackets. But when the sum has to be multiplied, then brackets are required.

 
poman:

can take the value of 0 bar open time with period D1, + add the number of seconds,

in the condition to compare the current time with the obtained time in the first line

in a pending order it is possible to put a number of seconds, time of life of the order.

Data_1=iTime(Symbol(),PERIOD_D1,0)+86400;  //время жизни ордера


Thanks for the tip!) It helped)
 

Help with the code, the advisor goes through all the bars, how to make it go through the last 200 bars! Thanks

int  i, k=iBars(Symbol(), 0);
for (i=1; i<k; i++)
 

Provider_Signal

Forum on trading, automated trading systems and testing trading strategies

Questions from Beginners

Provider_Signal, 2016.11.09 18:38

How to close all orders in EA on Friday night ? So as not to leave it for the weekend.

Found function DayOfWeek().

I can write a check

if (DayOfWeek() == 5)
{
//
}

But what kind of check should we write for time. For example, what if it was 22:00 ?


 
Vladimir Karputov:

Provider_Signal

But what kind of check to write for the time. For example what would it be 22:00 ?
extern int St_Hour   = 22;

if (Hour()==St_Hour)
 
Aibek Mugiynov:

Help with the code, the advisor goes through all the bars, how to make it go through the last 200 bars! Thanks

int  i, k=iBars(Symbol(), 0);
for (i=1; i<k; i++)
for (i=1; i<200; i++)
 

Hello, help.

If no buffer is filled on three bars, I fill the buffer.


     int BarCount=3;
    BER=true;
   for(int il=1;il<=BarCount;il++)
     {
      if(BufferPointUp[il]!= EMPTY_VALUE){BER=false;break;}
     }
     if(BER) BufferPointUp[i]=high[i];

It fills on all bars, indiscriminately.

But everything is correct if I do this.

if(BufferPointUp[i+1]== EMPTY_VALUE&&BufferPointUp[i+2]== EMPTY_VALUE&&BufferPointUp[i+3]== EMPTY_VALUE)BufferPointUp[i]=high[i];

How to dothis check in a loop ?

 
mila.com:
extern int St_Hour   = 22;

if (Hour()==St_Hour)
Thank you
Reason: