[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 113

 
r772ra:

Cycle through the positions

Thank you so much, I will try everything now! Thank you!
 
r772ra:

Cycle through the positions

Tried it, didn't work. So yes, I can find it. But the problem is that I get the following situation:

For example, on 01.01 I opened a position, but the condition triggered only on 02.01. I.e., from the opening price of the order in the negative side, the price has passed 50 pips on the second day. If the condition is fulfilled, the action will be executed. And the action is to reduce the trade by 1/3. i.e. to reduce the volume of the trade by a factor of three. But the action will work until the lot is closed completely. We can set some flag. If b=0, then the action is in place. And at the end of the action b=1. If we do not null the flag at the end of the day, the trade will be executed once and that's it when we test it by history. If we zero the flag, then as soon as the flag is zeroed, the action will again start reducing orders until it closes it completely. I thought it would be possible to compare the volume of initially opened trade and then changed volume, but they will always be the same when comparing. If we decrease the volume of lot, the volume of funds in the account will also decrease, hence the initial volume will be recalculated. I.e. it is also not that, I think for the 3rd day. I have no clue, do you have any other ideas?

 
Boneshapper:

Good afternoon!

Dear Professionals, could you please advise me.

If the price exceeds by 50 pips the open price of this order, the order has to be modified.

OrderSelect(0, SELECT_BY_POS,MODE_TRADES);

double OPEN = OrderOpenPrice();
double maximus = OPEN + 0.00500;
Alert ("maximus = ",maximus);
double minimus = OPEN - 0.00500;
RefreshRates();//Refresh data.
timecur = TimeToStr(TimeCurrent(),TIME_SECONDS); //Calculate current time in HH:MM format.
if ((timecur > "00:00:00") && (timecur < "22:58:00") && (Deal_s == 1) && (Deal_bb == 0)&& (Bid > maximus))
{
OrderSelect(0, SELECT_BY_POS,MODE_TRADES);
Lootup = OrderLots () * 0.34;
Lootdown = OrderLots () * 0.34;
OrderClose(OrderTicket(), Lootdown, Ask, 10, CLR_NONE);
Alert (GetLastError());
Deal_bb = 1;
}

If it happens during the day, I am able to do it. Please advise, how to check if opening price + 50 P is controlled by price for each lot, until it closes in few days?

You time a string and then measure by strings - original!!!!
You don't need to invent anything: first you check the time resolution and then just trailing orders. Proven solutions for both can be found here and here.

 
Boneshapper:

Tried it, didn't work. It does work, but the problem is: I can't find it. But the problem is that I get the following situation:

For example, 01.01 I opened a deal, but the condition triggered only 02.01. I.e. from the opening price of the warrant in the negative side of the price passed 50 ppm on the second day. If the condition is fulfilled, the action will be executed. And the action is to reduce the trade by 1/3. i.e. to reduce the volume of the trade by a factor of three. But the action will work until the lot is closed completely. We can set some flag. If b=0, then there is an action. And at the end of the action b=1. If we do not null the flag at the end of the day, the trade will be executed once and that's it when we test it by history. If we zero the flag, then as soon as the flag is zeroed, the action will again start reducing orders until it closes it completely. I thought it would be possible to compare the volume of initially opened trade and then changed volume, but they will always be the same when comparing. If we decrease the volume of lot, the volume of funds in the account will also decrease, hence the initial volume will be recalculated. I.e. it is also not that, I think for the 3rd day. I have no clue, do you have any other ideas?

What do days have to do with it? You just write down what you want, and you'll be advised of the algorithm. It seems to me that you should not check the days but check the profit/loss of the order and then take your pick from it. 50 (or whatever) pips are important for you...

 
TarasBY:

You put time in a string, and then measure it with strings - that's original!
You don't have to invent anything: first you check the time resolution, and then you simply trailing the orders. Proven solutions for both can be found here and here.

Thank you so much for your reply, you gave me a link to exactly what I need. I will try it now, but I think it will work.

I'm sorry about the bugs, but I'm new to programming and not very good at it yet.

 
artmedia70:

What do days have to do with anything? You just write down what you want and they will tell you the algorithm. It seems to me that you should not check days but check profit/loss of an order and depend on it, because 50 (or whatever) points are important for you...

Yes, you are right. My profit/loss is what I am relying on. TarasBY pointed out exactly what I needed. I'll look into it now.

Thanks for your kind attention!

 

Can you please tell me if there is a kim function to search for fractals?

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает экстремум ЗигЗага по его номеру.                    |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    tf - таймфрейм                  (      0     - текущий ТФ)              |
//|    ne - номер экстремума           (      0     - последний)               |
//|    dp - ExtDepth                                                           |
//|    dv - ExtDeviation                                                       |
//|    bs - ExtBackstep                                                        |
//+----------------------------------------------------------------------------+
double GetExtremumZZPrice(string sy="", int tf=0, int ne=0, int dp=12, int dv=5, int bs=3) {
  if (sy=="" || sy=="0") sy=Symbol();
  double zz;
  int    i, k=iBars(sy, tf), ke=0;

  for (i=1; i<k; i++) {
    zz=iCustom(sy, tf, "ZigZag", dp, dv, bs, 0, i);
    if (zz!=0) {
      ke++;
      if (ke>ne) return(zz);
    }
  }
  Print("GetExtremumZZPrice(): Экстремум ЗигЗага номер ",ne," не найден");
  return(0);
}
How do I write the same function that counts the number of fractals in a given period?
 
berezhnuy:

Can you tell me if there is a kim function for finding fractals?

How to write the same function that counts the number of fractals in a given period?

It goes something like this:

void fGet_ExtremumsZZPrice (string fs_Symbol,           // инструмент
                            int fi_TF,                  // таймфрейм
                            datetime fdt_TimeControl,   // время, до которого ищем экстремумы
                            int fi_ExtDepth = 12,       // ExtDepth         
                            int fi_ExtDeviation = 5,    // ExtDeviation
                            int fi_ExtBackstep = 3)     // ExtBackstep
{
    double ld_Value, lda_Extremum[];
    int    li_size = iBarShift (fs_Symbol, fi_TF, fdt_TimeControl), li_IND = 0;
//---- 
    for (int li_Bar = 1; li_Bar < li_size; li_Bar++)
    {
        ld_Value = iCustom (fs_Symbol, fi_TF, "ZigZag", fi_ExtDepth, fi_ExtDeviation, fi_ExtBackstep, 0, li_Bar);
        if (ld_Value != 0.)
        {
            ArrayResize (lda_Extremum, li_IND + 1);
            lda_Extremum[li_IND] = ld_Value;
            li_IND++;
        }
    }
//---- 
}

The extrema of the ZigZag from the current time to Time_Control are collected in an array.

 
Can you please suggest a function to check the new fractal or the old one?
 
berezhnuy:
Can you please suggest a function to check the new fractal or the old one?

Here, I went to the topic "Useful functions" and brought you "on a silver platter:

//+----------------------------------------------------------------------------+
//| Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                    |
//+----------------------------------------------------------------------------+
//| Версия   : 07.10.2006                                                      |
//| Описание : Поиск ближайшего фрактала.                                      |
//+----------------------------------------------------------------------------+
//| Параметры:                                                                 |
//|   sy - наименование инструмента     (NULL - текущий символ)                |
//|   tf - таймфрейм                    (  0  - текущий ТФ)                    |
//|   mode - тип фрактала               (MODE_LOWER|MODE_UPPER)                |
//+----------------------------------------------------------------------------+
double FindNearFractal(string sy="0", int tf=0, int mode=MODE_LOWER) {
  if (sy=="" || sy=="0") sy=Symbol();
  double f=0;
  int d=MarketInfo(sy, MODE_DIGITS), s;
  if (d==0) if (StringFind(sy, "JPY")<0) d=4; else d=2;

  for (s=2; s<100; s++) {
    f=iFractals(sy, tf, mode, s);
    if (f!=0) return(NormalizeDouble(f, d));
  }
  Print("FindNearFractal(): Фрактал не найден");
  return(0);
}
Live and use it in good health! There are all kinds of them! You don't have to ask, you don't have to wait, you just take it and use it!
Reason: