Built an indicator - volatility summary table for selected instruments. The data should be calculated equally, regardless of the chart on which the indicator was installed. However, it calculates it differently. Depending on whether the chart has JPY in the denominator.
If there is, the table looks like this:
if not, it looks like this:
Here is the code:
#property copyright"Vasya Pupkin"#property link""#property indicator_separate_window//------- Внешние параметры индикатора ----------------------------------------+externint BARS = 100; // Кол-во баров для рассчетаexternint eiOffsetY = 15; // Смещение текста по вертикалиexternint eiStepY = 12; // Шаг смещения текста по вертикалиexternint eiX1Row = 3; // Координата X первой колонкиexternint eiX2Row = 50; // Координата X второй колонкиexternint eiX3Row = 100; // Координата X третей колонкиexternint eiX4Row = 150; // Координата X четвёртой колонкиexternint eiX5Row = 200; // Координата X пятой колонкиexternint eiX6Row = 250; // Координата X шестой колонкиexternint eiX7Row = 300; // Координата X седьмой колонкиexternint eiX8Row = 350; // Координата X восьмой колонкиexternint eiX9Row = 400; // Координата X восьмой колонкиexterncolor ecText = Gray; // Цвет текстаexternstring Symbols = "audcad,audchf,audjpy,audnzd,audusd,cadchf,cadjpy,chfjpy,euraud,eurcad";
//------- Глобальные переменные индикатора ------------------------------------+int nWindow_ToDay; // Номер окна//------- Буферы индикатора ---------------------------------------------------+//------- Поключение внешних модулей ------------------------------------------+//+----------------------------------------------------------------------------+//| Custom indicator initialization function |//+----------------------------------------------------------------------------+void init() {
nWindow_ToDay=WindowFind("VolatilityTab");
if (nWindow_ToDay<0) nWindow_ToDay=WindowsTotal();
DeleteObjects();
Comment("");
}
//+----------------------------------------------------------------------------+//| Custom indicator deinitialization function |//+----------------------------------------------------------------------------+void deinit() {
DeleteObjects();
Comment("");
}
//+----------------------------------------------------------------------------+//| Custom indicator iteration function |//+----------------------------------------------------------------------------+void start() {
DeleteObjects();
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SetLabel("Volatility_00", "TF", Red, eiX1Row, eiOffsetY+eiStepY);
SetLabel("Volatility_10", "M5", ecText, eiX1Row, eiOffsetY+2*eiStepY);
SetLabel("Volatility_20", "M15", ecText, eiX1Row, eiOffsetY+3*eiStepY);
SetLabel("Volatility_30", "M30", ecText, eiX1Row, eiOffsetY+4*eiStepY);
SetLabel("Volatility_40", "H1", ecText, eiX1Row, eiOffsetY+5*eiStepY);
SetLabel("Volatility_50", "H4", ecText, eiX1Row, eiOffsetY+6*eiStepY);
SetLabel("Volatility_60", "D1", ecText, eiX1Row, eiOffsetY+7*eiStepY);
SetLabel("Volatility_70", "Week", ecText, eiX1Row, eiOffsetY+8*eiStepY);
SetLabel("Volatility_80", "Month", ecText, eiX1Row, eiOffsetY+9*eiStepY);
string syb[];
int k, r, countX,countY=1;
StrSplit(Symbols, syb, ",");
if (ArraySize(syb)==0) StrSplit(Symbols, syb, ";");
r=ArraySize(syb);
for (k=0; k<r; k++) {
syb[k]=StringUpper(syb[k]);
countX++;
SetLabel("Volatility_"+"0"+countX, syb[k], Red, countX*eiX2Row, eiOffsetY+eiStepY);
int i,s1=0,s2=0,s3=0,s4=0,s5=0,s6=0,s7=0,s8=0,b;
for (i=BARS; i>0; i--)
{
s1+=(iHigh(syb[k],5,i)-iLow(syb[k],5,i))/Point;
//Comment(MarketInfo(syb[k],MODE_DIGITS));
s2+=(iHigh(syb[k],15,i)-iLow(syb[k],15,i))/Point;
s3+=(iHigh(syb[k],30,i)-iLow(syb[k],30,i))/Point;
s4+=(iHigh(syb[k],60,i)-iLow(syb[k],60,i))/Point;
s5+=(iHigh(syb[k],240,i)-iLow(syb[k],240,i))/Point;
s6+=(iHigh(syb[k],1440,i)-iLow(syb[k],1440,i))/Point;
s7+=(iHigh(syb[k],10080,i)-iLow(syb[k],10080,i))/Point;
s8+=(iHigh(syb[k],43200,i)-iLow(syb[k],43200,i))/Point;
b++;
}
SetLabel("Volatility_"+countY+countX,s1/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+2*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s2/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+3*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s3/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+4*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s4/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+5*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s5/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+6*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s6/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+7*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s7/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+8*eiStepY);
countY++;
SetLabel("Volatility_"+countY+countX,s8/b+ " п.", ecText, countX*eiX2Row, eiOffsetY+9*eiStepY);
s1=0;
s2=0;
s3=0;
s4=0;
s5=0;
s6=0;
s7=0;
s8=0;
b=0;
countY=1;
}
}
//+----------------------------------------------------------------------------+//| Удаление объектов. |//+----------------------------------------------------------------------------+void DeleteObjects() {
string st="Volatility_";
int i, j;
for (i=0; i<9; i++) {
for (j=0; j<15; j++) ObjectDelete(st+i+j);
}
}
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 12.10.2007 |//| Описание : Установка текстовой метки |//+----------------------------------------------------------------------------+//| Параметры: |//| nm - наименование объекта |//| tx - текст |//| cl - цвет метки |//| xd - координата X в пикселах |//| yd - координата Y в пикселах |//| cr - номер угла привязки (0 - левый верхний) |//| fs - размер шрифта (8 - по умолчанию) |//+----------------------------------------------------------------------------+void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=8) {
if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_LABEL, nWindow_ToDay, 0,0);
ObjectSetText(nm, tx, fs);
ObjectSet(nm, OBJPROP_COLOR , cl);
ObjectSet(nm, OBJPROP_XDISTANCE, xd);
ObjectSet(nm, OBJPROP_YDISTANCE, yd);
ObjectSet(nm, OBJPROP_CORNER , cr);
ObjectSet(nm, OBJPROP_FONTSIZE , fs);
}
//+----------------------------------------------------------------------------+//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 01.09.2005 |//| Описание : Разбиение строки на массив элементов |//+----------------------------------------------------------------------------+//| Возврат: |//| Количество элементов в массиве |//| Параметры: |//| source - текстовая строка |//| dest - выходной массив |//| delimeter - разделитель |//+----------------------------------------------------------------------------+int StrSplit(string source, string& dest[], string delimeter=";") {
int cnt=0;
int last_pos=0;
int pos=StringFind(source, delimeter, last_pos);
while (pos!=-1) {
ArrayResize(dest, cnt+1);
dest[cnt]=StringSubstr(source, last_pos, pos-last_pos);
cnt++;
last_pos=pos+1;
pos=StringFind(source, delimeter, last_pos);
}
if (last_pos!=0 && last_pos<StringLen(source)) {
ArrayResize(dest, cnt+1);
dest[cnt]=StringSubstr(source, last_pos, StringLen(source)-last_pos);
cnt++;
}
return (cnt);
}
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 01.09.2005 |//| Описание : Возвращает строку в ВЕРХНЕМ регистре |//+----------------------------------------------------------------------------+string StringUpper(string s) {
int c, i, k=StringLen(s), n;
for (i=0; i<k; i++) {
n=0;
c=StringGetChar(s, i);
if (c>96 && c<123) n=c-32; // a-z -> A-Zif (c>223 && c<256) n=c-32; // а-я -> А-Яif (c==184) n=168; // ё -> Ёif (n>0) s=StringSetChar(s, i, n);
}
return(s);
}
Что нового по сравнению с версией 1.4? stSender. Изменена процедура записи файлов под требования билда 610 и выше. stReceiver. Функции проверки существования файла и копирования файлов заменены на аналогичные, поддерживающие UNICODE (для работоспособности в билде 610 и выше). Разработан и доступен для покупки новый советник e-Reverser...
Built an indicator - volatility summary table for selected instruments. The data should be calculated equally, regardless of the chart on which the indicator was installed. However, it calculates it differently. Depending on whether the chart has JPY in the denominator.
Already encountered this - JPY has less fractional digits. Therefore the Point will be different. Or something else?
Hello, could you please tell me how to do this? How can I prescribe, that trailing stop was not close to the indicator, but 10 points lower or higher respectively?
if (OrderMagicNumber()==Magic&&OrderSymbol()==Symbol()&&OrderType()==OP_BUY&&
NormalizeDouble(SAR,Digits)>NormalizeDouble(OrderStopLoss(),Digits)&&NormalizeDouble(SAR,Digits)<NormalizeDouble(Bid,Digits))
OrderModify(OrderTicket(),0,SAR,0,0,Blue);
How to solve this problem? I wrote an EA where a pending order with increased lot (e.g. by 2 times) is placed on an unsuccessful trade,
But when the pending order is executed (rarely, in 1 out of 10 cases), the lot is not multiplied by the coefficient, even though it was initially placed according to the algorithm.
Here is an example:
a deal was closed with 0.4 lots and an pending order with 0.8 lot is placed; when it is executed, the volume turns out to be 0.4 lot.
How to solve this problem? I wrote an EA where a pending order with increased lot (e.g. by 2 times) is placed on an unsuccessful trade,
But when the pending order is executed (rarely, in 1 out of 10 cases), the lot is not multiplied by the coefficient, even though it was initially placed according to the algorithm.
Here is an example:
a deal was closed with 0.4 lots, immediately a pending order is placed with 0.8 lot and when it is executed, the volume turns out to be 0.4 lot.
What may it be?
Thank you.
Could it be a partial occurence? What is in the logs?
Good evening.
Built an indicator - volatility summary table for selected instruments. The data should be calculated equally, regardless of the chart on which the indicator was installed. However, it calculates it differently. Depending on whether the chart has JPY in the denominator.
If there is, the table looks like this:
if not, it looks like this:
Here is the code:
Good evening.
Built an indicator - volatility summary table for selected instruments. The data should be calculated equally, regardless of the chart on which the indicator was installed. However, it calculates it differently. Depending on whether the chart has JPY in the denominator.
Already encountered this - JPY has less fractional digits. Therefore the Point will be different. Or something else?
By the way, it is recommended to use Point() or _PointI've already encountered this - JPY has less fractional digits. Therefore Point will be different
tried adding a condition
and here divided by Z^
but in the end, on the pair without the yen, everything is clear:
but with yen it's a mess:
tried adding a condition
and here divided by Z^
but in the end, on the pair without the yen, everything is clear:
But with yen it's a mess:
ReplacePoint with "SymbolInfoDouble(syb[k],SYMBOL_POINT)"
ReplacePoint with "SymbolInfoDouble(syb[k],SYMBOL_POINT)"
Thank you, now it's clear everywhere, and no screw ups
Thank you, now it's clear everywhere, and no screw-ups.
Optimise the code a bit, call the calculation just once on one character:
Optimise the code a bit, call the calculation just once on one character:
And in that spirit, reduce all code to a concise array operation. Any repetitions of the same logic should be designed as loops.
Good day!
How to solve this problem? I wrote an EA where a pending order with increased lot (e.g. by 2 times) is placed on an unsuccessful trade,
But when the pending order is executed (rarely, in 1 out of 10 cases), the lot is not multiplied by the coefficient, even though it was initially placed according to the algorithm.
Here is an example:
a deal was closed with 0.4 lots and an pending order with 0.8 lot is placed; when it is executed, the volume turns out to be 0.4 lot.
What may it be?
Thank you.
Good day!
How to solve this problem? I wrote an EA where a pending order with increased lot (e.g. by 2 times) is placed on an unsuccessful trade,
But when the pending order is executed (rarely, in 1 out of 10 cases), the lot is not multiplied by the coefficient, even though it was initially placed according to the algorithm.
Here is an example:
a deal was closed with 0.4 lots, immediately a pending order is placed with 0.8 lot and when it is executed, the volume turns out to be 0.4 lot.
What may it be?
Thank you.
Could it be a partial occurence? What is in the logs?