[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 124

 
Notter:

Good afternoon,

Could you please tell me how to put a marker on the chart? For example, the order did not open, but at least to see on the chart, at which point it should have opened.

I would like to place a marker on a chart.

Like this

#include <stderror.mqh>

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int Err;
//----
       if(...........) //покупаем
          { 
          Err=OrderSend(..................);
             if(Err<0)
                SetArrow(159, Blue,"ошибка открытия № "+GetLastError(),Time[0],Open[0],2);
          }
       if(...........) //продаем
          { 
          Err=OrderSend(..................);
             if(Err<0)
                SetArrow(159, Red,"ошибка открытия № "+GetLastError(),Time[0],Open[0],2);
          }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 12.10.2007                                                     |
//|  Описание : Установка значка на графике, объект OBJ_ARROW.                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    cd - код значка                                                         |
//|    cl - цвет значка                                                        |
//|    nm - наименование               ("" - время открытия текущего бара)     |
//|    t1 - время открытия бара        (0  - текущий бар)                      |
//|    p1 - ценовой уровень            (0  - Bid)                              |
//|    sz - размер значка              (0  - по умолчанию)                     |
//+----------------------------------------------------------------------------+
void SetArrow(int cd, color cl,
              string nm="", datetime t1=0, double p1=0, int sz=0) {
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (t1<=0) t1=Time[0];
  if (p1<=0) p1=Bid;
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_ARROW, 0, 0,0);
  ObjectSet(nm, OBJPROP_TIME1    , t1);
  ObjectSet(nm, OBJPROP_PRICE1   , p1);
  ObjectSet(nm, OBJPROP_ARROWCODE, cd);
  ObjectSet(nm, OBJPROP_COLOR    , cl);
  ObjectSet(nm, OBJPROP_WIDTH    , sz);
}
 
dertop:


Yeah sorry got confused, first time writing on the forum. Copypasted first, then decided to handwrite and got confused... But the example above is correct...

MA1>MA2 and MA1<MA3 and MA3<MA4


Read the following thread
 
Vinin:


There's something strange here.

MA1>MA2 and MA2>MA3 and then MA1<MA3

All the more so because it is sufficient to

Yes, indeed, there is a contradiction between the two. I just didn't look into everything! The author still has a long way to go to make "hard mistakes"!
 

The question is this. This is not the first time I've encountered this situation:

If the traal or breakeven function is called on every tick, for example, an error 1 will pop up. Which means, according to the documentation:

ERR_NO_RESULT   1       Нет ошибки, но результат неизвестен

If not called openly in start function, i.e. not just entered function with parameters directly in start, but call it on every bar, i.e. not by tick, then error - no...

I mean like this:

int start()
{
   MovingStopLossToBU();
// Что-то дальше делаем..

Why like this?

And in general, how is it more intelligently implemented? Will it be resource intensive on every tick?

 

Всем добрый день.

I need your help. I don't understand what's going on.

if (OrderStopLoss() != NormalizeDouble(t6,5))

{

a=10;

}

TheOrderStopLoss()=1.3017 andNormalizeDouble(t6,5)=1.3017 condition still holds, i.e. a=10. But it should not be satisfied.

What may be the reason for this?

 
hoz:

The question is this. This is not the first time I've encountered this situation:

If the traal or breakeven function is called on every tick, for example, an error 1 will pop up. Which means, according to the documentation:

If not called openly in start function, i.e. not just entered function with parameters directly in start, but call it on every bar, i.e. not by tick, then error - no...

I mean like this:

Why like this?

And in general, how is it implemented more intelligently? Will it be resource intensive on every tick?

I would advise you not to go by bars, by so many pips. If necessary, that's what resources are for. And the "no error" error occurs when the price is repeated for a modification that already exists. That's why you have to do it step by step, as I advised you at the beginning.
 
hoz:

The question is this. This is not the first time I've encountered this situation:

If the traal or breakeven function is called on every tick, for example, an error 1 will pop up. Which means, according to the documentation:

If not called openly in start function, i.e. not just entered function with parameters directly in start, but call it on every bar, i.e. not by tick, then error - no...

I mean like this:

Why like this?

And in general, how is it implemented more intelligently? Is it going to be resource intensive on every tick?

Trawl tries to move SL to the same level. We need to add a check, trawl level should be different from current SL.

 
valeryk:

Trawl attempts to move the SL to the same level. A check should be added, trawl level must be different from current SL.



I have a check for that:

if (ND(OrderStopLoss() - priceBU * pt) != 0.0)
{
  if (!OrderModify(OrderTicket(), OrderOpenPrice(), priceBU, OrderTakeProfit(), 0, CLR_NONE ))
  {
    Print ("Ошибка модификации ордера ", OrderType(), " - ", GetLastError());
  }

}
If stop - new stop (in b.u.) is not zero... then we modify... If not, we don't modify. That's why it's not clear to me how this happens. After all, I understand that I need to check for equality of past and new stop and I have done it.
 

Hello ! please advise how can I modify my initial and final order to 1 T/P thank you

gi_304 = CountTrades();

   g_price_212 = 0;

   double ld_24 = 0;

   for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) {

      OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES);

      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue;

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) {

         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {

            g_price_212 += OrderOpenPrice() * OrderLots();

            ld_24 += OrderLots();

         }

      }

   }

   if (gi_304 > 0) g_price_212 = NormalizeDouble(g_price_212 / ld_24, Digits);

   if (gi_332) {

      for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) {

         OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES);

         if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue;

         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) {

            if (OrderType() == OP_BUY) {

               g_price_180 = g_price_212 + TakeProfit2 * Point;

               gd_unused_196 = g_price_180;

               gd_308 = g_price_212 - Stoploss * Point;

               gi_268 = TRUE;

            }

         }

         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) {

            if (OrderType() == OP_SELL) {

               g_price_180 = g_price_212 - TakeProfit2 * Point;

               gd_unused_204 = g_price_180;

               gd_308 = g_price_212 + Stoploss * Point;

               gi_268 = TRUE;

            }

         }

      }

   }

   if (gi_332) {

      if (gi_268 == TRUE) {

         for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) {

            OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES);

            if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue;

            if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) OrderModify(OrderTicket(), g_price_212, OrderStopLoss(), g_price_180, 0, Yellow);

            gi_332 = FALSE;

         }

      }

   }

   return (0);


 
agat8430:

Hello ! please advise how can I modify my initial and final order to 1 T/P thank you


Edit this code so it doesn't look like a hack