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

 
Dimka-novitsek:
I'm moving this kind of writing now, the stop moves exactly when the profit reaches 30 pips (minus the spread, etc.), at a distance of 15 pips from the price.

And the order is always modified? If I try to place it manually, it won't move and I get the message Invalid S/L...
 
Tell me, will this function, i.e. this form select orders from the last closed and in order?
for ( i=0; i<OrdersHistoryTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
         if (OrderSymbol()!=Symbol())     continue;
         
         if (OrderMagicNumber()==1000 || OrderMagicNumber()==2000) {
            if (0<OrderClosePrice()) {
                Profit=OrderClosePrice();
                
               }
            if (0>OrderClosePrice()) {
                Loss=OrderClosePrice();   
               }
            }
         }
      }
      
 

first_may:



And the order is always modified? When I try to set it manually, it's not set and I get the message Wrong S/L...


Well, it must be wrong, on the wrong side or closer than 10 pips to the price depending on what the broker allows for this pair

My S/L is modifiable? no complaints.

 
Dimka-novitsek:


Well, it must be wrong, on the wrong side, or closer than 10 pips to the price.

Is it modifying? I'm not complaining.


Well, let's say EURAUD - stop loss cannot be set less than 100 pips, and I would like to memorize the breakeven level and move it...
 
first_may:

Well, let's say EURAUD - you cannot place a stop loss of less than 100 pips and I would like to remember the breakeven level when placing an order and move it...

I see...
 
first_may:

Well, let's say the pair EURAUD - here you can not put a stop loss of less than 100 pips and I would like to memorize the breakeven level and move it...

Use a virtual StopLoss level. As you write here, remember the price (store it in a variable). If price moves below (for BUY) or above (for SELL) virtual level, use OrderClose() function.

This is the only way to make a loss (profit) slightly more (less) than we want. The price rarely stops at the level we want. But this variant is quite acceptable for trading. It's true, I did not trade with this method.

 
MaxZ:

Use a virtual StopLoss level. As you write here, remember the price (store it in a variable). If price moves below (for BUY) or above (for SELL) virtual level, use OrderClose() function.

This is the only way to make a loss (profit) slightly more (less) than we want. The price rarely stops at the level we want. But this variant is quite acceptable for trading. I have not traded using this method.


Is storing in a variable a global one? And if you need to store for several securities at the same time, you need an array?
 
first_may:

Is storing in a variable some kind of global one? And if you need to store for several papers at the same time, you need an array?
You are so intuitive. Don't be afraid to work with arrays. They won't eat you! :DD
 
MaxZ:
How smart you are. Don't be afraid of working with arrays. They won't eat you! :DD


Read: https://book.mql4.com/ru/variables/arrays . It turns out that I can arrange a two-dimensional array for say three pairs: double Mas_d[3][2] = {1, 0, 2, 0, 3,0};

while keeping in mind that:

the value of Mas_d[1][1] corresponds to e.g. the AUDCAD pair, and Mas_d[1][2] is the value of that pair;

the value of Mas_d[2][1] corresponds for example to AUDCHF pair and Mas_d[2][2] is the value of this pair;

value of Mas_d[3][1] corresponds for example to AUDJPY, and Mas_d[3][2] is the value of this pair,

the array elements retain their values between ticks. And then I will be able to change values of array elements according to the criterion I need. Did I understand correctly what you mean? :)

 
Folks, help: I have a condition in my EA which is to open a Buy position only if the low of the previous candlestick is below all the lows of the previous 40 candlesticks. The question: how to implement this enumeration of previous candlestick's lows and find out if the low of the previous candlestick was below the low of the previous candlestick? I thank you in advance.