Doing interesting things for free - page 20

 
DmitriyN: It's something else.
You're wrong your zig-zag knee ratio problem has been solved by many(not just that script ), although I'm not imposing it.
 
You need to mark out the minima of the maxima,
come up with the criteria for finding the shapes-
and then we take the starting point,
look for a no-holds-barred up/down move,
and then look for a stick of percentages next to it.

Actually, it's almost a simple zigzag.
And instead of a stake, you can build a distribution-.
how much knee #X is from the previous one.
 
Vinin:

The fish are not there

Stadium director (c)

Yes, there are fish there... If the movement was no less than 60.0 pips and the pullback was no less than 25% - then the slippage on the levels will not be more than 2-3 times... and then you can use martini as well :-)
 
DmitriyN:
It's a good joke, but at least comment on your point of view.

A lot has been broken on ZZ, and not only by me. Maybe a different approach is needed. I recently finished pattern recognition (with Kohonen) and decision making. Unfortunately the result is negative. Maybe we should just use a comprehensive approach.
 
GaryKa:
You're wrong your zig-zag knee ratio problem has been solved by many (not just this script), though I'm not imposing it.
It's not about the ratio. The ratio of knees is a separate topic. I mean the search of the maximal trend on the chart.
This script? I do not understand what it is all about. At least explain it then.
 
#property copyright "Copyright c 2003"
#property link ""

#property indicator_chart_window
//---- input parameters
extern color LabelFontColor = Lime;
extern int LabelFontSize = 8;

//---- buffers
// Счётчик для всяких функций
int i = 0;
// Счётчик для уникальных имён
double NUN=0;
// Уникальное имя текстового объекта
int Rmm1=0; string MM1Im; string MM1; double MM1Mi = 100;double MM1Ma = 0;
int Rmm2=0; string MM2Im; string MM2; double MM2Mi = 100;double MM2Ma = 0;
int Otk1=0; string Ot1; double Ot1Mi = 100;double Ot1Ma = 0; // первая откатка в 25%
int Otl1=0; string Ol1; double Ol1Mi = 100;double Ol1Ma = 0; // первая откатка в 25%
int Otl2=0; string Ol2; double Ol2Mi = 100;double Ol2Ma = 0; // первая откатка в 25%
int Teik=0; string Te; double TeMi = 100;double TeMa = 0; // первая откатка в 25%
int Stop=0; string St; double StMi = 100;double StMa = 0; // первая откатка в 25%

string cSt1; double cSt1Mi = 100;double cSt1Ma = 0; // первая откатка в 25%
string cTe1; double cTe1Mi = 100;double cTe1Ma = 0; // первая откатка в 25%
string Ot2; double Ot2Mi = 100;double Ot2Ma = 0; // первая откатка в 25%
string St2; double St2Mi = 100;double St2Ma = 0; // первая откатка в 25%
string Te2; double Te2Mi = 100;double Te2Ma = 0; // первая откатка в 25%
string cSt2; double cSt2Mi = 100;double cSt2Ma = 0; // первая откатка в 25%
string cTe2; double cTe2Mi = 100;double cTe2Ma = 0; // первая откатка в 25%



//общая часть наименований текстовых объектов
string _BareSize = "NC5_";

int KolVo_Barov = 0;// колво баров...

// Направление сделки
// 0 - ищем Минимум на графике... после которого Максимум имеется не менее 60 пипсов...
// 1 - нашли такой Максимум - теперь ищем Откатку в 0.25 или Новый Максимум..
int NapSd = 0;
int NapSd1 = 0;
//
double Mn001=100,Ma001=0;
double Mn002=100,Ma002=0;
double Mn003=100,Ma003=0;


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
DeleteBarSizeLabels();
return(0);
}
//+------------------------------------------------------------------+
void DeleteBarSizeLabels() {
int ArrSize = 0;
int i;
string ObjectsColl[20000];
for(i = 0; i < ObjectsTotal(); i++) {
//сформируем массив удаляемых объектов - только построенных данным идикатором
if(StringFind(ObjectName(i), _BareSize, 0) != -1){
ObjectsColl[ArrSize] = ObjectName(i);
ArrSize++;
}
}
//удаляем согласно списку
for(i = 0; i < ArrSize; i++) ObjectDelete(ObjectsColl[i]);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
Print("Deintit Indikatora");
DeleteBarSizeLabels();
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int counted_bars = IndicatorCounted(); //
int limit;
double i1;// чем кончился день..
double i3;// чем кончился день..
string i2 = "";
int stavka = 1;
int napstv = 0;
int Lott =0;
int prz=0; // признак продолжения ставки
double Res1 = 0;// итог сделки в пипсах
double Res2 = 0;// итог сделки в пипс*лоты
double Res3 = 0;// итог сделок
double Res4 = 0;// положительный итог сделок
double BaksRos = 0;// скоко дней бакс рос
double CeOtk = 0;// цена открытия сделки с учётом спреда...
double MaksiSt = 0;// Максимальная ставка
double teik = 0;
double loss = 0;

double Size; // итог сделки в пипах
int Explic = MathPow(10, MarketInfo(Symbol(), MODE_DIGITS));
int Pr1 =0; 
for( i = Bars-20; i >= 0; i--) {
NapSd = NapSd1;
//+------------------------------------------------------------------+
//| Поиск Нового МИНИМУМА
//+------------------------------------------------------------------+
if (NapSd == 0 || NapSd == 1 || NapSd == 2 ) {
if (Low[i] < MM1Mi) {
// нашли новый минимум
// надо нарисовать границы поиска максимума...
MM1Mi = Low[i];
MM1Ma = Low[i]+250*Point;
// определим новые имена для рисования Квадрата поиска
MM1Im = _BareSize + DoubleToStr(NUN,0); NUN++;
MM1 = _BareSize + DoubleToStr(NUN,0); NUN++;
ObjectCreate(MM1Im, OBJ_TEXT, 0, Time[i+1], High[i] + 10*Point);
ObjectSetText(MM1Im, "Поиск New Min" ,LabelFontSize, "Arial",Snow);// LightCyan);
ObjectSet(MM1Im, OBJPROP_ANGLE,90);
// Рисуем КВАДРАТ поиска Максимума
ObjectCreate(MM1, OBJ_RECTANGLE, 0, Time[i+1], MM1Mi, Time[i], MM1Ma);
ObjectSet(MM1,OBJPROP_COLOR, Teal);
Rmm1 = 0;
Rmm2 = 0;
Otk1 = 0;
Otl1 = 0;
Otl2 = 0;
Teik = 0;
NapSd = -1; NapSd1 = 1; // поиск Движухи в 60 пипов
}
}
//+------------------------------------------------------------------+
//| поиск Движухи в 60 пипов
//+------------------------------------------------------------------+
if (NapSd == 1 ) ObjectSet(MM1,OBJPROP_TIME2, Time[i]);
if (NapSd == 2 ) ObjectSet(MM1,OBJPROP_TIME2, Time[i]);
if (NapSd == 3 ) ObjectSet(MM1,OBJPROP_TIME2, Time[i]);
if (Otk1 == 1 ) ObjectSet(Ot1,OBJPROP_TIME2, Time[i]);
if (Otl2 == 1 ) ObjectSet(Ol2,OBJPROP_TIME2, Time[i]);
if (Otl1 == 1 ) ObjectSet(Ol1,OBJPROP_TIME2, Time[i]);
if (Teik == 1) ObjectSet(Te,OBJPROP_TIME2, Time[i]);
if (Teik == 1) ObjectSet(St,OBJPROP_TIME2, Time[i]);
//+------------------------------------------------------------------+
//| поиск Движухи в 60 пипов
//+------------------------------------------------------------------+
if (NapSd == 1 && High[i] >= MM1Ma) {
// перерисовываем нижний квадрант
MM1Ma = High[i];
MM1 = _BareSize + DoubleToStr(NUN,0); NUN++;
ObjectCreate(MM1, OBJ_RECTANGLE, 0, Time[i], MM1Mi, Time[i-1], MM1Mi+30*Point);
ObjectSet(MM1,OBJPROP_COLOR, Teal);
// рисуем квадрат 0.25 движухи
Otk1 = 1; Otl2 = 0; Rmm1 = 0; Rmm2 = 0; Teik = 0;
Ot1 = _BareSize + DoubleToStr(NUN,0); NUN++;
Res1 = Explic * (MM1Ma - MM1Mi);
Res1 = Res1 * 0.25;
Ot1Ma = MM1Ma; Ot1Mi = Ot1Ma - Res1*Point;
ObjectCreate(Ot1, OBJ_RECTANGLE, 0, Time[i], MM1Ma,Time[i-1], Ot1Mi);
ObjectSet(Ot1,OBJPROP_COLOR, DarkViolet);
NapSd = -1; NapSd1 = 1; // движуха найдена - ищем откатку
}
//+------------------------------------------------------------------+
//| поиск Откатки движухи в 0,25
//+------------------------------------------------------------------+
if (NapSd == 1 && Otk1 == 1 && Low[i] <= Ot1Mi) {
// откатка найдена - выставляем отложенный ордер
Teik = 0; Otk1 = 0; ObjectSet(Ot1,OBJPROP_TIME2, Time[i]);
Otl2 = 1;
Ol2 = _BareSize + DoubleToStr(NUN,0); NUN++;
Ol2Ma = Ot1Ma;
Ol2Mi = Ot1Mi;
ObjectCreate(Ol2, OBJ_RECTANGLE, 0, Time[i], Ol2Ma, Time[i-1], Ol2Mi); ObjectSet(Ol2,OBJPROP_COLOR, LightSeaGreen);
NapSd = -1; NapSd1 = 2; //движуха найдена - выставляем отложенный ордер
}
//+------------------------------------------------------------------+
//| если выставлен отложенный ордер №2
//| то проверяем не ципанула ли его цена Снизу вверх
//| выставляем Тейк и Лосс
//+------------------------------------------------------------------+
if (Otl2 == 1 && High[i] >= Ol2Ma) {
Otl2 = 0;
Teik = 1;
Te = _BareSize + DoubleToStr(NUN,0); NUN++;
TeMa = Ol2Ma; TeMi = Ol2Mi;
ObjectCreate(Te, OBJ_RECTANGLE, 0, Time[i], TeMa, Time[i-1], TeMi);
ObjectSet(Te,OBJPROP_COLOR, Blue);
Res1 = Explic * (TeMa - TeMi);
St = _BareSize + DoubleToStr(NUN,0); NUN++;
StMa = Ol2Ma + Res1*Point; StMi = Ol2Ma;
ObjectCreate(St, OBJ_RECTANGLE, 0, Time[i], StMa, Time[i-1], StMi);
ObjectSet(St,OBJPROP_COLOR, Crimson);
i--; NapSd = -1; NapSd1 = 3; // выставили Настоящий ордер с Тейком и Лоссом
} 
//+------------------------------------------------------------------+
//| если выставлен отложенный ордер №2
//| то проверяем не ципанула ли его цена Сверху вниз
//| выставляем Тейк и Лосс
//+------------------------------------------------------------------+
if (Otl1 == 1 && Low[i] <= Ol1Ma) {
Otl1 = 0; Teik = 1;
Te = _BareSize + DoubleToStr(NUN,0); NUN++;
TeMa = Ol1Ma; TeMi = Ol1Mi;
ObjectCreate(Te, OBJ_RECTANGLE, 0, Time[i], TeMa, Time[i-1], TeMi);
ObjectSet(Te,OBJPROP_COLOR, Blue);
Res1 = Explic * (TeMa - TeMi);
St = _BareSize + DoubleToStr(NUN,0); NUN++;
StMa = Ol1Ma + Res1*Point; StMi = Ol1Ma;
ObjectCreate(St, OBJ_RECTANGLE, 0, Time[i], StMa, Time[i-1], StMi);
ObjectSet(St,OBJPROP_COLOR, Crimson);
i--; NapSd = -1; NapSd1 = 4; // выставили Настоящий ордер с Тейком и Лоссом

}
//+------------------------------------------------------------------+
//| если сработал Тейк
//+------------------------------------------------------------------+
if (Teik == 1 && Low[i] <= TeMi) {
ObjectSet(Te,OBJPROP_TIME2, Time[i-1]);
MM1Im = _BareSize + DoubleToStr(NUN,0); NUN++;
ObjectCreate(MM1Im, OBJ_TEXT, 0, Time[i+1], High[i] + 2*Point);
ObjectSetText(MM1Im, "tp=" ,LabelFontSize, "Arial",Snow);
ObjectSet(MM1Im, OBJPROP_ANGLE,90);
Rmm1 = 0;
Rmm2 = 0;
Otk1 = 0;
Otl1 = 0;
Otl2 = 0;
Teik = 0;
MM1Ma = 0;
MM1Mi = 100;
i--;
i--;
NapSd = -1; NapSd1 = 0;
}
//+------------------------------------------------------------------+
//| если сработал СТОП лосс
//+------------------------------------------------------------------+
if (NapSd == 3 && Teik == 1 && High[i] >= StMa) {
ObjectSet(St,OBJPROP_TIME2, Time[i]);

MM1Im = _BareSize + DoubleToStr(NUN,0); NUN++;
ObjectCreate(MM1Im, OBJ_TEXT, 0, Time[i+1], High[i] + 2*Point);
ObjectSetText(MM1Im, "sL=" ,LabelFontSize, "Arial",Snow);
ObjectSet(MM1Im, OBJPROP_ANGLE,90);

Otl1 = 1;
Ol1 = _BareSize + DoubleToStr(NUN,0); NUN++;
Ol1Ma = Ot1Ma;
Ol1Mi = Ot1Mi;
Rmm1 = 0;
MM1Ma = High[i];
MM2 = _BareSize + DoubleToStr(NUN,0); NUN++;
ObjectCreate(MM2, OBJ_RECTANGLE, 0, Time[i], MM1Mi, Time[i-1], MM1Mi+30*Point); ObjectSet(MM2,OBJPROP_COLOR, Teal);
ObjectCreate(Ol1, OBJ_RECTANGLE, 0, Time[i], Ol1Ma, Time[i-1], Ol1Mi); ObjectSet(Ol1,OBJPROP_COLOR, LightSeaGreen);
// рисуем квадрат 0.25 движухи
Otk1 = 1; Otl2 = 0; Rmm1 = 0; Rmm2 = 1; Teik = 0;
Ot1 = _BareSize + DoubleToStr(NUN,0); NUN++;
Res1 = Explic * (MM1Ma - MM1Mi);
Res1 = Res1 * 0.25;
Ot1Ma = MM1Ma; Ot1Mi = Ot1Ma - Res1*Point;
ObjectCreate(Ot1, OBJ_RECTANGLE, 0, Time[i], MM1Ma,Time[i-1], Ot1Mi);
ObjectSet(Ot1,OBJPROP_COLOR, DarkViolet);
NapSd = -1; NapSd1 = 1;
}
}
//----
return(0);
} 

Here's a sample indicator with coloured squares on the chart showing moves and pullbacks...

you can put any advisor on a tick run, let's say atf 5 or 15 minutes - put a pause there - and put this indicator on the visual chart....

 
Vinin:
I am not the only one who has been broken a lot of times on ZZ. Maybe a different approach is needed, of course. I recently finished pattern recognition (with Kohonen) and decision making. Unfortunately the result is negative. Maybe we should just use a comprehensive approach.

Victor, this is not about zig-zags. Their problems are clear. Let's assume that we set a definition:

A trend is a directional price movement, after which the price necessarily rolls back by 33% (it may be another figure).

How can we find the maximum length of the trend on the symbol chart according to this definition? This is what the script should do.
It is quite possible that RZ can be applied here, I do not argue, but I have not seen such a script yet.

 
DmitriyN:

TheXpert, I suggest you the idea of a research script

It should go through the whole history (all the bars) beginning with Bars() and ending with bar 0. Its purpose is to determine the maximum allowable price strength for a pullback.

The strength is understood as the distance H, which price should pass in any direction (down or up) from the starting price
the pullback F, expressed as a percentage of the height H, must follow this distance:

The purpose of this script is to know the maximum value of the price length of the trend on the history for a given instrument, in order to develop
averaging techniques. Preferably, the script specifies the location (dates) of the trend with the maximum size found.

The initial data for the script is the same - the percentage of price pullback (price drawdown).

Let me remind you that the pullback (in points) is :
- for an uptrend - the difference between the maximum price and the minimum price, which (the minimum) appears after the maximum price;
- for a downtrend (as in the figure above) - the difference between the maximum price value that appears after the minimum price value;
Rollback percentage (in %) - the ratio of the rollback in pips to the size of the trend in pips, multiplied by 100%.

I am currently working on such a script myself, but have not yet figured out how to make the algorithm correctly.


I already did something like that a couple of years ago:

https://www.mql5.com/ru/forum/116407

Actually, the correct approach is to create an EA and optimise the entry/exit levels in the tester. That's how you get the statistics.

 
DmitriyN:

Victor, this isn't about zig-zags. Everything is clear with their problems. Look, let's say that we have a definition:

A trend is a directed price movement followed by the obligatory 33% price pullback (it may be another figure).

How can we find the maximum length of the trend on the symbol chart based on this definition? This is what the script should do.
It may well be possible to apply a FZ here, I don't argue, but I haven't seen such a script yet.


If it's not a gZ, it's up to you to formulate it.

it doesn't take much to draw a picture.

 
DmitriyN:

Victor, this is not about zig-zags. Their problems are clear. Look, let's say that we set ourselves a definition:

A trend is a directed price movement, after which the price necessarily rolls back by 33% (may be another figure).

How can we find the maximum length of the trend on the symbol chart based on this definition? This is what the script should do.
It may well be possible to apply a FZ here, I don't argue, but I haven't seen such a script yet.


There was an indicator that worked in fractions (percentages). It was one of XMA variants, but I will hardly be able to find it. I did not analyse it though.