Discussion of article "Visual strategy builder. Creating trading robots without programming" - page 6

 
Andrey Barinov:
...

I will add wheel scrolling in future versions....

I would like to share my experience in implementing wheel scrolling. Perhaps my technology will not suit you, but it may give you the right idea (if you haven't decided on the implementation method yet).

Inside the OnChartEvent() function in the condition :

if(id == CHARTEVENT_CHART_CHANGE && !a)

1. I use the ChartNavigate function and set the current chart to the -100 bars back position.

2. I set the number of the first visible bar using ChartGetInteger(0,FIRST_VISIBLE_BAR) to the static variable "First_bar_number".

3. Next, I fix the chart event CHARTEVENT_CHART_CHANGE once through (I use flag "a" and flag "b" for this purpose).

4. I compare "Number_of_the_first_bar" and "Number_of_this_bar" (which I also get via ChartGetInteger(0,FIRST_VISIBLE_BAR), but on each CHARTEVENT_CHART_CHANGE event, not once as with "Number_of_the_first_bar") and determine the direction of the chart shift.

and determine the direction of the chart shift.

5. Next, everything is simple - I move the kanvas image with ObjectSetInteger(0,G_CORE[CANVAS][_NAME],OBJPROP_YOFFSET,G_CORE[CANVAS][_FIELD_TO_VIEW_Y_DISTANCE]); I return the chart to its original position - ChartNavigate(0,CHART_END,-100);

6. I skip the next chart event because it is generated from the called ChartNavigate function . Then everything repeats itself.

Here's the code:

 if(id == CHARTEVENT_CHART_CHANGE && !a)
   {
    //------------------------------------ 
    if(!Номер_первого_бара)
      {
       ChartNavigate(0,CHART_END,-100); 
       Номер_первого_бара = ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR);
      }
    //------------------------------------ 
    Номер_этого_бара = ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR);
    //------------------------------------
    if(Номер_этого_бара > Номер_первого_бара)
      {
       Прокрутка_вниз = 1;
       Прокрутка_вверх = 0;
       Сдвиг = 25;
       a = 1;
      }
    if(Номер_этого_бара  < Номер_первого_бара) 
      {
       Прокрутка_вниз = 0;
       Прокрутка_вверх = 1;
       Сдвиг = -25;
       a = 1;
      }
    //------------------------------------
    G_CORE[КАНВАС][_IMAGE_VIRTUAL_Y] -= Сдвиг;
    //------------------------------------ 
    G_CORE[КАНВАС][_FIELD_TO_VIEW_Y_DISTANCE] = G_CORE[Поле_обзора][_Y] - G_CORE[КАНВАС][_IMAGE_VIRTUAL_Y];  
    //------------------------------------
    ObjectSetInteger(0,G_CORE[КАНВАС][_NAME],OBJPROP_YOFFSET,G_CORE[КАНВАС][_FIELD_TO_VIEW_Y_DISTANCE]);
    //------------------------------------    
  }
//------------------------------------------------------
if(b){a = 0; b = 0;} 
if(a == 1){ChartNavigate(0,CHART_END,-100);  b = 1;} 
//------------------------------------------------------

The disadvantage of this method is that the chart in the background twitches. However, your constructor takes up all of the visible part of it and so it won't be noticeable.

The advantage of this method is that you get excellent scrolling with the wheel, not inferior to the scrolling of Windows windows. There is energy, deceleration... Also, when hovering over a horizontal scroll bar and scrolling the wheel, I have a horizontal scroll bar. It's easy to do this.

With this scrolling, users will feel like they are working in windup).

This is what it looks like: https://www.mql5.com/ru/forum/139237/page7

 
Реter Konow:

I would like to share my experience in implementing scrolling with the wheel. Perhaps my technology will not suit you, but it may give you the right idea (if you have not yet decided on the method of implementation).

Inside the OnChartEvent() function in the condition :

1. I use the ChartNavigate function and set the current chart to the position -100 bars back.

2. I set the number of the first visible bar using ChartGetInteger(0,FIRST_VISIBLE_BAR) into the static variable "First_bar_number".

3. Next, I fix the chart event CHARTEVENT_CHART_CHANGE once through (I use flag "a" and flag "b" for this purpose).

4. I compare "Number_of_the_first_bar" and "Number_of_this_bar" (which I also get via ChartGetInteger(0,FIRST_VISIBLE_BAR), but on each CHARTEVENT_CHART_CHANGE event, not once as with "Number_of_the_first_bar").

and determine the direction of chart shift.

5. Next, everything is simple - I move the kanvas image with ObjectSetInteger(0,G_CORE[CANVAS][_NAME],OBJPROP_YOFFSET,G_CORE[CANVAS][_FIELD_TO_VIEW_Y_DISTANCE]); I return the chart to its original position - ChartNavigate(0,CHART_END,-100);

6. I skip the next chart event because it is generated from the called ChartNavigate function . Then everything repeats itself.

Here is the code:

The disadvantage of this method is that the chart in the background twitches. However, your constructor occupies the whole visible part of it, so it won't be noticeable.

The advantage of this method is that you get excellent wheel scrolling, not inferior to the scrolling of Windows windows. There is energy, deceleration... Also, when hovering over a horizontal scroll bar and scrolling the wheel, I have a horizontal scroll bar. It is easy to do this.

With this scrolling, users will feel like they're working in windup).

This is what it looks like: https://www.mql5.com/ru/forum/139237/page7

Thanks.

What's wrong with CHARTEVENT_MOUSE_WHEEL?

https://www.mql5.com/en/docs/constants/chartconstants/enum_chartevents&nbsp;

Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Типы событий графика
Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Типы событий графика
  • www.mql5.com
Существуют 11 видов событий, которые можно обрабатывать с помощью функции предопределенной функции OnChartEvent(). Для пользовательских событий предусмотрено 65535 идентификаторов в диапазоне от CHARTEVENT_CUSTOM до CHARTEVENT_CUSTOM_LAST включительно. Для генерации пользовательского события необходимо использовать функцию EventChartCustom...
 
Andrey Barinov:

Thank you.

What's wrong with CHARTEVENT_MOUSE_WHEEL?

https://www.mql5.com/en/docs/constants/chartconstants/enum_chartevents&nbsp;

When I did the scrolling with the wheel, it wasn't there yet. So I didn't even try it. (Besides, I'm still working on MT4, and it doesn't seem to be available there).

Does it give energy and deceleration?

 
Реter Konow:

When I did the scrolling with the wheel, it wasn't there yet. That's why I didn't even try it. (Besides, I'm still working on MT4, and it doesn't seem to be available there).

Does it give energy and deceleration?

I don't know, I haven't tried it. I just remember that there is such an event.

 

Good afternoon.

I am the NEOPROGRAMMIST for whom this product and the article about it exist.

I have a question - for educational purposes I tried to reproduce the Expert Advisor from the example number 1 (crossing of fast and slow MA). I did everything as in the article, letter by letter. As a result, the Expert Advisor sometimes opens and immediately closes several positions, instantly creating a loss. And sometimes it opens a single position, all as it should, closes it when the opposite signal arrives. Everything seemed to be good at least with these, but I noticed that they are always only Bai.

The scheme dissolved after rebooting the computer (update at night), so I can not find a possible error, in the code is still too weak, and it is so large and incomprehensible.

Would you be able to review the code and suggest what I did wrong ?

Files:
 
Andrey Barinov:

I don't know, I haven't tried it. I just remember that there is such an event.

The event is there, but no one has used it yet).

I would love to get rid of my method because of chart twitching, but MT4 doesn't have this event, and MT5 doesn't know how it works yet....

 
 
Sergey Voytsekhovsky:

Good afternoon.

I am the NEOPROGRAMMIST for whom this product and the article about it exists.

I have a question - for educational purposes I tried to reproduce the Expert Advisor from the example number 1 (crossing of fast and slow MA). I did everything as in the article, letter by letter. As a result, the Expert Advisor sometimes opens and immediately closes several positions, instantly creating a loss. And sometimes it opens a single position, all as it should, closes it when the opposite signal arrives. Everything seemed to be good at least with these, but I noticed that they are always only Buy.

The scheme dissolved after rebooting the computer (update at night), so I can not find a possible error, in the code is still too weak, and it is so large and incomprehensible.

Would you be able to review the code and suggest what I did wrong ?

Start by looking at pattern #1. This is exactly the same pattern that is considered in the article (only Travelling and Lossless are added). You can see the parameters of all elements and play with them.

There are a number of errors in your Expert Advisor. One of them is that you have not changed the type of transaction in the element for making sales (it says "purchase" instead of sale).

 
Andrey Barinov:

Start by studying pattern #1. This is exactly the scheme considered in the article (only Travelling and Breakeven are added). You can see the parameters of all elements and play with them.

There are some errors in your Expert Advisor. One of them is that you have not changed the type of transaction in the element for making sales (it says "purchase" instead of sale).

Thank you, I was very pleasantly surprised by the promptness of your reply.

I understand about the unchanged transaction type, it's the reason why only purchases work normally.

But in what place is it wrong that in half a second, apparently on every tick, a whole series of orders is opened and closed at once, and there are both buying and selling orders. ???

 
Sergey Voytsekhovsky:

Thank you, very pleasantly surprised by the promptness of the response.

I understand about the unchanged transaction type, it is the reason why only purchases work normally.

But in what place is it wrong that in half a second, apparently on every tick, a whole series of orders is opened and immediately closed, and there are both buy and sell orders. ???

Well, look, you have a buy instead of a sell. At the same time, when a sell signal is given, purchases should be closed! Which it does.

A sell signal appears, the robot opens a buy instead of a sell by mistake, and immediately closes it, then opens it again and closes it again, etc.

Otherwise, everything was correct in your scheme.