Useful features from KimIV - page 73

 
The function returns the fractal by its number. The numbering is separate for upper and lower fractals. This may be useful for developing Expert Advisors that analyse relative positioning of the last number of fractals in order to make a decision about entering the market. Made by modifying the KimIV function.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru  & khorosh        |
//+----------------------------------------------------------------------------+
//|  Версия   : 08.02.2009                                                     |
//|  Описание : Возвращает фрактал по его номеру.                              |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента        ("" или NULL - текущий символ)     |
//|    tf - таймфрейм                       (    0       - текущий ТФ)         |
//|    nf - номер фрактала                  (    0       - последний)          |
//+----------------------------------------------------------------------------+
double GetFractal(string sy="0", int tf=0, int nf=0, int mode=MODE_UPPER) {
  if ( sy=="" || sy=="0") sy=Symbol();
  double f=0;
  int    i, k=iBars( sy, tf), kf;
  for ( i=3; i< k; i++) {
    if( mode==MODE_LOWER){
    f=iFractals( sy, tf, MODE_LOWER, i);
    if ( f!=0) {
      kf++;
      if ( kf> nf) return(iLow( sy, tf, i));
     } 
    }
    if( mode==MODE_UPPER){
    f=iFractals( sy, tf, MODE_UPPER, i);
    if ( f!=0) {
      kf++;
      if ( kf> nf) return(iHigh( sy, tf, i));
      }
    }
  }
  Print("GetFractalBar(): Фрактал не найден");
  return(-1);
}
 

Hello Igor!

I'm trying to learn MQL4 and due to lack of description of the language operators one problem has left me stumped. I have an indicator with 8 buffers of accumulated data. I need it to be displayed on a timeframe that I have chosen and with the period of the next timeframe. For this purpose, it uses iCustom() operator. But it returns a double value and I don't know how and whether iCustom can and should be used in this case.

I really hope for your help.

 

Hello Igor! And good afternoon to all!

I am interested in the code which should be entered so that the Expert Advisor does not make any more trades on that day when it closes a trade...


I've found it but it does not work in the strategy tester, I want to test it, what code should I use instead?

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает номер бара открытия последней позиции или -1.       |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ("" или NULL - текущий символ)          |
//|    tf - таймфрейм                  (    0       - текущий таймфрейм)       |
//|    op - операция                   (   -1       - любая позиция)           |
//|    mn - MagicNumber                (   -1       - любой магик)             |
//+----------------------------------------------------------------------------+
int NumberOfBarCloseLastPos(string sy="0", int tf=0, int op=-1, int mn=-1) {
  datetime t;
  int      i, k=OrdersHistoryTotal();

  if (sy=="" || sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
      if (OrderSymbol()==sy) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderCloseTime()) t=OrderCloseTime();
            }
          }
        }
      }
    }
  }
  return(iBarShift(sy, tf, t, True));
}

Then you should put in the entry conditions

if (NumberOfBarCloseLastPos(NULL, 1440,-1, Magic)  !=0) {
                                                      }
 
LeoV писал(а) >>

Hello Igor!

Do you have a script that modifies all open positions by volume (lots) for all instruments by a certain percentage? Both upwards and downwards with saving Magic Number for each position?

Hello Leonid!

I did not... I wrote... ChangeLots

 
KimIV писал(а) >>

Hello, Leonid!

Didn't... wrote... ChangeLots

Igor, thank you very much! I could really use this for my pamm. )))))
 

Hello Igor!

When using your Expert Advisor "e-SampleCase",when I set a stop

less than 100 (10 pips), my tester generates error 130.

I do not know why it does not work correctly.

Please answer!

 
6232 >> :

When using your "e-SampleCase" Expert Advisor, when setting a stop

less than 100 (10 pips), my tester gives error 130.

Stop works fine. Why?

Extended the DC min. corridor for setting stops and takeaways

 
BARS писал(а) >>

Expanded the DC min. corridor to set stops and takeovers

>>Thank you! Got it.

 
6232 >> :

Hello Igor!

When using your Expert Advisor "e-SampleCase",when I set a stop

less than 100 (10 pips), my tester generates error 130.

I do not know why it does not work correctly.

>> Please give me an answer.

It's probably because of the introduction of the fifth digit, at Alpari by the way they said you have to increase your stops by 10 times because your 100 pips becomes 10 pips, hence the errors on most pairs...

 
stalkervr писал(а) >>

If you don't mind, tell me how to use your function

Determine the presence and volume of an open position, as well as the presence and volume of pending orders set

Eugene, I find your question a bit redundant because a non-zero volume will automatically mean presence.

Look at the functions:

Perhaps, you can make something useful for yourself.