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

 
Artyom Trishkin:

ChartIndicatorAdd()

Thank you. It is only here that the EA displays the indicator which is not directly in the chart. I have a question about how to display the calculations of the EA itself.

 
Andrey Sokolov:

Thank you. Only here, the EA displays the indicator not directly in the chart. I have a question how to display the calculations of the EA itself.

OBJ_LABEL

ObjectSetString - entering data

ObjectGetString - getting data


As an example, I have




 
Andrey Sokolov:

Thank you. Only here, the EA displays the indicator not directly in the chart. I have a question on how to display the calculations of the EA itself.

Take a canvas (CCanvas) and draw. Translation of time and price to chart coordinates, using ChartTimePriceToXY.

 
MakarFX:

On which timeframe?

М1

 

Greetings, I can't figure out why the SELECT_BY_TICKET selection does not work in this design, unlike SELECT_BY_POS.

void Ticket_Limits (int magic ){


int _GetLastError = 0, k = OrdersTotal();
        Ticket_Total = 0;
        
// изменяем размеры массивов под текущее кол-во позиций
        // (если _OrdersTotal = 0, меняем размер массивов на 1)
        int temp_value = MathMax( k, 1 );
        ArrayResize( _Tacket,                   temp_value );
        ArrayResize( _Type,                        temp_value );
        ArrayResize( _OpenPrice,                temp_value );   
        // обнуляем массивы
        ArrayInitialize( _Tacket,               0 );
        ArrayInitialize( _Type,                 0 );
        ArrayInitialize( _OpenPrice,    0 );
        
        for ( int z = k-1;z>=0; z -- )
        {

           Print("z =",z);
                if (!OrderSelect( z, SELECT_BY_POS ))
                {
                        _GetLastError = GetLastError();
                        Print( "OrderSelect( ", z, ", SELECT_BY_TICKET  ) - Error #", _GetLastError );
                        continue;
                }
                if ( OrderMagicNumber() == magic && OrderSymbol() == Symbol() )
                {
                        // заполняем массивы
                        _Tacket               [Ticket_Total] = OrderTicket();
                        _Type                         [Ticket_Total] = OrderType();
                        _OpenPrice                      [Ticket_Total] = NormalizeDouble( OrderOpenPrice(), _Digits );
                        Ticket_Total++;
                        Print("_Tacket === ",_Tacket[z]," _Type === ",_Type[z]," _OpenPrice === ",_OpenPrice[z]);
                }
          
        }               
        // изменяем размеры массивов под кол-во позиций, принадлежащих эксперту
        // (если Ticket_Total = 0, меняем размер массивов на 1)
        temp_value = MathMax( Ticket_Total, 1 );
        ArrayResize( _Tacket,                   temp_value );
        ArrayResize( _Type,                        temp_value );
        ArrayResize( _OpenPrice,                temp_value );
} 
 
Hi guys, I apologize if I am going in the wrong direction: Can you help me how to make an indicator put on the phone in MT4, such as mooving to time frame m15, was not visible on this pair on the time frame of m5, or any other TF.
 
MakarFX, Mihail Matkovskij
thank you. But my question is not about that. It's about how to draw data from arrays, like from indicator buffers, if it' s possible.
 
Andrey Sokolov:
ChartTimePriceToXY and you're done. Draw either points or lines or other primitives, or display arrows (Windings font) based on coordinates you get. CCanvashas all the methodsfor that. Just create a canvas that covers the whole screen and you can draw as you want. But at the same time you have to constantly redraw Kanvas in OnChartEvent(id: CHARTEVENT_CHART_CHANGE). All in all, you need to learn how to work with CCanvas first. But if you're new to programming, and you're too lazy to learn it all, then Freelance is your help.
 
Galim_V:

Greetings! I can't understand why in this design the SELECT_BY_TICKET selection does not work, unlike SELECT_BY_POS.

BecauseSELECT_BY_TICKET select s the order by its ticket. And you select them in order (SELECT_BY_POS).To select orders by ticket, report the tickets to the OrderSelect function, not the indexes.

 
Mihail Matkovskij:

With CCanvas you can draw anything you want. Copy the time(with CopyTime) and array data (so that the cell in time array clearly matches the cell in your data array). Convert it into pixels with ChartTimePriceToXY and you're done. Draw either points or lines or other primitives, or display arrows (Windings font) based on coordinates you get. CCanvashas all the methodsfor that. Just create a canvas that covers the whole screen and you can draw as you want. But at the same time, the canvas has to be constantly redrawn in OnChartEvent(id: CHARTEVENT_CHART_CHANGE). All in all, you need to learn how to work with CCanvas first. But if you're new to programming, and you're too lazy to learn it all, then Freelance is your help.

thanks

Reason: