[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 222

 
Hello. Can you tell me where I can read how to make transactions in the tester, by myself? I'd appreciate it.
 

Hi all.

I have a script that closes all available orders.

I don't understand three lines in it:

If it's not difficult, please translate it into Russian for a beginner.

I studied the tutorial, but I did not come across such long logical expressions.

The script I am attaching. Thank you.

Files:
 

Let me try to "translate" the first entry for you:

if(((OrderSymbol() == Symbol() && OnlyThisSymbol) || !OnlyThisSymbol))

"If at least one of the expressions 1. or 2. is true, then ... "
1.the order instrument is the same as the chart instrument and the external variable OnlyThisSymbol has the value true
2.The OnlyThisSymbol external variable has a value equal to false.

Now, the meaning of this entry:
There is an enumeration of orders to be closed by positions with different filters. This record is a filter by instrument. If you set the value of the onlyThisSymbol external variable, you can choose whether you want to close orders by chart symbols only, or orders by any symbols.

 
alsu:

Not exactly. The point is that the Experts variable already has int type, hence type conversion should take place BEFORE assigning a value to it, i.e. the compiler

* took out of the box a value of type double (it has no name in your program, and is written simply to some address known to the compiler in the main memory or in the register of CPU)

* made all necessary changes to the value of the above variable and wrote a new value (of int type!) into Experts variable,

* assigned this value (of int! type) to the variable New_Experts. They have the same type, so it's just a matter of transferring a value from one memory location to another.


P.S. It's great to see that there are people who comprehend their deeds in such detail. In fact, no kidding. Keep in touch.


Good day... Dealing with your last and penultimate messages I'm stumped. In particular (your message from the previous answer): "Then when we take a value out of the box, it is of the double type, but if we give the command to write the result into a variable of the int type, the compiler automatically takes all the necessary actions to put the value into a new box." And your message from the last answer: "The point is that the Experts variable already has the int type... Didn't we convert it to type double the moment we "put" it into a GV-variable box?

Thanks in advance for the answer

 

Can you advise me, friends? Does MQL4 allow setting the Account Balance value programmatically, and not only in the initial conditions of the tester?

I will explain why I need it, just to make the question clear. I want the Expert Advisor to change the Account Balance size as a variable during optimization.

 

Good afternoon.

I am trying to create an indicator to display Sl and Tp on the chart based on (H-L)/2, it does not work - it just draws by the close of the bar, what is the problem?

As the basis was taken by an indicator ATR.

//+------------------------------------------------------------------+
//|                                                          Tp/Sl.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 Green
//---- input parameters
extern int PeriodMM=25;
//---- buffers
double SlBuffer[];
double TpBuffer[];
double SlBuffer2[];
double TpBuffer2[];
double TempBuffer[];
double TempBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 1 additional buffer used for counting.
   IndicatorBuffers(4);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,SlBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,TpBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,SlBuffer2);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,TpBuffer2);
   SetIndexBuffer(4,TempBuffer);
   SetIndexBuffer(5,TempBuffer2);
//----
   SetIndexDrawBegin(0,PeriodMM);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=PeriodMM) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=PeriodMM;i++)
      SlBuffer[Bars-i]=0.0;
      TpBuffer[Bars-i]=0.0;
      SlBuffer2[Bars-i]=0.0;
      TpBuffer2[Bars-i]=0.0;
//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      double high=High[i];
      double low =Low[i];
      double close = Close[i];
      TempBuffer[i]=(high-low)/2;
      TempBuffer2[i]=(high-low)/2*2.5;
      i--;
     }
//----
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(i=0; i<limit; i++)
      SlBuffer[i]=Close[i]+iMAOnArray(TempBuffer,Bars,PeriodMM,0,MODE_SMA,i);
      TpBuffer[i]=Close[i]+iMAOnArray(TempBuffer2,Bars,PeriodMM,0,MODE_SMA,i);
      SlBuffer2[i]=Close[i]-iMAOnArray(TempBuffer,Bars,PeriodMM,0,MODE_SMA,i);
      TpBuffer2[i]=Close[i]-iMAOnArray(TempBuffer2,Bars,PeriodMM,0,MODE_SMA,i);
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Comrades I can't understand why CSV files are not being created, everything was working before.
//+------------------------------------------------------------------+
//|                                                          TP1.mq4 |
//|                                                      S.I.Shlikov |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "S.I.Shlikov"
#property link      ""
int init()  
  {
   int h=FileOpen("H"+(Period()/60)+".csv",FILE_CSV|FILE_WRITE|FILE_READ,";");
    if(h<1)
      {
      Print("Файл не найден : ", GetLastError());
      return(false);
      }
   FileSeek(h, 0, SEEK_END);
   FileWrite(h,"Date","EURUSD","GBPUSD","NZDUSD","USDJPY","EURJPY","GBPJPY","USDCHF","EURCHF","GBPCHF");
   FileClose(h);        
  }
int start()
  {
   int h=FileOpen("H"+(Period()/60)+".csv",FILE_CSV|FILE_WRITE|FILE_READ,";");
    if(h<1)
      {
      Print("Файл не найден : ", GetLastError());
      return(false);
      }
   string Wtime=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
   FileSeek(h, 0, SEEK_END);
   FileWrite(h,Wtime,DoubleToStr(iClose("EURUSD",Period(),0),MarketInfo("EURUSD",MODE_DIGITS)),
                     DoubleToStr(iClose("GBPUSD",Period(),0),MarketInfo("GBPUSD",MODE_DIGITS)),
                     DoubleToStr(iClose("NZDUSD",Period(),0),MarketInfo("NZDUSD",MODE_DIGITS)),
                     
                     DoubleToStr(iClose("USDJPY",Period(),0),MarketInfo("USDJPY",MODE_DIGITS)),
                     DoubleToStr(iClose("EURJPY",Period(),0),MarketInfo("EURJPY",MODE_DIGITS)),
                     DoubleToStr(iClose("GBPJPY",Period(),0),MarketInfo("GBPJPY",MODE_DIGITS)),
                     
                     DoubleToStr(iClose("USDCHF",Period(),0),MarketInfo("USDCHF",MODE_DIGITS)),
                     DoubleToStr(iClose("EURCHF",Period(),0),MarketInfo("EURCHF",MODE_DIGITS)),
                     DoubleToStr(iClose("GBPCHF",Period(),0),MarketInfo("GBPCHF",MODE_DIGITS))
                     );
   FileClose(h);   
   return(0);
  }
 
orb:
Comrades I can't understand why CSV files are not being created, everything was working before.

What is the error number?
 
sergeev:

what is the error number?
no error number...just no files created, looking for ALPARI\tester\files\
 
orb:
no error number... just not creating files, looking for ALPARI\tester\files\

Well, look in the other one.