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

 
Snower: The yellow line is the price channel that the price should break through, and that the order would open with a smiley face candle, and all the ones before that would be ignored

in your piece of code, is the price channel channel_top and channel_bottom defined above? Where is the definition of a pin bar?

 
Vitaly Muzichenko:

Reply

Artyom, you didn't read it carefully: the TS needs to open only at a pin bar breakout, respectively, if you prescribe a pin bar (small body and large shadows), the condition can be met

Vitaly, I was answering to this:

...and ignored all the ones before...

If all the ones that were before were pin bars, then how can you ignore them when they were current, were pin bars crossing the line?

 
Sergey Likho:

How is the iCustom function handled in MT4? Please reply to those who know about it!


For example, in the strategy tester an Expert Advisor accesses the indicator at every tick.

When the function is called, the indicator is loaded into the memory, recalculates all values from zero bar to Bars and then returns the value at the required offset.

If I request the value of 1 bar on the first tick and the value of the second bar on the second tick, then my Expert Advisor will calculate the indicator twice on the entire history?


If the Expert Advisor accesses the indicator1, and it has iCustom to the indicator2. How many times will the indicator2 be recalculated when requesting the value of indicator1?


Maybe, the Strategy Tester and the MT4 terminal stores the indicator values on every bar, so that not to recalculate them at the repeated request?

It all depends on the realization of the indicator. If the calculation is correct, then the indicator calculates only the current bar - the others were calculated at (rates_total-prev_calculate)>1

 

how to average iMAOnArray over an array if there areEMPTY_VALUE values in the array ?

 
Максим Дмитриев:

how to average iMAOnArray over an array if there areEMPTY_VALUE values in the array ?


I see! If at least one value in the averaging sample isEMPTY_VALUE, then the iMAOnArray value at that point is alsoEMPTY_VALUE.

 

Good day to you all. I am testing an EA. I am not going to trade with it, but only to check some regularity. The EA opens an order on every minute candlestick and if the order is closed on a SL, it opens another BUY order at close price on a SL.


int start()                                             
{
if(Bid == iOpen(NULL,PERIOD_M1,0))
if ( G != Minute() )
{
OrderSend(Symbol(),OP_SELL,0.1,Bid ,3,Ask+400*Point,Ask-200*Point,Y10,123 );
G  =  Minute();
}
////*******   Если в списке закрытых ордеров есть ордер закрытый по СЛ - открыть другой ордер
int Счетф=0,  Номерф=OrdersHistoryTotal()-1;
for( ; Номерф>=0; Номерф--)
{
if(!OrderSelect(Номерф, SELECT_BY_POS, MODE_HISTORY)) continue;
if(OrderProfit()>=0) break;
Счетф++;
if(Счетф>0)
if(TimeCurrent()==OrderCloseTime())
OrderSend(Symbol(),OP_BUY,1,Ask,1,Bid-400*Point,Bid+200*Point,Y11,123 );
}
return;
}

The problem is... If several orders are closed on one tick and the last order is closed on a PI, the BUY order I need is not opened. This is because the program thinks that the last order was closed by a TP, not by a SL. Here is an example of such a situation

13:38:15.859 2008.01.02 15:01:46 Tester: stop loss #232 at 1.46566 (1.46560 / 1.46562)

13:38:15.859 2008.01.02 15:01:46 Tester: stop loss #233 at 1.46566 (1.46560 / 1.46562)
13:38:15.859 2008.01.02 15:01:46 Tester: take profit #302 at 1.46562 (1.46560 / 1.46562)
13:38:15.859 2008.01.02 15:02:00 MACD Sample EURUSD,M1: open #347 sell 0.10 EURUSD at 1.46570 sl: 1.46972 tp: 1.46372 ok
Could you please explain what language structure should be used to open a BUY order on one tick right after the SL order is closed on the same tick with the SL order.

Thank you.

 

Hello!

I've already racked my brains. How do I check if there is a certain price in the double array?

I wrote it like this for the test:


double prmas[5] = {11,22,33,44,99};

ArrayBsearch(prmas,OrderOpenPrice(),WHOLE_ARRAY,0,MODE_ASCEND));


The script finds 11, 22, 33, 44 without any problems (the terminal has such orders). However, if the script processes the price of 45, for example, it still shows 3 (position of the price 44 in the array).

What I really need is a bool - if there is a price of the order being processed in the array, it should return true, if not, it should return false. But I haven't found such a function in the language yet.

 

Good afternoon. Can you tell me why the file is not being created and the data is not being written to:

   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
   string file_name=terminal_data_path+"\\MQL4\\Files\\VolC(Symbol(),Period())";
   int file_handle=FileOpen(file_name,FILE_READ|FILE_WRITE|FILE_TXT);
   FileWrite(file_handle,(double)V5);
   FileClose(file_handle);
 
YarTrade: Good afternoon. Can you tell me why the file is not being created and the data written to it?

Examine the Files folder carefully!!! Always write to the sandbox = File folder . Try it this way:

   string file_name=VolC(Symbol(),Period());  // А кто такой ВолК = VolC  ???
   int file_handle=FileOpen(file_name,FILE_READ|FILE_WRITE|FILE_TXT);
   FileWrite(file_handle,(double)V5);
   FileClose(file_handle);
 
STARIJ:

Examine the Files folder carefully!!! Always write to the sandbox = File folder . Try it like this:


VolC - I named the file that way. Isn't the file name needed?

Reason: