[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 234

 
sergeev:

Tried it. It didn't freeze.


gave error 129 on OrderClose.

Put RefreshRates in front of it.

Closed without error


Yes, I did the same, but sometimes it just stops working (and not the terminal itself, but the EA)

 
doon:
Can you please explain why this code sometimes freezes in one place and you have to restart the terminal to resume it?


You have been asked quite directly - At which line does it freeze?

Your code opens and immediately closes the same order and is very well documented, so it should be immediately visible in Alerts which line the code has reached. Or is it just a part of the code?

 
Roger:


You have been asked quite directly - On what line does it freeze?

Your code opens and immediately closes the same order and is very well documented, so you should be able to see immediately in the Alert which line the code has reached. Or is it just a part of the code?


No, this is all code. And it stops at the lines of order opening and closing (but not always).

 
Replace ask and bid in the code with MarketInfo(Symbol(),MODE_ASK) and MarketInfo(Symbol(),MODE_BID), should work
 

From this:

OrderSend(Symbol (), OP_BUY, 1, Ask, 10,0,0, "dsgdsf", 0, 0, CLR_NONE);

On this:

OrderSend(Symbol (), OP_BUY, 1, MarketInfo(Symbol(),MODE_ASK), 10,0,0, "dsgdsf", 0, 0, CLR_NONE);
?
 

No, it still hangs up.

After 4 minutes of hanging, it turned out to be error 128(Transaction waiting time has expired).

Maybe this will help?

 

Dear colleagues, I'm still a complete "dummy"in MQL programming, I started studying this topic quite recently. But I already started to write my first EA, or at least I tried to.

On the 182nd page of this topic I've laid out trading criteria this EA should trade by. Please see what it says (last post on the page). I've been struggling for three weeks and I still cannot write here the part of the code responsible for the trading criteria. I've readthe tutorial chapter dedicated to this topic, but it didn't help me in this particular case.

I have written dozens of variants of this part of the code during my programming battles, but none of them works properly. Obviously I do not have enough knowledge, Icannot masterMQL that quickly .Anyway, here is one of the code variants that works, at least approximately, as I want it to.

//+-------------------------------------------------------------------------------------+
//| Расчет значений технических индикаторов с формированием сигналов для позиций        |
//+-------------------------------------------------------------------------------------+
void GetSignal()
{
 Signal = 0;
// - 1 - == Получение значений индикаторов ==============================================
 double SAR = iSAR(Symbol(), 0, SARStep, SARMaximum, 0);
 double EnvUp = iEnvelopes(Symbol(), 0, EnvPeriod, EnvMethod, EnvShift, EnvPrice,
 EnvDeviation, MODE_UPPER, 1);
 double EnvDn = iEnvelopes(Symbol(), 0, EnvPeriod, EnvMethod, EnvShift, EnvPrice,
 EnvDeviation, MODE_LOWER, 1);
 double StochM = iStochastic(Symbol(), 0, StochK, StochD, StochSlowing, StochMethod,
 StochPrice, MODE_MAIN, 1);
 double StochS = iStochastic(Symbol(), 0, StochK, StochD, StochSlowing, StochMethod,
 StochPrice, MODE_SIGNAL, 1);
// - 1 - == Окончание блока =============================================================

// - 2 - == Генерация сигнала ===========================================================
 if (SAR < Low[1])
   {
    Signal = 3;                                                          // Закрытие SELL
    if (StochM > StochS && StochM >= 80 && StochS >= 80 && High[1] >= EnvUp && SAR < Open[1])
      Signal = 1;                                                         // Открытие BUY
   }   
 
 if (SAR > High[1])
   {
    Signal = 4;                                                           // Закрытие BUY
    if (StochM < StochS && StochM <= 20 && StochS <= 20 && Low[1] <= EnvDn && SAR > Open[1])
      Signal = 2;                                                        // Открытие SELL
   }   
// - 2 - == Окончание блока =============================================================
}


I know the code is all crooked and slanted, and in general the baypositions and sell are mixed up. But this is the only variant of the code, when Stochastic and Envelope are trading together, without ignoring each other. At the same time, Parabolic signals are not taken into account in trading for some reason. Anyway, please don't scold me too much for such "ass-kicking", I am well aware that the code is not correct.

Please help me, please fix the code of my Expert Advisor. I am having a hard time with it. I have implemented easier strategies (Mooving + Momentum; Mooving +RSI), but I can not do it with this one. Please help. Please rewrite all wrong lines to make my EA trade by those rules, that I have describedon page 182. I really need it.

P.S.: I can not write all of the code, because I used ready-made MQL-templates.

 
doon:

No, it still hangs up.

After 4 minutes of hanging, it turned out to be error 128(Transaction waiting time has expired).

Maybe this will help?


Damn, change the dealing centre already - it's clear without any hints that if trade orders on the same code then pass normally and then hangs, it means that the server is dying. The order went out and did not come back for 4 minutes. Are you really going to conduct real trades on this server? Cross your heart and change different brokerage houses a few times. Did somebody teach you how to use a computer? It's not a typewriter or a game console - it requires knowledge. This is a study and painstaking work. If you had a basic understanding of the command line, how to open files and at least a basic understanding of how a computer network works, you would ask different questions and you would be happy to get help. All you need now is to ping your brokerage company's server and compare the response time with server response time of other brokerage companies. If you spent about 30 minutes you would understand what is what. If you had tried to outline the interaction of the Expert Advisor and the server, we could even estimate with MQL4 how fast your brokerage company's server executes trade orders.

There are no words. How could you treat so carelessly the process of your own work?

 

daytrader19:

Please rewrite the wrong lines so that the EA trades according to the rules I describedon page 182.

Note.

1) The condition "line1[1]>line2[1]" is not enough for the signal "two lines crossing". Надо "линия1[1]>линия2[1]&&линия1[2]<линия2[2]"

2) The parabolic should not be compared to Open, but to High and Low, and note that you calculate it on the zero bar and take Open[1] from the first bar.

 
doon:

No, it still hangs up.

After 4 minutes of hanging, it turned out to be error 128(Transaction waiting time has expired).

Maybe this will help?


It can also happen with bad internet, e.g. when downloading a torrent too much. But you won't be able to check until Monday.