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

 
pu6ka:

What is ma2 ?

Meaning of the slip indicator
 
Example2:

The value of the sliding bar indicator


Print the value of the slides. Because of the ticks on the zero bar, the value of the MA on the second bar does not change.

Here you have each tick coming in and changing the same value in the order.

 
pu6ka:


Print the value of the slides. Because of the ticks on the zero bar, the value of the MA on the second bar does not change.

Here you have each tick coming in and changing the same value in the order.


I simply changed the check to if(OrderOpenPrice()!=NormalizeDouble(ma1,Digits) and the error disappeared. I'll take your comment into account though, thanks
 
artmedia70:
Then pay attention to the price in the trade order. Buy closes at Bid, Sell closes at Ask. You have no check for order type there and therefore no price choice - either Ask or Bid


Only sells are opened in the EA. That is why I have not specified it explicitly. Or maybe you should still specify it and it may cause an error. I have closed a sell on Ask.
 
001:

In the EA, only sells are opened. That's why I didn't specify it explicitly. Or should I specify it anyway, maybe it is the cause of error? And I am closing a sell on Asc.

Maybe try it this way:

//+------------------------------------------------------------------+
bool CheckForLongetivityClose_Sell(int symbol, int magic) {
   if(DayOfWeek()==0 || DayOfWeek()==6) return;
   for(int i=OrdersTotal()-1; i>=0; i--) {
      if(OrderSelect(i,SELECT_BY_POS)) {
         if(OrderMagicNumber()!=magic) continue;
         if(OrderSymbol()!=symbol)     continue;
         if(OrderType()!=OP_SELL)      continue;
         datetime openTime_S= OrderOpenTime();
         int timeDistance_S = TimeCurrent()-openTime_S;
         if(timeDistance_S>60*BarrierMinute_S) {
            if(OrderClose(OrderTicket(),OrderLots(),Ask,3,clrRed)) return(true);
            }
         }
      }
   return(false);
}
//+------------------------------------------------------------------+

I have entered a symbol and a magik in the variables to be passed. You don't have a check for them.

 
Example2:

I just changed the verification to if(OrderOpenPrice()!=NormalizeDouble(ma1,Digits) and the error disappeared. I'll take your comment into account though, thanks.
Well, it is good that you have found it out. Although on real numbers it is better to compare the difference, read the link. For example, if MathAbs(OrderOpenPrice() - ma1) >= _Point
 
Yesterday I asked a question about multitimescale RSI. Doesn't anyone know the answer to it? Actually, the question itself is herehttps://www.mql5.com/ru/forum/145455/page619#972686
 

I'm trying to copy the file programmatically, from the script. It doesn't work. What's the right way?

#import  "shell32.dll"
    int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); 
#import

int Copyini;

int start()
   {
    //-------------------------- Cкопируем ini файл в песочницу Тестера ----------
    //Copyini = ShellExecuteA(0, "Open", "xcopy", "\""+PuthTerminal+FileOptim1+"\" \""+PuthTester_h+"\" /y", "", 3);
    //Copyini = ShellExecuteA(0,"Open","xcopy","D:\Alpari_Terminal\MQL4\Files\optimise.ini D:\Alpari_Terminal_Tester\tester\optimise.ini /y","",3);
    //Copyini = ShellExecuteA(0,"Open","xcopy","D:\Alpari_Terminal\MQL4\Files\optimise.ini D:\Alpari_Terminal_Tester\tester /y","",3);
      Copyini = ShellExecuteA(0,"Open","xcopy","D:\Alpari_Terminal\MQL4\Files\optimise D:\Alpari_Terminal_Tester\tester /y","",3);

    return(0);
   }
 
Leo59:

I'm trying to copy the file programmatically, from the script. It doesn't work. What's the right way?




#import "kernel32.dll"
  bool CopyFileW
       ( string lpExistingFileName,         // Имя файла источника
         string lpNewFileName,              // Имя нового файла
         bool   bFailIfExists );            // Не перезаписывать
#import




if (CopyFileW(srcFile , dstFile , False)) 
{

}
else
   ... ошибка



// под ваш случай

CopyFileW( "D:\\Alpari_Terminal\\MQL4\\Files\\optimise.ini" "D:\\Alpari_Terminal_Tester\\tester\\optimise.ini", False);

// или 

string sFileSRC =  "D:\\Alpari_Terminal\\MQL4\\Files\\optimise.ini";
string sFileDST =  "D:\\Alpari_Terminal_Tester\\tester\\optimise.ini;
if ( CopyFileW( sFileSRC,  sFileDST , False) )
{

}
else
{
   printf("error");
}

 
YuraZ:



Thanks!!!!!!!!!!!!

If you don't think it's impertinent.....:))) advise how to run the Tester properly. The way I'm trying, it's not working.

#import  "shell32.dll"
    int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); 
#import

int Start;

int start()
   {
    //---------------------------------- Запустим Тестер -------------------------
    //Start   = ShellExecuteA(0, "Open", "terminal.exe", FileOptim, PuthTester_h, 3);
    //Start   = ShellExecuteA(0, "Open", "terminal.exe", "optimise.ini", "D:\Alpari_Terminal_Tester\tester", 3);

    return(0);
   }