Hi All,
I have been looking for a good and simple trend code for entry that would see trend just as I would see it if I was looking at the chart.
I have put my idea that is coded below and when I manually sit and try it on the charts it seems excellent and the trend updates continually unless there was a fractal in the last 30 minutes that it uses instead.
If someone would put this in an indicator to draw lines to check it, great. Else it might be useful for someone as is, in an EA
This is how it works.. take last two fractals that are both above or below the bollenger band and find the delta. Take that point and draw a line to the bollenger band upper or lower (must be on the same side as the two fractals) and that is the trend.
Any suggestions on code improvement would be very welcome. I am no great coder.. so there may be a lot better way to do it.
cheers
A
I have been looking for a good and simple trend code for entry that would see trend just as I would see it if I was looking at the chart.
I have put my idea that is coded below and when I manually sit and try it on the charts it seems excellent and the trend updates continually unless there was a fractal in the last 30 minutes that it uses instead.
If someone would put this in an indicator to draw lines to check it, great. Else it might be useful for someone as is, in an EA
This is how it works.. take last two fractals that are both above or below the bollenger band and find the delta. Take that point and draw a line to the bollenger band upper or lower (must be on the same side as the two fractals) and that is the trend.
Inserted Code
double BuyLine = iBands(NULL,15,20,2,0,PRICE_LOW,MODE_LOWER,0); double SellLine = iBands(NULL,15,20,2,0,PRICE_LOW,MODE_UPPER,0); //Define Trend int Trend; static int HighFractalTime, LowFractalTime; static double FirstHighFractal, LastHighFractal, HighFractal,FirstLowFractal, LowFractal, LastLowFractal; if (iFractals (NULL,15, MODE_UPPER, 0) >= SellLine) // Only count fractal greater than upper bollenger band {FirstHighFractal = LastHighFractal; LastHighFractal=HighFractal; HighFractal= iFractals (NULL,15, MODE_UPPER, 0); HighFractalTime=Time[0];} if (iFractals (NULL,15, MODE_LOWER, 0) <= BuyLine) // Only count fractal lower than lower bollenger band {FirstLowFractal= LastLowFractal; LastLowFractal=LowFractal; LowFractal= iFractals (NULL,15, MODE_LOWER, 0); LowFractalTime=Time[0];} if (HighFractalTime < LowFractalTime) // Last fractal was Low { if (( TimeCurrent() - LowFractalTime )/60 > 30) { if((LastLowFractal+LowFractal)/2 > BuyLine + 200*Point) Trend=1; //Trend is Down if((LastLowFractal+LowFractal)/2 < BuyLine - 200* Point) Trend=2; //Trend is Up if (Trend != (1||2))Trend=3; //Trend is Ranging } if (( TimeCurrent() - HighFractalTime )/60 <= 30) { if((FirstLowFractal+LastLowFractal)/2 > LowFractal + 200 * Point) Trend=1; //Trend is Down if((FirstLowFractal+LastLowFractal)/2 < LowFractal - 200 * Point) Trend=2; //Trend is Up if (Trend != (1||2))Trend=3;//Trend is Ranging }} if (HighFractalTime > LowFractalTime)// Last fractal was High { if (( TimeCurrent() - HighFractalTime )/60 > 30) { if((LastHighFractal+HighFractal)/2 > SellLine + 200*Point) Trend=1; //Trend is Down if((LastHighFractal+HighFractal)/2 < SellLine - 200* Point) Trend=2; //Trend is Up if (Trend != (1||2))Trend=3; //Trend is Ranging } if (( TimeCurrent() - HighFractalTime )/60 <= 30) { if((FirstHighFractal+LastHighFractal)/2 > HighFractal + 200 * Point) Trend=1; //Trend is Down if((FirstHighFractal+LastHighFractal)/2 < HighFractal- 200 * Point) Trend=2; //Trend is Up if (Trend != (1||2))Trend=3;//Trend is Ranging }}
cheers
A