Обсуждение статьи "Изучаем класс CCanvas. Реализация прозрачности графических объектов" - страница 3

 

Владимир, огромное спасибо!

Я просто упустил из виду  преобразование ColorToARGB().

 
Dennis Kirichenko:

Владимир, огромное спасибо!

Я просто упустил из виду  преобразование ColorToARGB().

Пожалуйста :) .
 
привет, я думаю, что эта статья является превосходным. У меня есть вопрос, как я могу сделать прямоугольник на экране с координатами x1, x2, y1, y2. где:

x1 = Time[1]

 x2 = Time[0]

y1 = Open[1]

y2 = Close[1] 
 
Jorge Fernando De Los Ríos De Los Ríos:
привет, я думаю, что эта статья является превосходным. У меня есть вопрос, как я могу сделать прямоугольник на экране с координатами x1, x2, y1, y2. где:

x1 = Time[1]

 x2 = Time[0]

y1 = Open[1]

y2 = Close[1] 

By means of the class CCanvas? 

 

P.S. Use CCanvas.CreateBitmap:

Creates a graphical resource bound to a chart object.

1. Creates a graphical resource in the main window of the current chart.

bool  CreateBitmap( 
   const string       name,                                 // name 
   const datetime     time,                                 // time 
   const double       price,                                // price 
   const int          width,                                // width 
   const int          height,                               // height 
   ENUM_COLOR_FORMAT  clrfmt=COLOR_FORMAT_XRGB_NOALPHA      // format 
   );

 

Thus you will be able to bind one corner of a Сanvas. But width and height, all the same, will be set in pixels. 

 

Let's do a excercise more easy. I go to put a circle moves with the price; but, why does not it move in axis Y?

 

That is the code 

void OnStart()
  {
   int ChartWidth=ChartWidthInPixels();
   int ChartHeight=ChartHeightInPixelsGet();

   CCanvas pepe;

   int t1,t0,p1,p0;
   ChartTimePriceToXY(0,0,Time[1],Open[1],t1,p1);
   ChartTimePriceToXY(0,0,Time[0],Close[1],t0,p0);

   pepe.CreateBitmapLabel("canvas_XRGB_NOALPHA",0,0,ChartWidth,ChartHeight,COLOR_FORMAT_ARGB_RAW);
   pepe.Erase(0);
   pepe.FillCircle(t0,p0,25,ColorToARGB(clrBlue,255));
   pepe.Update();
   return(rates_total);
  } 
 
Jorge Fernando De Los Ríos De Los Ríos:

Let's do a excercise more easy. I go to put a circle moves with the price; but, why does not it move in axis Y?

 

That is the code 

This script isn't compiled. In him a heap of mistakes.
 
Jorge Fernando De Los Ríos De Los Ríos:

Let's do a excercise more easy. I go to put a circle moves with the price; but, why does not it move in axis Y?

 

That is the code 

"Time[]", "Close[]" - mistake. There are no such variables in MQL5!
 
Karputov Vladimir:
"Time[]", "Close[]" - mistake. There are no such variables in MQL5!
MQL4 ;)
 
Artyom Trishkin:
MQL4 ;)

Я не приветствую MQL4. Все примеры только на MQL5.

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#include <Canvas\Canvas.mqh>
CCanvas     m_canvas;           // the canvas object
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   datetime arr_time[];
   double   arr_open[];
   double   arr_close[];
   if(CopyTime(Symbol(),Period(),0,2,arr_time)==-1)
      return;
   if(CopyClose(Symbol(),Period(),0,2,arr_close)==-1)
      return;
   if(CopyOpen(Symbol(),Period(),0,2,arr_open)==-1)
      return;
   int x1,y1,x2,y2;
   if(!ChartTimePriceToXY(0,0,arr_time[0],arr_open[0],x1,y1))
      Print("Error ",GetLastError());
   if(!ChartTimePriceToXY(0,0,arr_time[1],arr_close[0],x2,y2))
      Print("Error ",GetLastError());
//x1 = Time[1];
//y1 = Open[1];
//x2 = Time[0];
//y2 = Close[1];
   Print("arr_time[0]=",arr_time[0],", arr_open[0]=",arr_open[0]);
   m_canvas.CreateBitmapLabel("COLOR_FORMAT_ARGB_NORMALIZE",x1,y1,MathAbs(x2-x1),MathAbs(y2-y1),COLOR_FORMAT_ARGB_NORMALIZE);
   m_canvas.Erase(ColorToARGB(clrBlue,200));
   m_canvas.Update();
   Sleep(10000);
   m_canvas.Destroy();
  }
//+------------------------------------------------------------------+
//| Gets the width of chart (in pixels)                              |
//+------------------------------------------------------------------+
int ChartWidthInPixels(const long chart_ID=0)
  {
//--- prepare the variable to get the property value
   long result=-1;
//--- reset the error value
   ResetLastError();
//--- receive the property value
   if(!ChartGetInteger(chart_ID,CHART_WIDTH_IN_PIXELS,0,result))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
     }
//--- return the value of the chart property
   return((int)result);
  }
//+------------------------------------------------------------------+
//| Gets the height of chart (in pixels)                             |
//+------------------------------------------------------------------+
int ChartHeightInPixelsGet(const long chart_ID=0,const int sub_window=0)
  {
//--- prepare the variable to get the property value
   long result=-1;
//--- reset the error value
   ResetLastError();
//--- receive the property value
   if(!ChartGetInteger(chart_ID,CHART_HEIGHT_IN_PIXELS,sub_window,result))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
     }
//--- return the value of the chart property
   return((int)result);
  }
//+------------------------------------------------------------------+

 

И результат работы скрипта:

результат 

 

Владимир, вопрос к Вам как к спецу.

Есть панель в виде холста. А потом на графике рисуются трендовые линии. Как их спрятать за холст?

Скриншоты торговой платформы MetaTrader

RTS Splice, H1, 2016.10.16

АО &#39;&#39;Открытие Брокер&#39;&#39;, MetaTrader 5, Demo

RTS Splice, H1, 2016.10.16, АО &#39;&#39;Открытие Брокер&#39;&#39;, MetaTrader 5, Demo


Причина обращения: