NexusFi: Find Your Edge


Home Menu

 





Williams Fractals for TradeStation


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one SunTrader with 2 posts (3 thanks)
    2. looks_two TraderDoc2 with 1 posts (1 thanks)
    3. looks_3 QCDragon with 1 posts (1 thanks)
    4. looks_4 lrc11239 with 1 posts (0 thanks)
      Best Posters
    1. looks_one dlaz758 with 4 thanks per post
    2. looks_two SunTrader with 1.5 thanks per post
    3. looks_3 ABCTG with 1 thanks per post
    4. looks_4 TraderDoc2 with 1 thanks per post
    1. trending_up 4,509 views
    2. thumb_up 10 thanks given
    3. group 7 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Williams Fractals for TradeStation

  #1 (permalink)
lrc11239
Brooklyn NY USA
 
Posts: 27 since Jul 2019
Thanks Given: 2
Thanks Received: 0

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!!


#wizard plots
#wizard text: Inputs: sequence count:
#wizard input: sequenceCount

input sequenceCount = 2;

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;

UpFractal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
UpFractal.SetDefaultColor(GetColor(3));
UpFractal.SetLineWeight(2);
DownFractal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
DownFractal.SetDefaultColor(GetColor(4));
DownFractal.SetLineWeight(2);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
How to apply profiles
Traders Hideout
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

lrc11239,

welcome to futures.io. You might be able to find an indicator that does what you want in the official Tradestation forum. For example this one might work for you: https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=60258

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 34 since Mar 2012
Thanks Given: 1
Thanks Received: 21


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):
 
Code
Input:
		MyStrength(2);

If SwingLow(1,L,MyStrength,MyStrength + 1) <> -1 {and L[2] <> L[4]} then begin
	 CommentaryCL("Action Bar");
	 If Low[MyStrength] < Low[MyStrength + 1] then begin
	 	PlotPB[MyStrength](0.5*(H+L)[MyStrength],(SwingLow(1,L,MyStrength,MyStrength + 1)),"FrctlL");
	 	If AlertEnabled then Alert("Fractal Low Formed " + GetSymbolName);
	 	end
	 	Else 
	 	begin
	 		PlotPB[MyStrength + 1]((SwingLow(1,L,MyStrength,MyStrength + 2)),(H[MyStrength + 1]+L[MyStrength + 1])/2,"FrctlL");
	 	 	If AlertEnabled then Alert("Fractal Low Formed " + GetSymbolName);
	 	end;
end
Else
	Begin
		NoPlot(1);
		NoPlot(2);
	End;
For Highs:
 
Code

Input:
		MyStrength(2);
If SwingHigh(1,H,MyStrength,MyStrength + 1) <> -1 {and H[2] <> H[4]} then begin
	 CommentaryCL("Action Bar");
	 If High[MyStrength] > High[MyStrength + 1] then begin
	 	PlotPB[MyStrength]((SwingHigh(1,H,MyStrength,MyStrength + 1)),(H[MyStrength]+L[MyStrength])/2,"FrctlH");
	 	If AlertEnabled then Alert("Fractal High Formed " + GetSymbolName);
	 	end
	 	Else 
	 	begin
	 	 	PlotPB[MyStrength + 1]((SwingHigh(1,H,MyStrength,MyStrength + 2)),(H[MyStrength + 1]+L[MyStrength + 1])/2,"FrctlH");
	 	 	If AlertEnabled then Alert("Fractal High Formed " + GetSymbolName);
	 	end;	 
end
Else
	Begin
		NoPlot(1);
		NoPlot(2);
	End;

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 
QCDragon's Avatar
 QCDragon 
Columbus, OH USA
 
Experience: Intermediate
Platform: Jigsaw Tradr+MultiCharts
Trading: eMini ES
Posts: 3 since Feb 2016
Thanks Given: 1
Thanks Received: 2

 
Code
[LegacyColorValue = TRUE];

{  ---------------------------------------------------------------------  
   --   SHOW: FRACTAL-SQUATS Study                                    --  
   --                                                                 --  
   --   Developed by Bill Williams                                    --  
   --   Easy Language Programing by:  Bill Williams                  --  
   --
   --   Copyright by Bill Williams - Profitunity Trading Group        --  
   ---------------------------------------------------------------------  
  See Profitunity Manual for information on how to apply this STUDY.

  These FRACTAL formation will be identified by this logic:            
                      Rising Markets:

        | |         |        |||       ||      ||||      |||||
       | | |       | |      |   |     |  |    |    |    |     |
      |     |     |   |    |     |   |    |  |      |  |       |
 ___________________________________________________________________
   
      |     |     |   |    |     |   |    |  |      |  |       |
       | | |       | |      |   |     |  |    |    |    |     |
        | |         |        |||       ||      ||||      |||||
                
                      Declining Markets:
   Additional formations can be added by placing the appropriate code in the       User functions:  
           UpFractal 
           DownFractal

   and by adding the logic in this study for determining where to place the    Fractal/Squat identifier.
   NOTE:   Documentation was limited by File Size Restrictions.}

INPUT: PtsInTic(1), TicExpnd(1);
VAR :  UpHump(FALSE), DownHump(FALSE), Expansion(0), Move(0);

UpHump = UpFractal = 1;

DownHump = DownFractal = 1;

IF TicExpnd >= MinimumMove THEN
   Move = TicExpnd
 ELSE
   Move = MinimumMove;

Expansion = Move * PtsInTic;

IF UpHump THEN
	BEGIN
		IF H[2] >= H[3] AND H[2] > H[4] THEN Plot1[2](HIGH[2] + Expansion Points,"UpHump");
		IF H[2] = H[3] AND H[3] = H[4] THEN Plot1[2](HIGH[2] + Expansion Points,"UpHump");
		IF H[2] > H[3] AND H[2] = H[4] THEN Plot1[2](HIGH[2] + Expansion Points,"UpHump");
		IF H[2] = H[3] AND H[3] = H[4] AND H[4] = H[5] THEN Plot1[2](HIGH[2] + Expansion Points,"UpHump");        
		IF H[2] = H[3] AND H[3] = H[4] AND H[4] = H[5] AND H[5] = H[6] THEN Plot1[2](HIGH[2] + Expansion Points,"UpHump"); 
	END;

IF DownHump THEN
	BEGIN
		IF L[2] <= L[3] AND L[2] < L[4] THEN Plot2[2](LOW[2] - Expansion Points,"DwnHump");
		IF L[2] = L[3] AND L[3] = L[4] THEN Plot2[2](LOW[2] - Expansion Points,"DwnHump");
		IF L[2] < L[3] AND L[2] = L[4] THEN Plot2[2](LOW[2] - Expansion Points,"DwnHump");
		IF L[2] = L[3] AND L[3] = L[4] AND L[4] = L[5] THEN Plot2[2](LOW[2] - Expansion Points,"DwnHump");
		IF L[2] = L[3] AND L[3] = L[4] AND L[4] = L[5] AND L[5] = L[6] THEN Plot2[2](LOW[2] - Expansion Points,"DwnHump");
       END;
The following is a NEWER version, but there are LESS examples:

 
Code
{ 
  *******************************
 *********************************
***                             *** 
***  FRACTAL PATTERNS           ***
***  PROFITUNITY TRADING GROUP  ***
***                             *** 
 *********************************
  *******************************
}

{ STEP 1: Replace <CRITERIA> with the logical criteria that will trigger the placement 
  of a ShowMe marker on the chart, such as Close > Close[1].  Note that Condition1 is a 
  logical variable, a temporary holding place for the true-false result of your 
  criteria. }

Condition1 = H[2] > H[3] and H[2] > H[4] and H[2] > H[1] and H[2] > H;
Condition2 = L[2] < L[3] and L[2] < L[4] and L[2] < L[1] and L[2] < L;

{ OPTIONAL STEP: Replace CLOSE with your own formula for the price at which the marker 
  will be placed.  Note that Value1 is a numeric variable, a temporary holding place 
  for the result of the numeric formula. }

Value1 = H[2] ;
Value2 = L[2];

{ Leave the following as is.  The plot is not named because there is only one plot, and 
  the default name Plot1 will be adequate.  The alert does not include a description 
  because the alerting criteria and the plotting criteria are the same, and the 
  description will be redundant. }

if Condition1 then 	Plot1[2]( Value1, "Fractal H", Green) ;
If Condition2 then  Plot2[2]( Value2, "Fractal L", Red);

Reply With Quote
Thanked by:
  #5 (permalink)
dlaz758
Phoenix Arizona
 
Posts: 1 since Jul 2019
Thanks Given: 0
Thanks Received: 1

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."];

variables:
Vector VectorOfHighs( NULL ),
Vector VectorOfLows( NULL ),
intrabarpersist int MinHighBarsNeeded( 0 ),
intrabarpersist int MinLowBarsNeeded( 0 ),
intrabarpersist double LastFractalHighPrice( -1 ),
intrabarpersist double LastFractalLowPrice( -1 ),
intrabarpersist int NumberOfDecimals( 2 ),
bool FractHighFound( false ),
bool FractLowFound( false ),
intrabarpersist double HighOffset( 0 ),
intrabarpersist double LowOffset( 0 );

{ 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." ) );

HighOffset = FractalHighOffsetTicks * MinMove / PriceScale;
LowOffset = FractalLowOffsetTicks * MinMove / PriceScale;

MinHighBarsNeeded = HighStrength * 2 + 1;
MinLowBarsNeeded = LowStrength * 2 + 1;
NumberOfDecimals = NumDecimals( PriceScale );

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}

VectorOfHighs.Insert( 0, High astype double );
VectorOfLows.Insert( 0, Low astype double );

FractHighFound = FractalHighFound();
FractLowFound = FractalLowFound();

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;


{ ** Copyright © TradeStation Technologies, Inc. All Rights Reserved **
** TradeStation reserves the right to modify or overwrite this analysis technique
with each release. ** }

Reply With Quote
Thanked by:
  #6 (permalink)
SunTrader
Boca Raton, FL
 
Posts: 260 since Nov 2018
Thanks Given: 81
Thanks Received: 182

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.

Reply With Quote
Thanked by:
  #7 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853


SunTrader View Post
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.

~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
SunTrader
Boca Raton, FL
 
Posts: 260 since Nov 2018
Thanks Given: 81
Thanks Received: 182


vmodus View Post
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.

~vmodus

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.

Reply With Quote
Thanked by:




Last Updated on June 4, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts