Closing of positions. On indicator signal. - page 6

 
 

I don't think it's in the code. And here's why. The code is simple. But that's not the point. It's about this:

if(OrderProfit() > tp)    { OrderClose(OrderTicket(),OrderLots(),Ask,3,Green);  }

Let us assume that tp=49. At lot=0.1, the position will be closed when the profit =50 pips. Then let us increase the lot from 0.1 to 0.2. What will we get in this case?

The lot has doubled and we will get profit tp=50 twice as fast. It is enough for the price to go only 25 pips in our direction! Doubled lot gives us a total of 50 ! And of course the position will be closed! A similar thing will happen in a losing zone with the variable "-sl". So the EA will work quite differently, not the way it was originally intended...

Now another question arises. How to bring the size of the "tp" variable into correspondence with the changing size of the lot ? So the values of OrderProfit() change proportionally to the lot size ?

 
Yeah, OrderProfit() I didn't notice. It should be divided by lot size.
 
Done. Thank you. It's working....
 

The problem came up again. It's in the middle of nowhere. From where I didn't expect it... I faced an urgent need (in order to participate in the contest) to use a small lot size in my Expert Advisor, = 0.01.

But the library of B-lots calculation I.Kim's USED does not provide for such a size, because it contains the following line

if (dLot<0.1) dLot=0.1;

Without thinking twice, I changed the line in the following way: if (dLot<0.01) dLot=0.01; I set Lots=0.01 in Properties.

But to my surprise (for no apparent reason) the lot remains equal to =0.1 ! I tried it both ways! - Nothing works! Please, who knows how to foresee the work of the library from lot=0.01, prompt ...

//|                                                       b-Lots.mqh |
//|                                           Ким Игорь В. aka KimIV |
//|  21.12.2005  Библиотека функций расчёта размера лота.            |
 
//------- Внешние параметры модуля -----------------------------------
extern string _Parameters_b_Lots = "---------- Параметры модуля расчёта лота";
extern int LotsWayChoice  = 0;    // Способ выбора рабочего лота:
extern double Lots        = 0.01;  // Фиксированный размер лота
extern int LotsPercent    = 10;   // Процент от депозита
extern int LotsDeltaDepo  = 200;  // Коэффициент приращения депозита
extern int LotsDepoForOne = 500;  // Размер депозита для одного минилота
extern int LotsMax        = 1000; // Максимальное количество минилотов
//+------------------------------------------------------------------+
//| Главная функция получения размера лота (вызывается из советника) |
//+------------------------------------------------------------------+
double GetSizeLot(){
  double dLot;
  if (LotsWayChoice==0) dLot=Lots;
 
  // фиксированный процент от депозита
  if (LotsWayChoice==1)
  {    dLot=MathCeil(AccountFreeMargin()/10000*LotsPercent)/10;  }
 
  // фракционно-пропорциональный
  if (LotsWayChoice==2)  { 
    int k=LotsDepoForOne;
    for (double i=2; i<=LotsMax; i++)    {
      k=k+i*LotsDeltaDepo;
      if (k>AccountFreeMargin())
      {        dLot=(i-1)/10; break;      }
    }
  }
 
  // фракционно-фиксированный
  if (LotsWayChoice==3)
  {    dLot=MathCeil((AccountFreeMargin()-LotsDepoForOne)/LotsDeltaDepo)/10;  }
 
  if (dLot<0.01) dLot=0.01;
  
  return(dLot);
}
 
First of all, check the minimum allowed lot size with Marketinfo() on the currently logged in account.
MODE_MINLOT - if it is more than 0.01, the tester will not work with 0.01 volumes.
 

Thank you. The account is allowed to work with lot=0.01.

Got it. It's working...

 

Hi all from a "dummy".

I am just starting to learn MQL, I am parsing and carefully modifying the well-known Moving Average. Can someone give me a tip?

How may I suggest to open deal not at opening of a new bar but at the moment of МА touching the rebound (approach from above - buy, approach from below - sell)?

And is it possible to do the same, from another object, for example, a trend line?

 
I think I saw an expert like this somewhere. Look here - http://www.metatrader4.com/ru/forum/4736/
 

Good afternoon everyone. I wanted to open a new thread, but then I decided to put the question here, in my thread... I would like to know the opinion of those present on such a question. "I built (as best I could) an Expert Advisor. It works in the tester in such a way that it's a sight to behold! I could not believe my eyes! After several days of working with a fixed lot = 0.1 the Expert Advisor can increase the deposit several times! I even did not insert the MM block. Why? I thought - "Too good is not good either..."!

The Expert Advisor works without indicators, according to mathematical logic, and instead of trawl there is a floating pending order. These are approximately the results, including out-of-sample, shown by the Expert Advisor



28.01.2008 - 08.02.2008, lot=0.1 (fixed), tf=1min

Modeling quality 25.00%, Error of chart mismatching 0

Initial deposit 1000.00

Net profit 21904.31

Profitability 1.86 Expected payoff 4.03

Absolute drawdown 4.64 Maximum drawdown 656.18 (10.19%) Relative drawdown 10.19% (656.18)

Total trades 5433

Profitable trades (% of all) 2278 (41.93%)

Largest profitable trade 75.46 losing trade -11.93

Average profitable trade 20.81 losing trade -8.09

Sure enough, I rubbed my hands together and, having hardly waited for Monday, "charged" the Expert Advisor online to the demo account. And that's when I found out that my Expert Advisor is losing money online....! Of course there are periods of stable profitable work, but overall it is a slow drain...

I started to look into it. It was found that the tester modulates smoothed ticks inside one-minute bars, i.e. much less "prickly" than incoming ticks in the online mode. Since the Expert Advisor is clearly a pipsewise one, it apparently makes a difference. All the more so because my take profit is many times greater than my stop loss!

But I think the amount of profit in the tester in this situation should translate into the quality of work online. I'm just sure of it! The profits of the Expert Advisor in the tester are too dashing. What should be done to make the Expert Advisor profitable in online trading? Please, share your ideas. Any ideas. Anything clever and anything unbelievable...

Reason: