Useful features from KimIV - page 51

 
Dear Igor, I apologise if I offended anyone... I wasn't really criticising, it's a pity it looks that way. Anyway, the posted prototype will be corrected and refined more than once. So there will be no puzzles (I never pretended to be the author) in future I will send you the work for author's revision. I see myself as the first step so far 25 pages. As soon as I will finish it I will send it to address mentioned in your site. Thank you for your invaluable work and unselfish sharing of experience!!!
 
rid писал (а) >>

I think it is possible. Apparently, it is necessary to check at each level (at crossing) what is the current lot size of the open position. And exactly by this criterion we should implement a closing mechanism !

Such functions (that returns the lot size) are available in this branch. Look at pp. 17 и 27

Thank you very much ! Hurrah ! Now I can move on. Thank you very much !

 

In order to determine whether or not additional lot size checks are needed in the OpenPosition() function, you need to see how you calculate the lot size and how and where it is called; I did not see this function in the branch

double ll=GetSizeLot();

maybe i missed .

If it's calculated like this https://championship.mql5.com/2012/ru/news, you might get a 134 error and miss the championship :-)

 

Hi KimIV.sent one thing will have to write it back. I'm not very good at programming and I'm studying to be a trader for 3 weeks. my grammar is not good either.

here. My question is this. Is it possible to make an EA using the CCi indicator?

Levels CCi 250, 50, -50, -250. The idea is that when it reaches (crosses) -50 and 50, respectively, I would sell or buy. Consider when the deal should stop:

1Then (let's say there is a sale) the graph crosses -250, then it crosses in the opposite direction -250 (you can see on the picture).

2 The chart has not reached 250 and crosses back to 50.

For buying, it is the same but vice versa.

Quote Euro/Dollar, any time frame.

How much would a plush EA like this cost????

If its the same price, can you offer something better?

Thanks in advance. I hope so. Well, I went to a FOREX course.

By the way, forex is a real way to earn bread and butter????

 

Greetings all.

Found this indicator, changed it a bit - builds good trend lines.

It would be interesting to concoct a function... (it's kind of a KimIV request).

Files:
tlbs.mq4  8 kb
 
Prival писал(а) >>

Re.

OpenPosition("GBPJPY", OP_SELL, 0.1, pb+23*po, pb-44*po);

Maybe it would be better to call OpenPosition("GBPJPY", OP_SELL, 0.1, 23, 44);

This suggestion, Sergei, increases convenience of using stops and takes set in pips. What about cases where stops and takes are set by price levels? For example, a stop at the low or high of the previous bar. Or by a line of some sort. Is it translated into points before calling the function and converted back to prices within the function? This is a redundant operation. So I will leave it as it is.

We will consider the GetSizeLot() function later (by the way, it is now called GetLots()). First of all, we need to finish using b-ForTest.mqh and b-Positions.mqh libraries.

 

The CountOrders() function for the tester.

In my test (intended for use only in the tester of MT4) versions of Expert Advisors, function CountOrders() replaces the following functions: ExistOrders(), ExistPositions(), NumberOfOrders() and NumberOfPositions(). That is, it can give information about the existence of a position or an order of any type, as well as information about the number of trades of each type. Such an exchange has its own advantages, which is expressed in a one-time reference to the orders base for one tick and obtaining all necessary information at once. And the above mentioned functions, especially when used together, each of them works with one and the same order base independently, so they repeatedly make the same calls. As a result, the CountOrders() function can reduce the time of one pass by several seconds, which allows to save hours of optimization.

Function CountOrders() takes the following parameters:

  • mo - Array of the number of orders by type. After the function has been executed, the array will have 6 (six) elements. Zero element - number of trades of Buy type, first element - number of Sell orders, second element - BuyLimit, third element - SellLimit, fourth element - BuyStop, fifth element - SellStop.
  • mn - Identifier of a position or orders (MagicNumber). The default value is -1 - any MagicNumber.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 03.08.2008                                                     |
//|  Описание : Рассчитывает количество ордеров по типам.                      |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    mo - массив количества ордеров по типам                                 |
//|    mn - MagicNumber                          (-1 - любой магик)            |
//+----------------------------------------------------------------------------+
void CountOrders(int& mo[], int mn=-1) {
  int i, k=OrdersTotal();

  if (ArraySize( mo)!=6) ArrayResize( mo, 6);
  for ( i=0; i< k; i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) {
      if ( mn<0 || OrderMagicNumber()== mn) mo[OrderType()]++;
    }
  }
}

P.S. Attached is a script for testing the CountOrders() function online.

Files:
 

Good afternoon, Igor and everyone else too. I have a problem using GetFractalBar(NULL,0, 0) function. - It returns the fractal bar number by its number. To be more precise, the problem is not with the function. But somewhere near it.

Everything is OK when the comment is displayed with this setting. I HAVE the number of the bar in the corner of the chart.

int a;
... ...

int start()
  {
//----
if(Time[0] == prevtime)   return(0);//ждём нового бара
   prevtime = Time[0];//если появился новый бар , включаемся

if ( isFractalUp() > isFractalDn() )  {//если это Down-фрактал

   a = iLow(NULL,0, GetFractalBar(NULL,0, 0));
   
Comment( GetFractalBar(NULL,0, 0));            }

And everything is OK when I show comment numbers in the corner of the chart. I see min. price values of the bar with the fractal in the left corner.

if ( isFractalUp() > isFractalDn() ) {//если это Down-фрактал
   a = iLow(NULL,0, GetFractalBar(NULL,0, 0));

Comment(iLow(NULL,0, GetFractalBar(NULL,0, 0)));          }

But further in general it is not clear! As soon as I insert the variable "a" into the comment instead of the function itself, the comment returns 1 in the corner instead of the price value! Here :

if ( isFractalUp() < isFractalDn() ) {
   a = iLow(NULL,0, GetFractalBar(NULL,0, 0));
   Comment( a);                        }
I've been sitting for three hours, I don't understand what's wrong! Please tell me if you can....
 
Rita писал(а) >>
As soon as I insert the variable "a" into the comment instead of the function itself, the comment returns 1 in the corner instead of the price value !

You have declared the variable "a" as an integer variable, i.e:

int a;

You should declare it as a real variable, i.e:

double a;

 

ModifyOrder() function for the tester.

This is a simplified version of the ModifyOrder() function, published on page 7, and is designed to change the absolute price levels of one pre-selected order or position.

The ModifyOrder() function accepts the following parameters:

  • pp - Order setting price. If you pass a value less than or equal to zero, the modification of this price level will not be performed. The default value is -1.
  • sl - Stop price level. If you pass a value less than zero, the modification of the price level will not be performed. The default value is 0.
  • tp - Take price level. If you pass a value less than zero, the modification of the price level will not be implemented. The default value is 0.
  • ex - Expiration date of the pending order. The default value is 0.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 28.03.2008                                                     |
//|  Описание : Модификация ордера. Версия функции для тестов на истории.      |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    pp - цена открытия позиции, установки ордера                            |
//|    sl - ценовой уровень стопа                                              |
//|    tp - ценовой уровень тейка                                              |
//|    ex - дата истечения                                                     |
//+----------------------------------------------------------------------------+
void ModifyOrder(double pp=-1, double sl=0, double tp=0, datetime ex=0) {
  int    dg=MarketInfo(OrderSymbol(), MODE_DIGITS), er;
  double op=NormalizeDouble(OrderOpenPrice() , dg);
  double os=NormalizeDouble(OrderStopLoss()  , dg);
  double ot=NormalizeDouble(OrderTakeProfit(), dg);
  color  cl;

  if ( pp<=0) pp=OrderOpenPrice();
  if ( sl<0 ) sl=OrderStopLoss();
  if ( tp<0 ) tp=OrderTakeProfit();
  
  pp=NormalizeDouble( pp, dg);
  sl=NormalizeDouble( sl, dg);
  tp=NormalizeDouble( tp, dg);

  if ( pp!= op || sl!= os || tp!= ot) {
    if (MathMod(OrderType(), 2)==0) cl= clModifyBuy; else cl= clModifySell;
    if (!OrderModify(OrderTicket(), pp, sl, tp, ex, cl)) {
      er=GetLastError();
      Print("Error(", er,") modifying order: ", ErrorDescription( er));
      Print("Ask=",Ask," Bid=",Bid," sy=",OrderSymbol(),
            " op="+ GetNameOP(OrderType())," pp=", pp," sl=", sl," tp=", tp);
    }
  }
}