Price Data Components
Miscellaneous
0
Views
0
Downloads
0
Favorites
CurrencyChart
//+------------------------------------------------------------------+
//| CurrencyChart.mq4 |
//| Strator |
//| k-v-p@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Strator"
#property link "k-v-p@yandex.ru"
//----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Green
//---- input parameters
extern string symbol = "EURUSD";
extern double verticalShiftFactor = 0.6;
extern bool useMultiply=false;
//---- buffers
double buffer_close[];
//---- variables
bool exit = false;
//+------------------------------------------------------------------+
//| Ïåðåâîä ñòðîêè â âåðõíèé ðåãèñòð |
//+------------------------------------------------------------------+
string StringUCase(string str)
{
for(int i = 0; i < StringLen(str); i++)
{
int char = StringGetChar(str, i);
if((char >= 97 && char <= 122) || (char >= 224 && char <= 255))
char = char - 32;
str = StringSetChar(str, i, char);
}
return(str);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
symbol = StringUCase(symbol);
MarketInfo(symbol, MODE_TIME);
int last_error = GetLastError();
if(last_error == 4106) //ERR_UNKNOWN_SYMBOL
{
string msg = "Íåèçâåñòíûé ñèìâîë:" + symbol;
IndicatorShortName(msg);
Print(msg);
exit = true;
}
else
{
IndicatorShortName(symbol + ",M" + Period());
SetIndexBuffer(0, buffer_close);
SetIndexStyle(0, DRAW_LINE);
IndicatorDigits(MarketInfo(symbol, MODE_DIGITS));
}
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if(exit)
return(0);
int counted_bars = Bars - IndicatorCounted() - 1;
for(int i = 0; i < counted_bars; i++)
{
datetime time_bar = Time[i];
int bar_no = iBarShift(symbol, Period(), time_bar, false);
if(useMultiply)buffer_close[i] = iClose(symbol, Period(), bar_no)*verticalShiftFactor;
else buffer_close[i] = iClose(symbol, Period(), bar_no)+verticalShiftFactor;
}
SetLevelStyle(DRAW_LINE, 1, DarkGray);
SetLevelValue(0, MarketInfo(symbol, MODE_BID));
return(0);
}
//+------------------------------------------------------------------+
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
---