Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1438

 

Please advise how best to proceed when optimising an EA:

There are many parameters that are responsible for indicator settings and there is a parameter that enables/disables this very indicator.


It makes absolutely no sense to optimise the indicator settings if it is disabled.

Question: How can I cut such meaningless overshoots?

 
ANDREY:

Thanks for the help and the new information for me . But it hit me and I came up with a much simpler way....
1. While opening the first order on a minute candlestick, I store in the X variable the LOW of that candlestick at the time of opening this first order.
2. When a zero candlestick opens (the next candlestick after the one on which the order opened), I get LoY[1]
. Then I turn logic and conclude
1. If X = LoY[1], then the order was opened after the LoY of the candlestick on which it was opened
2.If LoY[1]< X, it means that the price went down one more time after the order was opened and was lower than X. It means that the order was opened before LoY[] was formed on the given candlestick
Time LOW I needed only to know when the order was opened . before or after LoY[] formation.
And all orders on one minute candle open one above the other with a difference of 2 pips. That is, when the first one opened so did the others on this candlestick.
Thanks for the help.

But I have one more question.
I opened an order on a one-minute candlestick at X price. After a few seconds on the same candlestick, another order was opened at a price of X+2 pips. Between X and X+2 there is a price low.
I need to find out the low. If we deal with different candlesticks, I would use the iLow and iLowest functions
but these functions must specify bars as interval bounds. But my interval bounds are not bars, but the X and X+2 prices because there is only one bar.
I know how to find the minimum I need. But to do it, I need to track the price value on every tick. I also know how to do it with a cycle at the time of X+2. And how to do it all at once at the time of X+2 as in the case of iLow andiLowest.
I would be very grateful if you could teach me how to do this.
Thanks

Write the ticks to a file
 
MakarFX:
Write the ticks to a file

Thank you for the information that is new to me. I have never written ticks to a file. Where can I read more about it to understand how to do it ?

? Another question ..... can I write ticks with prices in an array, to sort the array with ticks and get the tick with the minimum price value? Or with the help of

ArrayMinimum


Thanks for the help.

 
ANDREY:

Thank you for the information that is new to me. I have never written ticks to a file. Where can I read more about it to understand how to do it ?

? Another question ..... can I write ticks with prices in an array, to sort the array with ticks and get the tick with the minimum price value? Or with the help of

ArrayMinimum


Thanks for the help.

Write to the file FileWriteString

In general, it's hard to understand what you need.

 
MakarFX:

FileWriteString

It's hard to know what you're looking for.

An order was opened on a one-minute candlestick at X price. A few seconds later on the same candlestick another order opened at X+2. Between X and X+2 there is a price low.
I need to find out the low. If we deal with different candlesticks, I would use the iLow and iLowest functions
but these functions must specify bars as interval bounds. But my interval bounds are not bars, but the X and X+2 prices because there is only one bar.
I know how to find the minimum I need. But to do it, I need to track the price value on every tick. I also know how to do it with a cycle at the time of X+2 . And how to do it all at once at the time of X+2 as in the case of iLow andiLowest.
I would be very grateful if you could teach me how to do this.
Thanks
 
ANDREY:

Thank you for the information that is new to me. I have never written ticks to a file. Where can I read more about it to understand how to do it ?

? Another question ..... can I write ticks with prices in an array, to sort the array with ticks and get the tick with the minimum price value? Or with the help of

ArrayMinimum


Thanks for the help.

It is possible. Only it is necessary to write into .bin file by function

uint  FileWriteArray( 
   int          file_handle,         // handle файла 
   const void&  array[],             // массив 
   int          start=0,             // начальный индекс в массиве 
   int          count=WHOLE_ARRAY    // количество элементов 
   );

and read

uint  FileReadArray( 
   int    file_handle,               // handle файла 
   void&  array[],                   // массив для записи 
   int    start=0,                   // стартовая позиция для записи в массив 
   int    count=WHOLE_ARRAY          // сколько читать 
   );
 
Alexey Viktorov:

You can. You just have to write to the .bin file with the function

and read

Thanks for the new to me information .... and not just new .... oooooooooo new ?:=) I will try to learn it myself....

 
ANDREY:

Thank you for the new information for me .... and not just new .... Very new ?:=) I'll try to digest it myself....

What's new here? You open documentation, read titles, find "File operations" section where description of different functions is given, including FileWriteArray()

It is not the first time I have reminded you that you should read the documentation more often. Even if you do not need it at the moment. By reading the section headings you will understand what is described in the documentation. You are the one who needs it the most.

 
Alexey Viktorov:

What's new here? Open the documentation, read the headers, find the "File operations" section where various functions are described, including FileWriteArray()

It is not the first time I have reminded you that you should read the documentation more often. Even if you do not need it at the moment. By reading the section headings you will understand what is described in the documentation. You are the one who needs it.

Thank you for the valuable advice. At the moment I'm reading documentation only when I'm writing code and I'm facing a question I don't know the answer to. I've never encountered a need to write data into files while writing my previous codes, so it's a totally new topic for me.
Tell me, can't my idea be realized in a simpler way, without writing it to a file? As in my code. This is not a working code but to illustrate my idea of how to find the minimum between two adjacent orders opened on one minute candlestick
Thanks for the help.

double P[60],Z;
int Tick,x,x1,G,G1,G2,T;

void OnTick()
{
Tick++;

if (OrdersTotal()==1&&Tick<2189)
{
P[x]=Bid;
Print("------------------------P[x]=Bid------------------------=", DoubleToString(P[x],5), "  x ",  x);
x++;
}
if (OrdersTotal()==2&&Tick==2189)
{
x1=x;
x=0;
ArraySort(P,WHOLE_ARRAY,0,MODE_ASCEND);
T=(60-x1);
Print("------------------------МИНИМУМ=------------------------=",DoubleToString(P[T],5), "  Tick ",  Tick, "  x1 ",  x);
}

if (Tick==2176||Tick==2188)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,Ask+300*Point,Ask-100*Point,"300",0);
G2=G;
G=Tick;
}
}

That is, I wrote the price of each tick directly into the array, not into a file.

 
ANDREY:

Thanks for the help and the new information for me . But it hit me and I came up with a much simpler way....
1. While opening the first order on a minute candlestick, I store in the X variable the LOW of that candlestick at the time of opening this first order.
2. When a zero candlestick opens (the next candlestick after the one on which the order opened), I get LoY[1]
. Then I turn logic and conclude
1. If X = LoY[1], then the order was opened after the LoY of the candlestick on which it was opened
2.If LoY[1]< X, it means that the price went down one more time after the order was opened and was lower than X. It means that the order was opened before the formation of LoY[] on the given candlestick


You may check the time but you are waiting for a new order and then ask for the maximum or minimum tick.

Reason: