[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 622

 
Rossi:

is there any way to sort the instruments in the tabs at the bottom of the screen? because 8 instruments in 4 timeframes are scattered in a mess....

no
 
DDFedor:

grab the tab with the name of the graph and drag it to the right place

AAAAAAAAAAAAAAAAAAAAAAAAAA great answer, thank you...
 
artmedia70:
:) Now error 130 has appeared. The most confusing thing is that with wrong stops (130) it still sets correct takeoffs (calculated by ATR), but my stops were not set from the beginning...
Is there any way to understand this?
An error of 130 could be either a wrong stoploss or a wrong takeprofit.
 
ToLik_SRGV:


I added Limit orders (I forgot about them in previous code :)) + error #1 processing (before modification new price is compared to current one, if they are the same, then nothing happens):

It seems that modified orders moved by the trawl closer to the market lose their TakeProfit inheritance... They, once triggered, hang on the chart in positions and stupidly consume margin. They don't close in profit or loss, and there is no TakeProfit line... Although, I purposely added tp value, calculated using ATR, to the code to check it:

void trailingOrder(int magic, int trailing){
   int index = 0, tp=TakeProfitATR (5);
   while(trailing > 0 && OrdersTotal() != 0 && OrderSelect(index, SELECT_BY_POS)){
      if(OrderMagicNumber() == magic){
         if(OrderType() == OP_BUYSTOP){
            if(OrderOpenPrice() - Ask > Point*trailing){
               if((Ask+Point*trailing) - Ask >= MarketInfo(Symbol(), MODE_STOPLEVEL)*Point &&
                 (Ask+Point*trailing) - Ask > MarketInfo(Symbol(), MODE_FREEZELEVEL)*Point &&
                 (Ask+Point*trailing) != OrderOpenPrice()){
                  if(!OrderModify(OrderTicket(),Ask+Point*trailing,OrderStopLoss(),
                  /*OrderTakeProfit()*/tp, 0, MediumSpringGreen))Print(">>> ERROR ", GetLastError());
               }else{
                  Print(">>> Слишком близко к рынку или передано неизмененное значение!");
               }
            }
            return;
         }
// ..... Далее по тексту функции также добавлены изменения...

Both before and after my changes the modified order did not have a take line either before or after its conversion to a position...

What can be the reason?

 
artmedia70:

It seems that modified orders moved by the trawl closer to the market lose their TakeProfit inheritance... They, once triggered, hang on the chart in positions and stupidly consume margin. They don't close in profit or loss, and there is no TakeProfit line... Although, I purposely added tp value, calculated using ATR, to the code to check it:

Both before and after modifications the modified order did not have a take line either before or after its conversion to a position...

What could be the reason?

When modifying the price of a pending order, the stoploss and takeprofit should also be modified.
 
khorosh:
Error 130 can be either the wrong stoploss or the wrong takeprofit.
Thank you. I already knew that... That wasn't the point. It was the trawl that gave me the error - I disabled it and everything's OK. I don't have time to deal with it yet.
 
khorosh:
When modifying pending order price, you should also modify StopLoss and TakeProfit.

Doesn't the ATR Take Profit function do that? I call it before modifying an order, get the current take value calculated by TakeProfitATR() and paste it into the order modification... This is in my example above:

int index = 0, tp=TakeProfitATR (5); // Рассчёт нового тейка по значению ATR. Ф-ция возвращает размер тейка в пунктах

....

if(!OrderModify(OrderTicket(),Ask+Point*trailing,OrderStopLoss(),
   /*OrderTakeProfit()*/tp, 0, MediumSpringGreen))Print(">>> ERROR ", GetLastError()); // здесь вместо OrderTakeProfit() подставляю tp
Looks like I found a mistake while writing this... The TakeProfit function by ATR returns TakeProfit value in pips, while the price should be used.
But then I don't understand why modified order was losing its takepoint value before these changes were done... Although, OrderTakeProfit() should write the value of its take point into the order being modified...
And then the question - why should I modify it (take) every time, if, say, I just want to move a pending order closer to the market without changing it, if the market has moved away from it and is ready for a reversal or correction... ???
 
artmedia70:

Doesn't the ATR Take Profit function do that? I call it before modifying an order, get the current take value calculated by TakeProfitATR() and paste it into the order modification... This is in my example above:

....

It looks like I found my mistake while writing this... The TakeProfit function by ATR returns TakeProfit value in pips, while the price should be used.
But then I don't understand why modified order still lost its takepoint value before these changes... Although, OrderTakeProfit() should write the value of its take point into the order being modified...
And then the question - why should I modify it (take) every time, if, say, I just want to move a pending order closer to the market without changing it, if the market has moved away from it and is ready for a reversal or correction... ???




I have added automatic stop and takeovers to my method. When you put a pending order you only have to set limiters and the method will drag everything to the right place :))

//+------------------------------------------------------------------+
void trailingOrder(int magic, int trailing){
   int index = 0;
   double takeprofit, stoploss;
   while(trailing > 0 && OrdersTotal() != 0 && OrderSelect(index, SELECT_BY_POS)){
      if(OrderMagicNumber() == magic){
         if(OrderType() == OP_BUYSTOP){
            if(OrderOpenPrice() - Ask > Point*trailing){
               if((Ask+Point*trailing) - Ask >= MarketInfo(Symbol(), MODE_STOPLEVEL)*Point &&
                 (Ask+Point*trailing) - Ask > MarketInfo(Symbol(), MODE_FREEZELEVEL)*Point &&
                 (Ask+Point*trailing) != OrderOpenPrice()){
                  if(!OrderModify(OrderTicket(),Ask+Point*trailing, Ask+Point*trailing-(OrderOpenPrice()-OrderStopLoss()), Ask+Point*trailing+(OrderTakeProfit()-OrderOpenPrice()), 0))Print(">>> ERROR ", GetLastError());
               }else{
                  Print(">>> Слишком близко к рынку или передано неизмененное значение!");
               }
            }
            return;
         }
         if(OrderType() == OP_SELLSTOP){
            if(Bid - OrderOpenPrice() > Point*trailing){
               if(Bid - (Bid-Point*trailing) >= MarketInfo(Symbol(), MODE_STOPLEVEL)*Point &&
                 Bid - (Bid-Point*trailing) > MarketInfo(Symbol(), MODE_FREEZELEVEL)*Point &&
                 (Bid-Point*trailing) != OrderOpenPrice()){
                  if(!OrderModify(OrderTicket(),Bid-Point*trailing,Bid-Point*trailing+(OrderStopLoss()-OrderOpenPrice()),Bid-Point*trailing-(OrderOpenPrice()-OrderTakeProfit()), 0))Print(">>> ERROR ", GetLastError());
               }else{
                  Print(">>> Слишком близко к рынку или передано неизмененное значение!");
               }
            }
            return;
         }
         if(OrderType() == OP_SELLLIMIT){
            if(OrderOpenPrice() - Bid > Point*trailing){
               if((Bid+Point*trailing) - Bid >= MarketInfo(Symbol(), MODE_STOPLEVEL)*Point &&
                 (Bid+Point*trailing) - Bid > MarketInfo(Symbol(), MODE_FREEZELEVEL)*Point &&
                 (Bid+Point*trailing) != OrderOpenPrice()){
                  if(!OrderModify(OrderTicket(),Bid+Point*trailing,Bid+Point*trailing+(OrderStopLoss()-OrderOpenPrice()),Bid+Point*trailing-(OrderOpenPrice()-OrderTakeProfit()), 0))Print(">>> ERROR ", GetLastError());
               }else{
                  Print(">>> Слишком близко к рынку или передано неизмененное значение!");
               }
            }
            return;
         }
         if(OrderType() == OP_BUYLIMIT){
            if(Ask - OrderOpenPrice() > Point*trailing){
               if(Ask - (Ask-Point*trailing) >= MarketInfo(Symbol(), MODE_STOPLEVEL)*Point &&
                 Ask - (Ask-Point*trailing) > MarketInfo(Symbol(), MODE_FREEZELEVEL)*Point &&
                 (Ask-Point*trailing) != OrderOpenPrice()){
                  if(!OrderModify(OrderTicket(),Ask-Point*trailing,Ask-Point*trailing-(OrderOpenPrice()-OrderStopLoss()),Ask-Point*trailing+(OrderTakeProfit()-OrderOpenPrice()), 0))Print(">>> ERROR ", GetLastError());
               }else{
                  Print(">>> Слишком близко к рынку или передано неизмененное значение!");
               }
            }
            return;
         }
      }
      index++;
   }
}
//+------------------------------------------------------------------+
 
ToLik_SRGV:


I have added automatic stop and takeovers to the method. When setting pending orders, I set limiters once and then the method itself drags everything to the right place :))

Very-very useful! But not optimal. We should dynamically change the take. Why do we have to follow the market? If we set a pending order and the price has moved away - a correction, for example... What do we do? Do we wait for the price to return? Or delete the order? Wouldn't it be better to do this...

Let us imagine a situation when the market has low volatility but a steady upward trend. The price has slowly moved away from the pending SELLSTOP order upwards. An open BUY position has already been worked out and closed with a profit. We wait for the market volatility to increase, and as soon as it exceeds some threshold, we move a limit order to the price. Thus, we catch the correction that has begun and the Limiter works not as a locking position but as an additional source of income. If we had not moved it, the correction might have reached it, touched it and finished. In this case we would have a lota Sell position in an uptrend.

Such an excursion into a trend safari...

If we have dynamic TPs, then by moving a pending order to the market and taking into account strong volatility (here it will be larger than for weak volatility) we are more likely to take more profit from a correction than in case of static TPs. Anyway, if we didn't close on the take, the trawl will do its job and we will lose only the missed profit...

Ugh... It's been a long time since I clicked so much on the keyboard...

Hence, the suggestion follows by itself. To make in passing parameters of function also TimeFrame. And based on it calculate the take from ATR values.

I experimented for some time and my investigations for M5 TF led to the conclusion that the optimum take profit according to ATR is calculated with ATR*45000, and I did it for my calculations. At these values the market almost always "catches" the take in time:

//+------------------------------------------------------------------+
//|                  Take from ATR                                   |
//+------------------------------------------------------------------+
double TakeProfitATR (int tf)
  {
   double   atr   =iATR(NULL,tf,14,0);
   double   mltp  =15000;
   if (tf==1) mltp=15000;
   if (tf==5) mltp=45000;
   double   tp    =MathRound(atr*mltp);
   return  (tp);
  }

Of course, the function is not finished, but it is enough for me for testing (I'm testing M5 for now)... By the way, with input value = 1 it gives quite a good distance for pending order setting.

It would be nice to see it in your function... :)

Thanks anyway - it's quite satisfying considering my modifications just to get the above...
ZS... it would be nice to add colours for modification icons... (really I have already added them)...

 

Here's a question: how does BC deal with a large number of trades? My Expert Advisor opens a position every 29 minutes (only one out of five strategies). Then, when equity increases by five percent, all of them are closed together. The main thing is that the balance increases by five percent every three to five days.

I wonder if BC has any claims to this kind of trading.

Reason: