[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 174

 
chief2000:

The question is no longer how to write the code, but at the level of an idea - is it possible to avoid multiple loops,

which puts a lot of load on the processor. For example, there was an idea to track the number of open STOP orders - if it has decreased by one, but the order has not been deleted => open a market order =>

its open time and type should be placed in an array. Something like this.

Any ideas are welcome.


Only duplicate all market order properties in arrays and compare them with current market orders. Compare them by ticket and if there is no match by order type, it means that the pending order has triggered, if it is not found in the array, it has gone into history, etc.

May come in handy https://www.mql5.com/ru/code/9366

 

Hello.

I'm really asking for code comparing the last two fractals (either up or down).

For me, it is still a wilderness.

Thanks in advance.

 

HOW TO CALCULATE THE NUMBER OF PROFITABLE LONG POSITIONS AND SEPARATELY THE NUMBER OF PROFITABLE SHORT POSITIONS IN THE PROCESS OF WORKING OF AN EA?

The strategy is as follows: if the number of profitable long positions since the start of the EA (or better, over the entire account history) is greater than the number of short positions, then only long positions should be allowed to be opened. And vice versa.

It is clear how to count these deals, if they are closed by the Expert Advisor: Close - Count. But if a position is closed by TP or SL, then ... ?

Maybe someone has a ready code of the function?

 
splxgf:

Only duplicate all properties of market orders in arrays and compare them with current market orders. Compare by ticket, if there is a mismatch by order type, it means that the pending order has triggered, if it is not found in the array, it means that it has gone into history, etc.

May be useful https://www.mql5.com/ru/code/9366

Thank you!

 
nemo811:

Hello.

I'm really asking for code comparing the last two fractals (either up or down).

For me, it is still a wilderness.

Thanks in advance.

In the simple case, something like:

      Fractal_Up[i+3]   = iFractals(NULL, 0, MODE_UPPER, i+3);
      Fractal_Down[i+3] = iFractals(NULL, 0, MODE_LOWER, i+3);


      if(Fractal_Down[i+3]>0) {
         Fractal_Sell_Low_3  = Fractal_Sell_Low_2;
         Fractal_Sell_Time_3 = Fractal_Sell_Time_2;

         Fractal_Sell_Low_2  = Fractal_Sell_Low_1;
         Fractal_Sell_Time_2 = Fractal_Sell_Time_1;

         Fractal_Sell_Low_1  = Fractal_Down[i+3];
         Fractal_Sell_Time_1 = Time[i+3];
      }


      if(Fractal_Up[i+3]>0) {
         Fractal_Buy_Up_3   = Fractal_Buy_Up_2;
         Fractal_Buy_Time_3 = Fractal_Buy_Time_2;

         Fractal_Buy_Up_2   = Fractal_Buy_Up_1;
         Fractal_Buy_Time_2 = Fractal_Buy_Time_1;

         Fractal_Buy_Up_1   = Fractal_Up[i+3];
         Fractal_Buy_Time_1 = Time[i+3];
      }
 
chief2000:

Thank you - we'll look into it
 
Roger:

Actually it's nonsense to ask such questions to an expert writer :) It turns out that you are not mature enough to be a beginner, so if you want to check if the calculated stops and takes are close to the open price of the order, you will probably learn nothing at all.
But of course not... ))) Advice is good )))) But it's been tested a long time! Takes and stops greater than the minimum allowable values ... And everything works great in the tester! But in "live" mode it doesn't want to open positions! Maybe, dear ROGER, I'm not mature enough to be a beginner yet ))))) But you should at least look at the code I wrote - if it's not too much trouble... Maybe you'll find a bug there...
 
7sintez:
Why not... ))) Advice is good )))) Only everything has been tested a long time ago! Takes and stops greater than the minimum allowable values ... And everything works great in the tester! But in "live" mode it doesn't want to open positions! Maybe, dear ROGER, I'm not mature enough to be a beginner yet ))))) But you should at least look at the code I wrote - if it's not too much trouble... Maybe you'll find a bug there...
I had such a bug in one brokerage house. It turned out that we should open an order with TP=0 and SL=0, and then set the required levels with OrderModify(). Otherwise, the error "Stops are too close" was shown all the time.
 
ikatsko:
I had such an issue with one brokerage company. It turned out that I had to open an order with TP=0 and SL=0, and then use OrderModify() to set the required levels. Otherwise, the error "Stops are too close" was shown all the time.
Thank you...! Perhaps this is the problem... I've looked through everything in my code - I can't find the error!!!
 

I did not find an answer in the search

how can i see from the script which indicators are on the chart, what parameters and indicators, in which subwindows they are located?

thanks