초보자의 질문 MQL4 MT4 MetaTrader 4 - 페이지 229

 
Aleksei Stepanenko :
감사합니다, 다른 해결책이 있습니까? 그 후, 고문은 거래를 열고 즉시 거래를 마감합니다.
 
Nargiz Ravanova :
감사합니다, 다른 해결책이 있습니까? 그 후, 고문은 거래를 열고 즉시 거래를 마감합니다.

제공된 시간을 수정해야 합니다.

op>=Profit

위치가 닫힐 때까지 다시 업데이트하지 마십시오.

그런 다음 현재 시간에서 기억하는 시간을 뺍니다.
지정된 초가 지나면 위치를 닫습니다.

 
input int Second=10;
ulong LastTime=0;

void OnTick()
   {
   if(op>=Profit) LastTime=GetMicrosecondCount();
   if(LastTime>0 && GetMicrosecondCount()-LastTime>(ulong)Second*1000000) {CloseAll(); LastTime=0;}
   }
 
input int Second = 10;
datetime LastTime = 0;

void OnTick()
  {
   if(op >= Profit && LastTime == 0)
      LastTime = TimeCurrent();
   if(LastTime > 0 && TimeCurrent() - LastTime >= Second)
     {
      CloseAll();
      LastTime = 0;
     }
  }
 

내가 그랬어


이중 연산 = 계산 이익();
int time_waiting=0;

if (op >= 이익)
time_waiting = TimeLocal() + 10;
if (TimeLocal() < time_waiting)
{
CloseAll();

}


하지만 그것은 나에게 오류를 제공합니다


유형 변환으로 인한 데이터 손실 가능성

 

이것은 오류가 아니지만 경고: 한 유형에서 다른 유형으로 변환할 때 데이터가 손실될 수 있습니다.

 datetime time_waiting;
 
Nargiz Ravanova :

즉, 고문이 2달러를 보자마자 즉시 닫는 것이 아니라 조금 더.

그리고 항상 10초 후에 이익이 더 크다는 것은 무엇입니까?)

 
MT4 "STRINGS: ASCII CHARACTER TABLE AND ITS USE"의 예에 따라 제작

 //+------------------------------------------------------------------+
//| StringLowerCase |
//+------------------------------------------------------------------+
string StringLowerCase( string str)
  {
   string s = str;
   int lenght = StringLen (str) - 1 , symbol;
   while (lenght >= 0 )
     {
      symbol = StringGetChar(s, lenght);
       if ((symbol > 64 && symbol < 91 ) || (symbol > 191 && symbol < 224 ))
         s = StringSetChar(s, lenght, symbol + 32 ); // тут possible loss of data due to type conversion
       else
         if (symbol > - 65 && symbol < - 32 )
            s = StringSetChar(s, lenght, symbol + 288 ); // тут possible loss of data due to type conversion
      lenght--;
     }
   return (s);
  }
//+------------------------------------------------------------------+
//| StringUpperCase |
//+------------------------------------------------------------------+
string StringUpperCase( string str)
  {
   string s = str;
   int lenght = StringLen (str) - 1 , symbol;
   while (lenght >= 0 )
     {
      symbol = StringGetChar(s, lenght);
       if ((symbol > 96 && symbol < 123 ) || (symbol > 223 && symbol < 256 ))
         s = StringSetChar(s, lenght, symbol - 32 ); // тут possible loss of data due to type conversion
       else
         if (symbol > - 33 && symbol < 0 )
            s = StringSetChar(s, lenght, symbol + 224 ); // тут possible loss of data due to type conversion
      lenght--;
     }
   return (s);
  }

어렵지 않다면 도와주세요..
 
s = StringSetChar(s, lenght, ushort (symbol + 32 ));
 string   StringSetChar(
   string &   string_var,       // строка
   int        pos,               // позиция
   ushort      value              // код символа
   );

다음 사실을 고려하여 모든 책임을 집니다.

짧은

unsigned short 유형은 ushort 이며 크기도 2바이트입니다. 최소값은 0이고 최대값은 65535입니다.

정수

정수형 int 의 크기는 4바이트(32비트)입니다. 최소값은 -2 147 483 648이고 최대값은 2 147 483 647입니다.

 
Iurii Tokman :

나는 당신이 말한 대로 했습니다. CloseAll() 함수 후에 내가 한 시간 동안 잠을 잔다는 사실에도 불구하고 닫은 후 고문이 거래를 몇 번 열고 닫습니다.

 input int Second = 10 ;
datetime LastTime = 0 ;

void OnTick ()

이중 연산 = 계산 이익();


if (op >= 이익 && LastTime == 0)
마지막 시간 = TimeCurrent();
if(마지막 시간 > 0 && TimeCurrent () - 마지막 시간 >= 초)

{
CloseAll();
마지막 시간 = 0;

SendNotification ("거래가 종료되었습니다");
절전(60*60000);// 60.000 = 1분

}