Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1514

 
I set the lines to see where the EA will work, replaced the lines with a condition for placing and modifying orders and the EA worked. To be honest I am glad it worked. This is my first independent EA. I understood why the tester set only one line ))
 
Alexey Viktorov:

Check MA crossing not on 1 and 2 bars, but on 3 and 4. And if there is a crossover, check the AO values on 1 and 2 bars.

Thank you. I will keep trying.
 

I have another headache - explain how to write the KEY_TILDE key for selecting the Rectangular Label object, so that it can be selected and moved to another place on the chart, I can't figure it out. I have attached a screenshot with an example on Fork Neo indicator at the bottom. I have understood the mouse, but I cannot use keys.

int OnInit()
  {
RectLabelCreate(0,"RectLabel",0,10,200,149,143,C'55,55,55',BORDER_SUNKEN,CORNER_LEFT_LOWER,C'55,55,55',STYLE_SOLID,1,false,false,true,0);

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,         // идентификатор события
                  const long& lparam,   // параметр события типа long
                  const double& dparam, // параметр события типа double
                  const string& sparam) // параметр события типа string
  {

    if(id==CHARTEVENT_KEYDOWN)
     {
      switch(int(lparam))
        {
         case KEY_TILDE:
            Print("Нажата KEY_TILDE");
            break;
        }
        ChartRedraw(); 
     }

  }
Files:
01.jpg  8 kb
02.jpg  3 kb
 
DYM:

I have another headache - explain how to write the KEY_TILDE key for selecting the Rectangular Label object, so that it can be selected and moved to another place on the chart, I can't figure it out. I have attached a screenshot with an example on Fork Neo indicator at the bottom. I have understood the mouse, but I cannot use keys.

    if(id==CHARTEVENT_KEYDOWN)
     {
      switch(int(lparam))
        {
         case KEY_TILDE:
         ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTABLE,true); 
         Print("Нажата KEY_TILDE");
         break;
        }
        ChartRedraw(); 
     }
 
MakarFX:
Thank you very much for the tip. I realised that I needed to use resolution and selection, but I couldn't figure out how to apply it. Thanks again.
 
Colleagues, I am in a strange situation. It works well in the tester, it is set so that a random order is opened instantly when it is added to the chart. This is optimal for GBPUSD. However, it does not open orders on the demo. I have a wide spread, no errors, but, again, orders have not been opened for a day, but I have traded good within the same day using downloaded ticks in the tester. All settings of MetaTrader are normal, faces are smiling and connection with broker's server is also normal. I have to look what is wrong with the code. Although, this code doesn't need any induks and parameters are valid by its conditions for skipping opening orders. I am puzzling.
Files:
BlackJack.mq4  47 kb
 
Порт-моне тв:
Dear Colleagues, I have finished my Expert Advisor. It works well in the Strategy Tester but has been configured in such a way that it opens a random order immediately when it is added to the chart. This is optimal for GBPUSD. However, it does not open orders on the demo. I have a wide spread, no errors, but, again, orders have not been opened for 24 hours, but I have traded good within the same day using downloaded ticks in the tester. All settings of MetaTrader are normal, faces are smiling and connection with broker's server is also normal. I have to look what is wrong with the code. Although, this code doesn't need any induks and parameters are valid by its conditions for skipping opening orders. I am puzzling.

There are a lot of bottlenecks. The code is poorly written - extremely sloppy data handling. Needs refactoring

 
Nikita Chernyshov:

There are a lot of bottlenecks. The code is poorly written - extremely sloppy data handling. It needs refactoring.

Your abstract evaluation does not reveal the cause.

 
Порт-моне тв:

what fucking bottlenecks...what the @@#$ refactor

the code was written "for my beloved self, for beer and while I remember it" :-)

honestly - i downloaded it, looked at it diagonally, i don't understand it...

----

Any code is documented/commented in case of sudden personal professional amnesia. That's when you forgot everything except the programming language.

No one will parse an unknown algorithm implemented in unknown ways. For free, at least. For money, they'll just rewrite it.

You're one of them. After two or three months of break you will not remember why there were so many variables in OnTick and what they were intended to read

 
Maxim Kuznetsov:

what fucking bottlenecks...what the @@#$ refactor

the code was written "for my beloved self, for beer and while I remember it" :-)

honestly - i downloaded it, looked at it diagonally, i don't understand it...

----

Any code is documented/commented in case of sudden personal professional amnesia. That's when you forgot everything except the programming language.

No one is going to parse an unknown algorithm implemented in unknown ways. For free, at least. For money, they'll just rewrite it.

You're one of them. Taking a two-three month break you will not remember why there were so many variables in OnTick and what they were intended to read

There's a lot of unnecessary stuff in there, to test let's say different functions. It shouldn't interfere and hasn't in other EAs, which just work. I suspect I put a parenthesis in the wrong place or something.
Reason: