Help me describe a piece of code. I want to tie the Fibonacci levels to the zigzag. The logic is simple, on the correction we enter into sales or purchases. We also look at the last movement of the zigzag. The problem is in the description of the zigzag extremes. The zigzag extreme is formed no more than once every five candles, and in my code everything is somehow crooked!
I ask for help in General who is not difficult to help!
here’s the code: for(int i=5;i<=20;i++)
{
if(Low1>lowM15[i]){Low1=lowM15[i];}
if(highM15[i]-Low1>(highM15[1]-Low1)*0.12){indLow1=i;break;}
}
for(int i=indLow1;i<=indLow1+40;i++)
{
if(High2 if((High2-Low1)*0.12 }
}
if((High2-Low1)*0.39
The pictures show the entry conditions.
ich_hub
I once solved a similar problem for ZigZag:
I think this will help You.
Good luck.
mvs
If you can, please comment on what this code does and how to use it?
-aleks-
Now I’m just working with ZZ, I made a function for vertices.
input int ExtDepth=48;
input int ExtDeviation= 5;
input int ExtBackstep = 3;
int handle_ZZ=0;
double ZigZagVizual []; / / zig-zag visualization
double ZigZagHighs []; / / upper zig-zag fractures
double ZigZagLows []; / / lower zig-zag fractures
double ZZ_High_Price[]; //Maximum price of a segment
datetime ZZ_High_Time[]; //Time of formation of the maximum price of the vertex
double ZZ_Low_Price []; //Minimum price of the segment
datetime ZZ_Low_Time[]; //Time of formation of the minimum price of the vertex
double ZZ_Start_Price[]; //Initial price of the segment
datetime ZZ_Start_Time[]; //Start time of the segment
double ZZ_Stop_Price[]; //Final (current for the last) price of the segment
datetime ZZ_Stop_Time[]; //End time of the segment
int ZZ_Vektor[]; //The direction vector of the line segment
int OnInit()
{
handle_ZZ=iCustom(Symbol(),PERIOD_CURRENT,"ExamplesZigZag_",ExtDepth,ExtDeviation,ExtBackstep);
if(handle_ZZ==INVALID_HANDLE)
{
PrintFormat("Failed to create handle of the handle_ZZ indicator for the symbol %s/%s, error code %d",
Symbol(),EnumToString(Period()),GetLastError());
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
void OnTick()
{
ZZ();
Print ("ZZ_Start_Price=",ZZ_Start_Price[0]," ZZ_Stop_Price=",ZZ_Stop_Price[0]);
Print ("ZZ_Start_Time=",ZZ_Start_Time[0]," ZZ_Stop_Time="+ZZ_Stop_Time[0]);
}
void ZZ()
{
ArrayFree(ZigZagHighs);
ArrayFree(ZigZagLows);
ArrayFree(ZigZagVizual);
// Copy the upper and lower zig-zag fractures to the buffers:
int BarTotal=Bars(Symbol(),PERIOD_CURRENT);
CopyBuffer(handle_ZZ,1,0,BarTotal,ZigZagHighs);
CopyBuffer(handle_ZZ,2,0,BarTotal,ZigZagLows);
// Copy the visualization of zig-zag fractures to the buffers:
CopyBuffer(handle_ZZ,0,0,BarTotal,ZigZagVizual);
// Increase the buffer size to the number of bars
int arrSize=MathMax(ArraySize(ZigZagHighs),ArraySize(ZigZagLows));
ArrayFree(ZZ_High_Price);
ArrayFree(ZZ_High_Time);
ArrayFree(ZZ_Low_Price);
ArrayFree(ZZ_Low_Time);
ArrayResize(ZZ_High_Price,arrSize);
ArrayResize(ZZ_High_Time,arrSize);
ArrayResize(ZZ_Low_Price,arrSize);
ArrayResize(ZZ_Low_Time,arrSize);
//--Remove the spaces between ZZ
int a=0;
int B=0;
double ZZ_High=0.0;
double ZZ_Low=0.0;
for(int i=arrSize-1; i>0; i--)
{
ZZ_High=ZigZagHighs[i];
ZZ_Low=ZigZagLows[i];
if(ZZ_High>0 && ZigZagVizual[i]>0)
{
ZZ_High_Price[A]=ZZ_High;
ZZ_High_Time[A]=iTime(Symbol(),PERIOD_CURRENT,BarTotal-i-1);
A++;
}
if(ZZ_Low>0 && ZigZagVizual[i]>0)
{
ZZ_Low_Price[B]=ZZ_Low;
ZZ_Low_Time[B]=iTime(Symbol(),PERIOD_CURRENT,BarTotal-i-1);
B++;
}
}
//--Find out the maximum number of segments
int arrSizeOtrezok=MathMax(A*2, B*2) +1;
ArrayFree(ZZ_Start_Price);
ArrayFree(ZZ_Start_Time);
ArrayFree(ZZ_Stop_Price);
ArrayFree(ZZ_Stop_Time);
ArrayResize(ZZ_Start_Price,arrSizeOtrezok);
ArrayResize(ZZ_Start_Time,arrSizeOtrezok);
ArrayResize(ZZ_Stop_Price,arrSizeOtrezok);
ArrayResize(ZZ_Stop_Time,arrSizeOtrezok);
ArrayFree(ZZ_Vektor);
ArrayResize(ZZ_Vektor,arrSizeOtrezok);
int VektorLast=0; //--Vector of the last segment
/ / --Define the vector of the last segment
if(ZZ_High_Time[0]>ZZ_Low_Time[>0]) VektorLast=1;
if(ZZ_High_Time[0]0]) VektorLast=-1;
Print(VektorLast);
bool Chetniy=false;
double ChetniyN=0;
for(int i=0; i1; i++)
{
Chetniy=true;
ChetniyN=i;
if(i>0 && NormalizeDouble(ChetniyN/2,0)-ChetniyN/2>0)Chetniy=false;
if(VektorLast==1)
{
if(Chetniy==false)//2
{
int N=(i-1)/2;
ZZ_Start_Price[i-1]=ZZ_Low_Price[N];
ZZ_Start_Time[i-1]=ZZ_Low_Time[N];
ZZ_Stop_Price[i-1]=ZZ_High_Price[N];
ZZ_Stop_Time[i-1]=ZZ_High_Time[N];
ZZ_Vektor[i-1]=1;
ZZ_Start_Price[i]=ZZ_High_Price[N+1];
ZZ_Start_Time[i]=ZZ_High_Time[N+1];
ZZ_Stop_Price[i]=ZZ_Low_Price[N];
ZZ_Stop_Time[i]=ZZ_Low_Time[N];
ZZ_Vektor[i]=-1;
}
}
if(VektorLast==-1)
{
if(Chetniy==false)//2
{
int N=(i-1)/2;
ZZ_Start_Price[i-1]=ZZ_High_Price[N];
ZZ_Start_Time[i-1]=ZZ_High_Time[N];
ZZ_Stop_Price[i-1]=ZZ_Low_Price[N];
ZZ_Stop_Time[i-1]=ZZ_Low_Time[N];
ZZ_Vektor[i-1]=-1;
ZZ_Start_Price[i]=ZZ_Low_Price[N+1];
ZZ_Start_Time[i]=ZZ_Low_Time[N+1];
ZZ_Stop_Price[i]=ZZ_High_Price[N];
ZZ_Stop_Time[i]=ZZ_High_Time[N];
ZZ_Vektor[i]=1;
}
}
}
vitaliy9999999
I agree about the parenthesis. I just tore a piece of code out of the body of the program… I have difficulty in calculating extremmov zigzag that would impose on them levels. the zigzag indicator sets the number of candles in which the indicator cannot draw two vertices. I basically calculated the movement at 12 percent, but how to set the number of candles?
barabashkakvn
vitaliy9999999:
Help me describe a piece of code. I want to tie the Fibonacci levels to the zigzag. The logic is simple, on the correction we enter into sales or purchases. We also look at the last movement of the zigzag. The problem is in the description of the zigzag extremes. The zigzag extreme is formed no more than once every five candles, and in my code everything is somehow crooked!
I ask for help in General who is not difficult to help!
here’s the code: for(int i=5;i<=20;i++)
{
if(Low1>lowM15[i]){Low1=lowM15[i];}
if(highM15[i]-Low1>(highM15[1]-Low1)*0.12){indLow1=i;break;}
}
for(int i=indLow1;i<=indLow1+40;i++)
{
if(High2
if((High2-Low1)*0.12
}
}
if((High2-Low1)*0.39
The pictures show the entry conditions.
1. Insert the code correctly, not as a sheet of text.
2. Always use the stylist in the editor – you will immediately see your mistakes:
for(int i=5;i<=20;i++)
{
if(Low1>lowM15[i])
{
Low1=lowM15[i];
}
if(highM15[i]-Low1>(highM15[1]-Low1)*0.12)
{
indLow1=i;break;
}
}
for(int i=indLow1;i<=indLow1+40;i++)
{
if(High2if((High2-Low1)*0.12break;
}
}
}
if((High2-Low1)*0.391]-Low1)
{
Sell=true;
}
As soon as the code is correct, you can continue to fill it.