Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hello all, I'm new to TradeStation and this forum. Thank you for so much information. I've been trying to find the Williams Fractal plots for Tradestation. I'm currently using Thinkorswim and have them there but I'm switching my day trading platform to Tradestation and I'm not sure if they have the Fractals I'm using. I've tried to call the Tech department and they really don't know if the platform has them. Does anyone know if Tradestation has the Williams Fractal plots? I've also included the ThinkScript codes if anyone is able to convert to EasyLanguage would be much appreciated. Many thanks as always!!
def maxSideLength = sequenceCount + 10;
def upRightSide = fold i1 = 1 to maxSideLength + 1 with count1 while count1 != sequenceCount and count1 != -1 do
if GetValue(high, -i1, -maxSideLength) > high or (GetValue(high, -i1, -maxSideLength) == high and count1 == 0) then -1
else if GetValue(high, -i1, -maxSideLength) < high then count1 + 1 else count1;
def upLeftSide = fold i2 = 1 to maxSideLength + 1 with count2 while count2 != sequenceCount and count2 != -1 do
if GetValue(high, i2, maxSideLength) > high or (GetValue(high, i2, maxSideLength) == high and count2 >= 1) then -1
else if GetValue(high, i2, maxSideLength) < high then count2 + 1 else count2;
def downRightSide = fold i3 = 1 to maxSideLength + 1 with count3 while count3 != sequenceCount and count3 != -1 do
if GetValue(low, -i3, -maxSideLength) < low or (GetValue(low, -i3, -maxSideLength) == low and count3 == 0) then -1
else if GetValue(high, -i3, -maxSideLength) > low then count3 + 1 else count3;
def downLeftSide = fold i4 = 1 to maxSideLength + 1 with count4 while count4 != sequenceCount and count4 != -1 do
if GetValue(low, i4, maxSideLength) < low or (GetValue(low, i4, maxSideLength) == low and count4 >= 1) then -1
else if GetValue(low, i4, maxSideLength) > low then count4 + 1 else count4;
plot UpFractal = if upRightSide == sequenceCount and upLeftSide == sequenceCount then high else Double.NaN;
plot DownFractal = if downRightSide == sequenceCount and downLeftSide == sequenceCount then low else Double.NaN;
I find that this code works pretty well [not sure it's exactly the same, but it's pretty close]
For Lows (I plot PaintBars with slightly thick plots in the lower half of the bar, so this is paintbar study code; it works best on bars rather than candles):
Hello, Also new to the forum. I am using Tradestation 9.5 Update 28 and it has the Williams Fractal, it is a "Show Me", so you have to click over 1 tab to the right when you go to add an indicator and select the ShowMe options.
Or perhaps I some how picked this up along the way from someone. Anyway here is the code.
{ Search Tag: WA-Fractals }
{ Reference: Bill Williams, PhD, "New Trading Dimensions" (John Wiley & Sons, Inc.,
1998) }
{
This study works in Charting only.
High and Low fractals are identified per Chapter 4 (see reference above). A
minimum of 5 bars are required to identify the pattern.
For a High fractal, the fractal bar must have 2 bars on the right and 2 bars on
the left that have lower Highs. For the bars to the left, a bar that has the same
High cannot be counted as one of the 2 'lower' bars. For the bars to the right of
the fractal bar, you can't have a bar with a High that equals the high of the
fractal bar, which invalidates the pattern. This can be seen in the examples
found in Figure 4-4 (see reference above).
Low fractals are similar, but use Low prices.
}
using elsystem;
using elsystem.collections;
inputs:
int HighStrength( 2 )[DisplayName = "HighStrength", ToolTip =
"Enter the number of bars required to identify a fractal high."],
int LowStrength( 2 )[DisplayName = "LowStrength", ToolTip =
"Enter the number of bars required to identify a fractal low."],
int ShowFractalHighs( 1 ) [DisplayName = "ShowFractalHighs", ToolTip =
"Enter 1 to mark the fractal highs. Enter any other value to prevent marking of the fractal highs."],
int FractalHighOffsetTicks( 1 ) [DisplayName = "FractalHighOffsetTicks", ToolTip =
"Set to the number of ticks that the marker will be offset above the fractal high price."],
int ShowFractalLows( 1 ) [DisplayName = "ShowFractalLows", ToolTip =
"Enter 1 to mark the fractal lows. Enter any other value to prevent marking of the fractal lows."],
int FractalLowOffsetTicks( 1 ) [DisplayName = "FractalLowOffsetTicks", ToolTip =
"Set to the number of ticks that the marker will be offset below the fractal low price."];
{ search for Fractal 'high' pattern }
method bool FractalHighFound()
variables:
int Counter,
bool HighFound,
bool OkToContinue,
double RefHigh,
int NumLowerHighsFound;
begin
HighFound = false; { initialize }
OkToContinue = true; { initialize }
if VectorOfHighs.Count >= MinHighBarsNeeded then { ensure bars are available }
begin
RefHigh = VectorOfHighs[HighStrength] astype double;
{ the High of 'Strength' bars ago must be higher than the current bar and
all of the other subsequent bars after 'Strength' bars ago }
for Counter = 0 to HighStrength - 1
begin
if VectorOfHighs[Counter] astype double >= RefHigh then
begin
OkToContinue = false;
break;
end;
end;
{ check the bars to the left of the reference bar for 'Strength' lower
highs than the RefHigh (without exceeding the RefHigh) }
if OkToContinue then { first condition was met }
begin
for Counter = HighStrength + 1 to VectorOfHighs.Count - 1
begin
if VectorOfHighs[Counter] astype double < RefHigh then
begin
NumLowerHighsFound += 1;
if NumLowerHighsFound = HighStrength then
begin
HighFound = true;
LastFractalHighPrice = RefHigh;
break;
end;
end
else if VectorOfHighs[Counter] astype double > RefHigh then
begin
break;
end;
end;
end;
end;
return HighFound;
end;
{ search for Fractal 'low' pattern }
method bool FractalLowFound()
variables:
int Counter,
bool LowFound,
bool OkToContinue,
double RefLow,
int NumHigherLowsFound;
begin
LowFound = false; { initialize }
OkToContinue = true; { initialize }
if VectorOfLows.Count >= MinLowBarsNeeded then { ensure bars are available }
begin
RefLow = VectorOfLows[LowStrength] astype double;
{ the Low of 'Strength' bars ago must be lower than the current bar and
all of the other subsequent bars after 'Strength' bars ago }
for Counter = 0 to LowStrength - 1
begin
if VectorOfLows[Counter] astype double <= RefLow then
begin
OkToContinue = false;
break;
end;
end;
{ check the bars to the left of the reference bar for 'Strength' higher
lows than the RefLow (without exceeding the RefLow }
if OkToContinue then { first condition was met }
begin
for Counter = LowStrength + 1 to VectorOfLows.Count - 1
begin
if VectorOfLows[Counter] astype double > RefLow then
begin
NumHigherLowsFound += 1;
if NumHigherLowsFound = LowStrength then
begin
LowFound = true;
LastFractalLowPrice = RefLow;
break;
end;
end
else if VectorOfLows[Counter] astype double < RefLow then
begin
break;
end;
end;
end;
end;
return LowFound;
end;
{ initialization and error checking of input values }
once
begin
if ShowFractalHighs <> 1
and ShowFractalLows <> 1 then
begin
throw Exception.Create( !( "Both fractal highs and fractal lows are set to not show." ) );
end;
if HighStrength < 2 then
throw Exception.Create( !( "HighStrength input must be at least 2." ) );
if LowStrength < 2 then
throw Exception.Create( !( "LowStrength input must be at least 2." ) );
VectorOfHighs = new Vector();
VectorOfLows = new Vector();
end;
{ the confirmation and marking of a fractal/pivot can only be determined at
the close of the bar; note that the "DataNum" property of the AnalysisTechnique
class starts at zero for Data1 so it must be incremented by 1 to correspond to
the data stream to be used with BarStatus}
if BarStatus( DataNum + 1 ) = 2 then
begin
{on each bar load the bar High and Low into respective vector; Vectors are used
so that the pattern recognition code can 'loop back' through prices (in the
Vectors) without affecting MaxBarsBack}
if FractHighFound and ShowFractalHighs = 1 then
Plot1[HighStrength]( High[HighStrength] + HighOffset, !( "FractHigh" ) );
if FractLowFound and ShowFractalLows = 1 then
Plot2[LowStrength]( Low[LowStrength] - LowOffset, !( "FractLow" ) );
{ alerts }
if AlertEnabled then
begin
if FractHighFound then
Alert( !( "Fractal high found at: " ) + NumToStr( LastFractalHighPrice,
NumberOfDecimals ) );
if FractLowFound then
Alert( !( "Fractal low found at: " ) + NumToStr( LastFractalLowPrice,
NumberOfDecimals ) );
end;
end;
Just thought I'd mention for those who are not aware that fractals, what some call hi/lo pivots or swing pivots, TD Points etc, need a certain number of bars (5 in this case) to print before a fractal can be determined to have taken place. In the past. In other words not confirmed until after the fact/lagging current price action.
They still have value as long as this is characteristic is plainly understood from the start.
I am coming into this discussion late, but I figured I would add since I am knee deep in fractal calculations right now.
To clarify even further, a minimum of 5 bars is needed to set a fractal (sometimes more bars.... refer to Bill Williams' books Trading Chaos 1st and 2nd ed.), but the fractal is painted on the second bar back after the last bar closes and the fractal is confirmed. So the fractal is shown three bars ago, but it is not really late as SunTrader pointed out.
Yes 5 bars for a fractal. But for other similar type swing points as I said - hi/lo or swing pivots or TD points it can vary - based on what strength/granularity is applied.