Good day to all. There is a need to analyse information from a senior timeframe.
The system has a condition to build a channel. It's finding the maximum and minimum prices for a certain number of bars. I implemented it using the following method:
externENUM_TIMEFRAMES TimeFrameRZ = PERIOD_M15; //Период разворотной зоныexternENUM_TIMEFRAMES TimeFrameIn = PERIOD_M5; //Период точки входаexternint ATR_period = 14;
externint UpLineSell = 7;
externint DownLineSell = 7;
externint UpLineBuy = 7;
externint DownLineBuy = 7;
// Параметры разворотных свечейexternstring Comment2 = "---------------------------------Параметры разворотных свечей------------------------------------------";
externint Volotilnost = 20; // Диапазон цен для трех разворотных свечей (в пунктах)externint MaxLineSell = 3;
externint MaxLineBuy = 3;
bool SellPattern = false;
bool BuyPattern = false;
bool New_Bar = false;
double UpLine_Sell = 0;
double DownLine_Sell = 0;
double UpLine_Buy = 0;
double DownLine_Buy = 0;
int i = 0, j = 0;
int ULs = 0;
int DLs = 0;
int ULb = 0;
int DLb = 0;
double MassZone[2][10];
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
if(Digits == 3 || Digits ==5 )
{
Volotilnost *=10;
UpLineSell *= 10;
DownLineSell *= 10;
UpLineBuy*= 10;
DownLineBuy*= 10;
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
RazvorotZona();
if(SellPattern == true)
{
if(ObjectCreate(ChartID(),"UpLine_Sell"+IntegerToString(ULs),OBJ_HLINE,0,TimeCurrent(),UpLine_Sell))
{
ObjectSetInteger(ChartID(),"UpLine_Sell"+IntegerToString(ULs),OBJPROP_COLOR,clrOrange);//--- установим цвет прямоугольника ObjectSetInteger(ChartID(),"UpLine_Sell"+IntegerToString(ULs),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника ObjectSetInteger(ChartID(),"UpLine_Sell"+IntegerToString(ULs),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника ObjectSetInteger(ChartID(),"UpLine_Sell"+IntegerToString(ULs),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане
}
if(ObjectCreate(ChartID(),"DownLine_Sell"+IntegerToString(DLs),OBJ_HLINE,0,TimeCurrent(),DownLine_Sell))
{
ObjectSetInteger(ChartID(),"DownLine_Sell"+IntegerToString(DLs),OBJPROP_COLOR,clrMagenta);//--- установим цвет прямоугольника ObjectSetInteger(ChartID(),"DownLine_Sell"+IntegerToString(DLs),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника ObjectSetInteger(ChartID(),"DownLine_Sell"+IntegerToString(DLs),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника ObjectSetInteger(ChartID(),"DownLine_Sell"+IntegerToString(DLs),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане
}
ULs++;
DLs++;
if(DLs >= MaxLineSell && ULs >= MaxLineSell)
{
ObjectDelete(ChartID(),"UpLine_Sell"+IntegerToString(ULs - MaxLineSell));
ObjectDelete(ChartID(),"DownLine_Sell"+IntegerToString(DLs - MaxLineSell));
}
}
if(BuyPattern == true)
{
if(ObjectCreate(ChartID(),"UpLine_Buy"+IntegerToString(ULb),OBJ_HLINE,0,TimeCurrent(),UpLine_Buy))
{
ObjectSetInteger(ChartID(),"UpLine_Buy"+IntegerToString(ULb),OBJPROP_COLOR,clrDeepSkyBlue);//--- установим цвет прямоугольника ObjectSetInteger(ChartID(),"UpLine_Buy"+IntegerToString(ULb),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника ObjectSetInteger(ChartID(),"UpLine_Buy"+IntegerToString(ULb),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника ObjectSetInteger(ChartID(),"UpLine_Buy"+IntegerToString(ULb),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане
}
if(ObjectCreate(ChartID(),"DownLine_Buy"+IntegerToString(DLb),OBJ_HLINE,0,TimeCurrent(),DownLine_Buy))
{
ObjectSetInteger(ChartID(),"DownLine_Buy"+IntegerToString(DLb),OBJPROP_COLOR,clrBrown);//--- установим цвет прямоугольника ObjectSetInteger(ChartID(),"DownLine_Buy"+IntegerToString(DLb),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника ObjectSetInteger(ChartID(),"DownLine_Buy"+IntegerToString(DLb),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника ObjectSetInteger(ChartID(),"DownLine_Buy"+IntegerToString(DLb),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане
}
ULb++;
DLb++;
if(ULb >= MaxLineBuy && DLb >= MaxLineBuy)
{
ObjectDelete(ChartID(),"UpLine_Buy"+IntegerToString(ULb - MaxLineBuy));
ObjectDelete(ChartID(),"DownLine_Buy"+IntegerToString(DLb - MaxLineBuy));
}
}
}
//+------------------------------------------------------------------+// Функция определения нового бара |//+------------------------------------------------------------------+void Find_New_Bar()
{
datetime TimeBar0 = iTime(Symbol(),TimeFrameRZ,0);
staticdatetime New_Time=0; // Время текущего бара
New_Bar=false; // Нового бара нет if(New_Time != TimeBar0) // Сравниваем время
{
New_Time = TimeBar0; // Теперь время такое
New_Bar = true; // Поймался новый бар
}
}
//+------------------------------------------------------------------+// Функция определения разворотной зоны |//+------------------------------------------------------------------+void RazvorotZona()
{
Find_New_Bar();
double Open3= NormalizeDouble (iOpen(Symbol(), TimeFrameRZ,4),Digits);
double Close3 = NormalizeDouble (iClose(Symbol(), TimeFrameRZ,4),Digits);
double High3 = NormalizeDouble (iHigh(Symbol(), TimeFrameRZ,4),Digits);
double Low3 = NormalizeDouble (iLow(Symbol(), TimeFrameRZ,4),Digits);
//Параметры индикатора волотильности ATR для нахожденя относительно большой свечи перед перевернутым Молотомdouble ATR = iATR(Symbol(),TimeFrameRZ,ATR_period,1);
SellPattern = false;
BuyPattern = false;
int bar1 = 1;
int bar2 = 3;
double Max, Min;
Max = High[iHighest(NULL, TimeFrameRZ, MODE_HIGH, bar2, bar1)]; //1. Ищем High и Low на отрезке [bar1, bar2].
Min = Low[iLowest(NULL, TimeFrameRZ, MODE_LOW, bar2, bar1)];
if(NormalizeDouble((Max - Min) / Point, Digits) < Volotilnost &&
MathAbs(Close3-Open3) > 1.5*ATR)
{
if((Close3 > Open3) && New_Bar == true)
{
UpLine_Sell = Max;
DownLine_Sell = Min;
SellPattern = true;
Print ("Идентифицирован паттерн");
Print ("Максимальная цена "+DoubleToStr(Max));
Print ("Минимальная цена "+DoubleToStr(Min));
}
else {SellPattern = false;}
if((Close3 < Open3) && New_Bar == true)
{
UpLine_Buy = Max;
DownLine_Buy = Min;
BuyPattern = true;
Print ("Идентифицирован паттерн");
}
else {BuyPattern = false;}
}
}
But this approach leads to analysis of bars from the current working timeframe M5. I need bar1 and bar2 parameters to be taken from M15
I have a feeling the problem is somewhere in here.
Max = High[iHighest(NULL, TimeFrameRZ, MODE_HIGH, bar2, bar1)]; //1. Ищем High и Low на отрезке [bar1, bar2].
Min = Low[iLowest(NULL, TimeFrameRZ, MODE_LOW, bar2, bar1)];
Can you tell me how to output ZigZag indicator values into an EA? The others are output by writing iMA, iStochastic, iWPR ... How do I manually calculate ZigZag?
ZZuretc: Please advise how to output the values of the ZigZag indicator into the EA? The others are printed by iMA, iStochastic, iWPR ... How do I manually calculate ZigZag?
Decided to use? The ZigZag indicator values are zero everywhere. Only in the tops the zigzag value is equal to the price at the top.
You have to go through the bars in a loop. See example
it works for me - it tracks mouse movement
I mean surolling).Good day to all. There is a need to analyse information from a senior timeframe.
The system has a condition to build a channel. It's finding the maximum and minimum prices for a certain number of bars. I implemented it using the following method:
But this approach leads to analysis of bars from the current working timeframe M5. I need bar1 and bar2 parameters to be taken from M15
How to implement this?
I have a feeling the problem is somewhere in here.
Who's to say what?
I have a feeling the problem is somewhere in here.
Who's to say what?
Well, yeah, specify the right timeframe.
Right, specify the correct timeframe
So I said...
TimeFrameRZ = PERIOD_M15It's an external variable.I declare an array and fill in the elements.
Why do I get a declaration without type error on the second line?
I declare an array and fill in the elements.
Why do I get a declaration without type error on the second line?
Write code in void OnTick() and everything will work.
Or writearray[0]=0.1; in void OnTick()
I declare an array and fill in the elements.
Why do I get a declaration without type error on the second line?
Are you declaring the array in the area of global variables?
Then declare it at once with values (since you fill them yourself in the code, so they are predefined), for example:
... Or fill the array with values in OnInit() or in the function, where it will be filled.
Please advise how to output the values of the ZigZag indicator into the EA? The others are printed by iMA, iStochastic, iWPR ... How do I manually calculate ZigZag?
Decided to use? The ZigZag indicator values are zero everywhere. Only in the tops the zigzag value is equal to the price at the top.
You have to go through the bars in a loop. See example