The same study, but on generated prices, where increments are formed according to a normal distribution.
Script:
#property show_inputs#define MAX_AMOUNT 250000#define MAX_RAND 32767.0externint BeginPips = 100;
externint EndPips = 1000;
externint StepPips = 10;
externint AmountBars = 100000;
externint Deviation = 15;
int PricesHigh[MAX_AMOUNT], PricesLow[MAX_AMOUNT];
double GetRand()
{
return(2 * MathRand() / MAX_RAND - 1);
}
void GetRandGauss( int Deviation, int& Rand1, int& Rand2 )
{
double X1, X2, W = 2;
while (W >= 1)
{
X1 = GetRand();
X2 = GetRand();
W = X1 * X1 + X2 * X2;
}
W = MathSqrt(-2 * MathLog(W) / W);
Rand1 = X1 * W * Deviation;
Rand2 = X2 * W * Deviation;
if (Rand1 < Rand2)
{
int Tmp = Rand1;
Rand1 = Rand2;
Rand2 = Tmp;
}
return;
}
void GetPrices( int Deviation, int AmountBars )
{
int Pos = 0;
int Rand1, Rand2, Avg = 0;
MathSrand(TimeLocal());
while (Pos < AmountBars)
{
GetRandGauss(Deviation, Rand1, Rand2);
PricesHigh[Pos] = Avg + Rand1;
PricesLow[Pos] = Avg + Rand2;
Avg = (PricesLow[Pos] + PricesHigh[Pos]) / 2;
Pos++;
}
return;
}
int GetZigZagCount( int Pips, int AmountBars )
{
bool FlagUP = TRUE;
int i, Min, Max, Count = 0;
int PriceHigh, PriceLow;
Min = PricesHigh[0];
Max = PricesLow[0];
for (i = 0; i < AmountBars; i++)
{
PriceHigh = PricesHigh[i];
PriceLow = PricesLow[i];
if (FlagUP)
{
if (PriceHigh > Max)
Max = PriceHigh;
elseif (Max - PriceLow >= Pips)
{
FlagUP = FALSE;
Min = PriceLow;
Count++;
}
}
else// (FlagUP == FALSE)
{
if (PriceLow < Min)
Min = PriceLow;
elseif (PriceHigh - Min >= Pips)
{
FlagUP = TRUE;
Max = PriceHigh;
Count++;
}
}
}
return(Count);
}
void start()
{
int Pips, Amount;
int handle;
GetPrices(Deviation, AmountBars);
handle = FileOpen("Analyse.prn", FILE_WRITE);
for (Pips = BeginPips; Pips <= EndPips; Pips += StepPips)
{
Amount = GetZigZagCount(Pips, AmountBars);
FileWrite(handle, Pips + " " + Amount);
}
FileClose(handle);
return;
}
The result is highly dependent on the Deviation parameter (standard deviation).
Same graphs:
The default parameters produce a similar dependence - from the square. But it is completely broken when the Deviation parameter is changed sideways. I checked market prices on majors, the dependence on the square is retained.
Советник считает количество колен ЗигЗага (не менее Pips) и записывает в файл: Запускается в тестере с оптимизацией:
График зависимости количества колен от их мин. размера (Pips):
Графики зависимости отношения вероятностей TP и SL (p(SL) / p(TP)) при отношении TP / SL = Koef от размера SL
On a logarithmic scale, the graph is clearer, by the way. As for the relationship of TP and SL, then it is easier and more unambiguous to arrange a straightforward check in the same tester, making their ratio as a parameter, for example. For some reason it seems to me that for random entries the average total of transactions will always tend to the spread, with a minus sign, of course.
I don't understand what you're counting... The probability of reaching TP and SL? So it's simple... Probability of TP = (SL - spread) / (TP + SL) Probability of SL = (TP + spread) / (TP + SL)
Что касается взаимоотношений TP и SL, то проще и однозначнее в интерпретации устроить лобовую проверку в том же тестере...
As I copied the post from another thread, the old designations remain: TP and SL. It is worth interpreting them as Pips1 and Pips2. The main conclusion is formulated in the Hypothesis.
kharko писал(а)>> I don't understand what you're counting... The probability of reaching TP and SL? So it's simple... Probability of TP = (SL - spread) / (TP + SL) Probability of SL = (TP + spread) / (TP + SL)
Поскольку копировал пост из другой темы, то остались старые обозначения: TP и SL. Стоит их интерпретировать, как Pips1 и Pips2. Основное заключение сформулировано в Гипотезе.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Script:
The result is highly dependent on the Deviation parameter (standard deviation).
Same graphs:
The default parameters produce a similar dependence - from the square. But it is completely broken when the Deviation parameter is changed sideways.
I checked market prices on majors, the dependence on the square is retained.
Повтор:
Советник считает количество колен ЗигЗага (не менее Pips) и записывает в файл:
Запускается в тестере с оптимизацией:
График зависимости количества колен от их мин. размера (Pips):
Графики зависимости отношения вероятностей TP и SL (p(SL) / p(TP)) при отношении TP / SL = Koef от размера SL
On a logarithmic scale, the graph is clearer, by the way. As for the relationship of TP and SL, then it is easier and more unambiguous to arrange a straightforward check in the same tester, making their ratio as a parameter, for example. For some reason it seems to me that for random entries the average total of transactions will always tend to the spread, with a minus sign, of course.
В логарифмическом масштабе график нагляднее, кстати, будет.
So it's simple...
Probability of TP = (SL - spread) / (TP + SL)
Probability of SL = (TP + spread) / (TP + SL)
Что касается взаимоотношений TP и SL, то проще и однозначнее в интерпретации устроить лобовую проверку в том же тестере...
As I copied the post from another thread, the old designations remain: TP and SL. It is worth interpreting them as Pips1 and Pips2. The main conclusion is formulated in the Hypothesis.
I don't understand what you're counting... The probability of reaching TP and SL?
So it's simple...
Probability of TP = (SL - spread) / (TP + SL)
Probability of SL = (TP + spread) / (TP + SL)
Let's check - TP = 20, SL = 20 => P(TP)=(SL-2)/(20+20)= 18/40 = 0.45, P(SL)=(TP+2)/(TP+SL) =(20+2)/(20+20)=22/40 = 0.55So they are not equal :))))
Поскольку копировал пост из другой темы, то остались старые обозначения: TP и SL. Стоит их интерпретировать, как Pips1 и Pips2. Основное заключение сформулировано в Гипотезе.
Corrected the post to the correct interpretation.
Проверим - TP = 20, SL = 20 => P(TP)=(SL-2)/(20+20) = 18/40 = 0.45, P(SL)=(TP+2)/(TP+SL) =(20+2)/(20+20)=22/40 = 0.55То есть не равны :))))
When you open a position, you are already at a loss by the amount of the spread....
When you open a position, you are already at a loss by the value of the spread....
What does probability have to do with it?
А вероятность тут причем?The probability is 0.5 if the distances the price has to travel are equal. SL-spread=TP+spread