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

 
kosmos0975:
Tried it. Can't see it yet. I'll try again.
Is it really necessary to make such a mess with indicators? Wouldn't it be easier to put everything into the Expert Advisor?
 
AlexeyVik:
Is it really necessary to make such a distortion of the indicators? Wouldn't it be easier to shove everything into the Expert Advisor?

Over time, the Expert Advisor will become encumbered with additional conditions for correct operation and will become inflexible.

(Maybe, it's a perversion. We Russians do not look for easy ways:)

 
Good afternoon!
How can "Market is closed" be defined in EA?
 
abeiks:
Good day!
How can you define "Market is closed" in Expert Advisor?

Why would you want to do that? If the market is closed, there will be no ticks, and therefore the Expert Advisor will not work.

But if you really need it, try this.

MarketInfo(Symbol(), MODE_TRADEALLOWED);

If the market is open, it returns 1. If the market is closed, it should return 0.)

 

Here's the thing - I need to determine the minimum and maximum price value of the last 100 bars, for example, and then fix the rise/decline when the price goes down/up, so I can draw a reversal pattern like 1 2 3. I cannot understand the difference between ArrayMaximum and iHighest functions. If I understand correctly, the result of their calculations will be only the index of the maximum bar in the specified interval of the array? Is it necessary to use the for operator when working with arrays for calculations, as in the example in question 26 from the textbook? I have changed this code to the following one

//-------------------------------------------------------------------- //multiprice.mq4 // Designed for use as an example in the MQL4.manual. //-------------------------------------------------------------------- extern int Quant_Bars=100; // Number of bars //-------------------------------------------------------------------- int start() // Special function start { int i; // Bar number double Minimum=Bid, // Minimum price Maximum=Bid; // Maximum price for(i=0;i<=Quant_Bars-1;i++) // From zero (!) to .) if (Low[i]< Minimum) // If < known Minimum=Low[i]; //then it will be Min if (High[i]> Maximum) // If > known Maximum=High[i]; // then it will be Max double Level_1, // Signal level 1 Level_2, // Signal level 2 Price; // Current price Level_1=Minimum; // Set the minimum level Level_2=Maximum; // Set the maximum level Price=Bid;                                  // Request price if (Price<Level_1) { // Checking the complex condition Alert("A pattern for sale has been formed"); } if (Price<Level_2) { // Checking the complex condition Alert("A pattern for buying has been formed"); // Report } return; } //-------------------------------------------------------------------- But it somehow produces a pattern for buying on every tick, while it should signal only when the minimum or the maximum has changed.  



 
silachara:

Why would you want to do that? If the market is closed, there will be no ticks, and therefore the Expert Advisor will not work.

But if you really need it, try this.

If the market is open, it returns 1. If the market is closed, it should return 0.)

Thanks!
For information. I need to calculate time between ticks.
I use OnTimer().
 
Deniskaaa:

Here's the thing - I need to determine the minimum and maximum price value of the last 100 bars, for example, and then fix the rise/decline when the price goes down/up, so I can draw a reversal pattern like 1 2 3. I cannot understand the difference between ArrayMaximum and iHighest functions. If I understand correctly, the result of their calculations will be only the index of the maximum bar in the specified interval of the array? Do calculations require use of for statement when working with arrays, like in the Textbook Problem 26? I changed this code to the following one




If you want to trade by these signals, you shouldn't. If you learn to program, write it correctly.

double

   Level_1, // Signal level 1 Level_2, // Signal level 2 Price; // Current price
on top.
for(i=0;i<=Quant_Bars-1;i++) replace with for(i=0;i<Quant_Bars; i++)
{
	 if (Low[i]< Minimum) // If < known 	 Minimum=Low[i]; // then it will be min 	 if (High[i]> Maximum) // If > known 	 Maximum=High[i]; // then it will be max
}
curly braces added.
if (Price<Level_2) change the sign if (Price > Level_2) above the top
 
kosmos0975:

If you want to trade on these signals, don't. If you learn to program, write correctly.


Thank you for your reply.
 

Started to learn how to work with files. I came across the term handle. The question arose after writing the code:

int filehandle;
filehandle=FileOpen("news.csv",FILE_READ);
Print("Файл открыт успешно. Хендл файла=", filehandle);
filehandle=FileOpen("news150901.csv",FILE_READ);
Print("Файл открыт успешно. Хендл файла=", filehandle);

After opening the first news.csv file, the program set the filehandle variable to 1. Next, the program opened the second news150901.csv file and set the filehandle variable to 2. It turns out that the program is now left with a handle value only from opening the second file. In other words, I killed the handle value for the first opened file. I.e. I can only access the data/content and close the second file? Is using one variable to store the handle of the open file a mistake? Is it a mistake to use one variable for storing the handle of the open file?

 
silachara:

Started to learn how to work with files. I came across the term handle. The question arose after writing the code:

After opening the first news.csv file, the program set the filehandle variable to 1. Next, the program opened the second news150901.csv file and set the filehandle variable to 2. It turns out that the program is now left with a handle value only from opening the second file. In other words, I killed the handle value for the first opened file. I.e. I can only access data/content and close the second file? Is using one variable to store the handle of the open file a mistake? Is it necessary to create a variable for the handle for each file to be opened?

When you open a file, you get an "access code" to it - a handle. As long as you have not closed it, you can work with the file through its handle, regardless of whether the other files are open or not.

P.S. Don't forget to close files (they are not closed in the example).

Reason: