Hello,
I'm trying to translate the following EasyLanguge code into EFS but it's too difficult for me...
Could anyone please help me do this?
Thanking in advance,
P.S. This code was written by Clyde Lee and it's free.
******
I'm trying to translate the following EasyLanguge code into EFS but it's too difficult for me...
Could anyone please help me do this?
Thanking in advance,
P.S. This code was written by Clyde Lee and it's free.
******
PHP Code:
{ Indicator: Find_Coils
Purpose: A research tool to help define characteristics of "coils" of prices
in an equity or future.
The input parameters are purely for discovery at this time.
A coil might be defined as a series of prices that trade within
a relatively narrow range over a fairly short number of bars (5
to 13) and may or may not require that more than one highs or lows
must have the same or approximately the same value.
Reason: Tim M provided the following in an email in which he identified the
following as something Joe Ross has recommended.
Minimum of five bars, max of eleven bars for this condition: Must have
either two lows that match or two highs that match.
Ranges of the bars should be a contraction of the prior average range.
MaxBars estabilshes the maximum number of bars over which to look for
one or more highs or lows that have the same value plus or minus a
"slop" amount since hitting the exact same prices does not happen as
often as "getting close"
If you want a "loose" coil then set the NumHiLo parameter to a value
of one (1) which does not require any match of more than one high
or low value. Once you have found a good range (HiLoRang) value to
define coils then you can "tighten up" the definition by increasing
the NumHiLo value to 2. When such an increase is made then playing
with the HiLoSlop value may be necessary to get any coils.
Changing ATRBars is not necessary. It may be easier to use the
multiplier of ATR values to set the range. In such a case it is
probably best to set this value initaially to a value of -4 or -3
and then adjust to something near -2 for final results.
}
Inputs: MaxBars(13), {Maximum number of bars to scan for defined characteristics}
NumHiLo(1), {Number of high or low values that must be the same for a }
{pattern to be called a coil. MAXIMUM=3 }
HiLoSlop(.5), {Number of points to allow slop for above matches. }
HiLoRang(-2.5), {Number of points if positive, or a multiplier if negative }
{of the AverageTrueRange on whatever bars you specify. }
ATRBars(21), {Bars for Average True range computation. }
StdDLen(121), {Bars for long term average of StdDev to set level below }
{which current StdDev must be to have zone called a coil }
StdDMul(0.8); {Multiplier to setup limits for coil determination }
Input: LinSize(1.3); {Line size/width and Style -- if line size is set to zero }
{s.t s=size 0->6 t=Style 1->5 (3=dotted) }
Arrays: BarsHi[25](0), BarsLo[25](0), BarsDate[25](0), BarsTime[25](0), BarsNumb[25](0);
Vars: HiBar(0), HiVal(0), LoBar(0), LoVal(0);
Vars: HiBar2(0), HiVal2(0), LoBar2(0), LoVal2(0);
Vars: HiBar3(0), HiVal3(0), LoBar3(0), LoVal3(0);
Vars: StdDVal(StdDev(c,MaxBars)), AvgStdD(Average(StdDVal,StdDLen));
Vars: SizeLin(IntPortion(LinSize)), StylLin(IntPortion(FracPortion(LinSize)*10));
If CurrentBar<MaxBars then begin
Value1=MaxBars-CurrentBar;
BarsHi[Value1]=High;
BarsLo[Value1]=Low;
BarsDate[Value1]=Date;
BarsTime[Value1]=Time;
BarsNumb[Value1]=CurrentBar;
If StylLin<1 then StylLin=1;
End
Else begin
{now have enough data to start looking for whaever!}
Value1=0;
BarsHi[Value1]=High;
BarsLo[Value1]=Low;
BarsDate[Value1]=Date;
BarsTime[Value1]=Time;
BarsNumb[Value1]=CurrentBar;
HiBar=HighestBar(High,MaxBars);
HiVal=High[HiBar];
LoBar=LowestBar (Low, MaxBars);
LoVal=Low[LoBar];
HiBar2=-1;
LoBar2=-1;
HiBar3=-1;
LoBar3=-1;
{Find first match if specified}
If NumHiLo>1 then begin
For Value1=0 to MaxBars-1 begin
If Value1<>HiBar then begin
If High[Value1]>HiVal-HiLoSlop and High[Value1]<=HiVal+HiLoSlop then begin
HiBar2=Value1;
HiVal2=High;
End;
End;
If Value1<>LoBar then begin
If Low[Value1]>LoVal-HiLoSlop and Low[Value1]<=LoVal+HiLoSlop then begin
LoBar2=Value1;
LoVal2=Low;
End;
End;
End;
End;
{Find second match if specified}
If NumHiLo>2 then begin
For Value1=0 to MaxBars-1 begin
If Value1<>HiBar and Value1<>HiBar2 then begin
If High[Value1]>HiVal-HiLoSlop and High[Value1]<=HiVal+HiLoSlop then begin
HiBar3=Value1;
HiVal3=High;
End;
End;
If Value1<>LoBar and Value1<>LoBar2 then begin
If Low[Value1]>LoVal-HiLoSlop and Low[Value1]<=LoVal+HiLoSlop then begin
LoBar3=Value1;
LoVal3=Low;
End;
End;
End;
End;
{See if in defined range}
If HiLoRang<0
then Value2=-HiLoRang*AvgTrueRange(ATRBars)
else Value2=HiLoRang;
StdDVal=StdDev(c,maxbars);
AvgStdD=Average(StdDVal,StdDLen);
If HiVal-LoVal < Value2 and StdDVal<=AvgStdD*StdDMul then begin
If (NumHiLo>2 and (HiBar3>0 or LoBar3>0)) OR (NumHiLo>1 and (HiBar2>0 or LoBar2>0)) OR NumHiLo<2 then begin
Value5=TL_New(Date[MaxBars], Time[MaxBars], HiVal, Date, Time, HiVal);
TL_SetColor(Value5,Tool_Blue);
TL_SetSize(Value5,SizeLin);
TL_SetStyle(Value5,StylLin);
TL_SetExtRight(Value5,False);
TL_SetExtLeft(Value5,False);
Value6=TL_New(Date[MaxBars], Time[MaxBars], LoVal, Date, Time, LoVal);
TL_SetColor(Value6,Tool_Red);
TL_SetSize(Value6,SizeLin);
TL_SetStyle(Value6,StylLin);
TL_SetExtRight(Value6,False);
TL_SetExtLeft(Value6,False);
End;
End;
{Dumb way to do things but just shove the stack}
For Value1=MaxBars downto 1 begin
BarsHi[Value1]=BarsHi[Value1-1];
BarsLo[Value1]=BarsLo[Value1-1];
BarsDate[Value1]=BarsDate[Value1-1];
BarsTime[Value1]=BarsTime[Value1-1];
BarsNumb[Value1]=BarsNumb[Value1-1];
End;
End;
If False then Plot1(0,"0");
Comment