0
Views
0
Downloads
0
Favorites
tradepad_sample
//+------------------------------------------------------------------+
//| TradePad_Sample |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#include "ClassTradePad.mqh"
input int TableRows=5;
int TableCols=5;
input int TableTop=40;
input int TableLeft=20;
input int CellWidth=70;
input int CellHeight=40;
input int TimerPeriodSeconds=5;
input color UpTrendColor=OliveDrab;
input color DownTrendColor=HotPink;
input color FlatColor=DarkGray;
input color UnknownTrend=Cornsilk;
bool launched=false;
CTradePad SymbolTable;
//+------------------------------------------------------------------+
//| ñîçäàòü òàáëèöó ñèìâîëîâ ÷åðåç îáúåêò CTradePad |
//+------------------------------------------------------------------+
bool CreatePad(int cols,int rows)
{
bool res=false;
//---
SymbolTable.CreateTradePad(TableCols,TableRows,TableLeft,TableTop,CellWidth,CellHeight,UpTrendColor,DownTrendColor,FlatColor,UnknownTrend);
//---
return(res);
}
//+------------------------------------------------------------------+
//| óäàëèòü îáúåêò CTradePad |
//+------------------------------------------------------------------+
bool DeletePad()
{
bool res=false;
//---
int del=SymbolTable.DeleteTradePad();
if(ObjectFind(0,SymbolTable.GetChartName())>=0)ObjectDelete(0,SymbolTable.GetChartName());
ChartRedraw(0);
//Print(del," Symbols deleted");
//---
return(res);
}
//+------------------------------------------------------------------+
//| èíèöèàëèçàöèÿ ïðè çàïóñêå èëè ïåðåèíèöèàëèçàöèè |
//+------------------------------------------------------------------+
void OnInit()
{
EventSetTimer(TimerPeriodSeconds);
Print("Init");
if(!launched)
{
CreatePad(TableCols,TableRows);
launched=true;
}
}
//+------------------------------------------------------------------+
//| ïðè çàâåðøåíèè ðàáîòû ñîâåòíèêà è èçìåíåíèè âõîäíûõ ïàðàìåòðîâ |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Print("Deinit");
launched=false;
//--- îòêëþ÷èì òàéìåð
EventKillTimer();
//--- óäàëèì îáúåêò
DeletePad();
}
//+------------------------------------------------------------------+
//| Process chart events |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
//Print("Ñîáûòèå OnChartEvent: lparam =",lparam," dparam=",dparam);
if(id==CHARTEVENT_OBJECT_CLICK)
{
string clickedButton=sparam;
SymbolTable.SetButtons(clickedButton);
ChartRedraw();
}
if(id==CHARTEVENT_OBJECT_DRAG)
{
string dragged=sparam;
//Print("Ïåðåìåùåí îáúåêò ",dragged," lparam =",lparam," dparam=",dparam);
if(dragged==SymbolTable.GetHeaderName())
{
int x=ObjectGetInteger(0,dragged,OBJPROP_XDISTANCE);
int y=ObjectGetInteger(0,dragged,OBJPROP_YDISTANCE);
SymbolTable.GetShiftTradePad(x,y);
//Print("X ñìåùåíèå = ",x," Y ñìåùåíèå = ",y);
SymbolTable.MoveTradePad(x,y);
ChartRedraw();
}
}
}
//+------------------------------------------------------------------+
//| îáðàáîòêà ñîáûòèé òàéìåðà |
//+------------------------------------------------------------------+
void OnTimer()
{
//Print("Timer event");
if(launched)SymbolTable.SetButtonColors();
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---