Jump to content

Req: Weis Wave For Tradestation


sherif

Recommended Posts

  • 11 months later...
  • 2 weeks later...
  • 6 months later...
I am about to install Tradestation and was also looking for the Weis Wave, does it work or not?

 

Have you found other similar, a zig zag volume or wave volume?

 

This work with MC Easylanguage so it should work with TS. It's essentially the same as Weis Wave.

 

{MRA - ZigZag Volume indicator by Menno Adema

Version 1.00 (08/09/2013)		Initial release.
Version 1.10 (10/25/2013)		Bug negative time duration when a swing spans multiple days fixed.
Version 1.11 (11/02/2013)		Correction on bug fix version 1.10.

This indicator is inspired on the Weis Wave with its cumulative wave volume. It plots a cumulative 
ZigZag volume histogram, a ZigZag line and the cumulative volume, price change and/or duration of 
the up/down swing at the swing high/low.

The ZigZag line can be based on point, percentage, ATR or UTC retracements.
The UTC retracement method is based on John R. Hill, George Pruitt, and Lundy Hill's description 
in their book The Ultimate Trading Guide, page 39: "A top pivot point is the highest price in a 
movement prior to penetration of the low of the top bar. A bottom pivot point is the lowest price 
in a movement prior to penetration of the high of the low bar." 
The UTC version is an improved version in which the highs and lows are calculated over a period. 
Longer periods make the ZigZag UTC less sensitive. The default period for the UTC is 2 bars.}


Inputs:
Offset (0.2),
Font_Size(10),
HiPrice( close ),		// price field for high swings
LoPrice( close ),		// price field for low swings
RetraceMethod( 1 ),		// 1=Pnt, 2=%, 3=ATR, 4=UTC
Period( 2 ),			// number of bars over which ATR or UTC is calculated
Retrace( 0 ),			// retracement in Pnt, % or ATR multiple
PlotVolume( true ),		// plots cumulative volume histogram
PlotSwings( true ),		// plots ZigZag lines
PlotVolumeText( true ),	// plots cumulative volume of up/down swing at swing high/low
ScaleVolumeBy( 1 ),		// divides cumulative volume text by the number of this input
PlotPriceText( false ),	// plots price change of up/down swing at swing high/low
PlotTimeText( false ),	// plots duration of up/down swing at swing high/low
LineWidth( 0 ),		// line width of ZigZag lines: 0,1,2,3,4,5,6
LineStyle( tool_solid),	// line style of ZigZag lines: tool_solid, tool_dotted, tool_dashed, tool_dashed2, tool_dashed3 
UpColor( red ),		// line color of upswings: PowerLanguage colors
DnColor( red ),		// line color of downswings: PowerLanguage colors
TextColor( black );		// text color: PowerLanguage colors

Vars:
dailyTF( false ),
dir( 0 ),
hi( HiPrice ),
lo( LoPrice ),
lastLoBar( 1 ),
lastHiBar( 1 ),
lastHi( HiPrice ),
lastLo( LoPrice ),
swingHiCondition( false ),
swingLoCondition( false ),
vol( 0 ),
volUp( 0 ),
volDn( 0 ),
barsBack( 0 ),
x( 0 ),
tl( 0 ),
plotText( "" ),
waveTxt( 0 );

// Initialize variables
dailyTF = BarType >= 2 and BarType < 5;
hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );
lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );
vol = iff( dailyTF, Volume, Ticks );

// set initial trend direction (dir will become non-zero after the first couple of bars)
if dir = 0 then
begin
if hi[0] > lastHi then // higher high
begin
	lastHi = hi[0];
	lastHiBar = CurrentBar;
	if lo[0] > lo[1] then // higher low
		dir = 1; // initial trend direction is up
end;
if lo[0] < lastLo then // lower low
begin
	lastLo = lo[0];
	lastLoBar = CurrentBar;
	if hi[0] < hi[1] then // lower high
		dir = -1; // initial trend direction is down
      end;
end;

// look for swing points and draw lines

if dir > 0 then // trend is up, look for new swing high
begin
if RetraceMethod = 1 then swingHiCondition = lo[0] < lastHi - Retrace; // condition for swing high pnt
if RetraceMethod = 2 then swingHiCondition = lo[0] < lastHi * (1 - Retrace * 0.01 ); // condition for swing high %
if RetraceMethod = 3 then swingHiCondition = lo[0] < lastHi - ( Retrace * AvgTrueRange( Period ) ); // condition for swing high ATR
if RetraceMethod = 4 then swingHiCondition = hi[0] < lastHi and lo[0] < lo[1]; // condition for swing high UTC

if not swingHiCondition then
begin
	if hi[0] > lastHi then // found a higher high
	begin
		lastHi = hi[0];
		lastHiBar = CurrentBar;
	end;
	// update cumulative volume of upswing
	volUp = 0;
	barsBack = ( CurrentBar - lastLoBar - 1 );
	for x = barsBack downto 0
	begin
		volUp = volUp + vol[x];
		if PlotVolume then
		begin
			NoPlot[x]( 2 );
			Plot1[x]( VolUp, "Volume Up" );
		end;
	end;
	// update current upswing line and text from lastLoBar
	if PlotSwings then
		TL_SetEnd_Dt( tl, datetime[0], lastHi );
	plotText = 
		iffString( PlotTimeText, iffString( dailyTF, NumToStr( CurrentBar - lastLoBar, 0 ) + " bar(s)",
			DateTimeToHMS( ( ELDateToDateTime( Date[0] ) - ELDateToDateTime( Date[CurrentBar - lastLoBar] ) ) +
			ELTimeToDateTime_s( Time_s[0] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) ) ), "" ) +
		iffString( PlotVolumeText, NewLine + NumToSTr( volUp + Offset / ScaleVolumeBy, 0 ), "" ) + 
		iffString( PlotPriceText, NewLine + "+" + NumToSTr( ( lastHi - lastLo ) * PriceScale, 0 ), "" );
	Text_SetLocation_Dt( waveTxt, datetime[0], High[0] + Offset );
	Text_SetString( waveTxt, plotText );
end
else if swingHiCondition then // found a swing high
begin
	// update cumulative volume of upswing
	volUp = 0;
	barsBack = ( CurrentBar - lastLoBar - 1 );
	for x = barsBack downto ( CurrentBar - lastHiBar )
	begin
		volUp = volUp + vol[x];
		if PlotVolume then
		begin
			NoPlot[x]( 2 );
			Plot1[x]( VolUp, "Volume Up" );
		end;
	end;
	// update current upswing line from lastLoBar
	if PlotSwings then
		TL_SetEnd_Dt( tl, datetime[CurrentBar - lastHiBar], lastHi );
	plotText = 
		iffString( PlotTimeText, iffString( dailyTF, NumToStr( lastHiBar - lastLoBar, 0 ) + " bar(s)",
			DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastHiBar] ) - ELDateToDateTime( Date[CurrentBar - lastLoBar] ) ) +
			ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) ) ), "" ) +
		iffString( PlotVolumeText, NewLine + NumToSTr( volUp / ScaleVolumeBy, 0 ), "" ) + 
		iffString( PlotPriceText, NewLine + "+" + NumToSTr( ( lastHi - lastLo ) * PriceScale, 0 ), "" );
	Text_SetLocation_Dt( waveTxt, datetime[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar] + Offset );
	Text_SetString( waveTxt, plotText );

	dir = -1; // trend direction is now down
	lastLo = lo[0];
	lastLoBar = CurrentBar; // now seeking new lows
	volDn = 0;
	barsBack = ( CurrentBar - lastHiBar - 1 );
	for x = barsBack downto 0
	begin
		volDn = volDn + vol[x];
		if PlotVolume then
		begin
			NoPlot[x]( 1 );
			Plot2[x]( VolDn, "Volume Down" );
		end;
	end;

	if PlotSwings then // start new trendline from new swing high to most recent low
	begin
		tl = TL_New_Dt( datetime[CurrentBar - lastHiBar], lastHi, datetime[CurrentBar - lastLoBar], lastLo );
		TL_SetExtLeft( tl, false );
		TL_SetExtRight( tl, false );
		TL_SetSize( tl, LineWidth );
		TL_SetStyle( tl, LineStyle );
		TL_SetColor( tl, DnColor );
	end;
	plotText = 
		iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ), "" ) + 
		iffString( PlotVolumeText, NewLine + NumToSTr( volDn / ScaleVolumeBy, 0 ), "" ) +
		iffString( PlotTimeText, NewLine + iffString( dailyTF, NumToStr( lastLoBar - lastHiBar, 0 ) + " bar(s)",
			DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastLoBar] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
			ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );
	waveTxt = Text_New_Dt( datetime[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar], plotText );
	Text_SetStyle( waveTxt, 2, 0 );
	Text_SetSize( waveTxt, Font_Size );
	Text_SetColor( waveTxt, TextColor );
end;
end 
else
begin // dir < 0, trend is down, look for new swing low
if RetraceMethod = 1 then swingLoCondition = hi[0] > lastLo + Retrace; // condition for swing low pnt
if RetraceMethod = 2 then swingLoCondition = hi[0] > lastLo * (1 + Retrace * 0.01 ); // condition for swing low %
if RetraceMethod = 3 then swingLoCondition = hi[0] > lastLo + ( Retrace * AvgTrueRange( Period ) ); // condition for swing low ATR
if RetraceMethod = 4 then swingLoCondition = lo[0] > lastLo and hi[0] > hi[1]; // condition for swing low UTC

if not swingLoCondition then
begin
	if lo[0] < lastLo then // found a lower low
	begin
		lastLo = lo[0];
		lastLoBar = CurrentBar;
	end;
	// update cumulative volume of downswing
	volDn = 0;
	barsBack = ( CurrentBar - lastHiBar - 1 );
	for x = barsBack downto 0
	begin
		volDn = volDn + vol[x];
		if PlotVolume then
		begin
			NoPlot[x]( 1 );
			Plot2[x]( VolDn, "Volume Down" );
		end;
	end;
	// update current downswing line and text from lastHiBar
	if PlotSwings then
		TL_SetEnd_Dt( tl, datetime[0], lastLo );
	plotText =
		iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ) + NewLine, "" ) + 
		iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) +
		iffString( PlotTimeText, iffString( dailyTF, NumToStr( CurrentBar - lastHiBar, 0 ) + " bar(s)",
			DateTimeToHMS( ( ELDateToDateTime( Date[0] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
			ELTimeToDateTime_s( Time_s[0] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );
	Text_SetLocation_Dt( waveTxt, datetime[0], Low[0] - Offset );
	Text_SetString( waveTxt, plotText );
end
else if swingLoCondition then // found a swing low
begin
	// update cumulative volume of downswing
	volDn = 0;
	barsBack = ( CurrentBar - lastHiBar - 1 );
	for x = barsBack downto ( CurrentBar - lastLoBar )
	begin
		volDn = volDn + vol[x];
		if PlotVolume then
		begin
			NoPlot[x]( 1 );
			Plot2[x]( VolDn, "Volume Down" );
		end;
	end;
	// update current downswing line from lastHiBar
	if PlotSwings then
		TL_SetEnd_Dt( tl, datetime[CurrentBar - lastLoBar], lastLo );
	plotText =
		iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ) + NewLine, "" ) + 
		iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) +
		iffString( PlotTimeText, iffString( dailyTF, NumToStr( lastLoBar - lastHiBar, 0 ) + " bar(s)",
			DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastLoBar] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
			ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );
	Text_SetLocation_Dt( waveTxt, datetime[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar] - Offset );
	Text_SetString( waveTxt, plotText );
	
	dir = 1; // trend direction is now up
	lastHi = hi[0];
	lastHiBar = CurrentBar; // now seeking new highs
	volUp = 0;
	barsBack = ( CurrentBar - lastLoBar - 1 );
	for x = barsBack downto 0
	begin
		volUp = volUp + vol[x];
		if PlotVolume then
		begin
			Plot1[x]( VolUp, "Volume Up" );
			NoPlot[x]( 2 );
		end;
	end;
	
	if PlotSwings then // start new trendline from new swing low to most recent high
	begin
		tl = TL_New_Dt( datetime[CurrentBar - lastLoBar], lastLo, datetime[CurrentBar - lastHiBar], lastHi );
		TL_SetExtLeft( tl, false );
		TL_SetExtRight( tl, false );
		TL_SetSize( tl, LineWidth );
		TL_SetStyle( tl, LineStyle );
		TL_SetColor( tl, UpColor );
	end;
	plotText =
		iffString( PlotTimeText, iffString( dailyTF, NumToStr( lastHiBar - lastLoBar, 0 ) + " bar(s)",
			DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastHiBar] ) - ELDateToDateTime( Date[CurrentBar - lastLoBar] ) ) +
			ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) ) ), "" ) +
		iffString( PlotVolumeText, NewLine + NumToSTr( volUp / ScaleVolumeBy, 0 ), "" ) + 
		iffString( PlotPriceText, NewLine + "+" + NumToSTr( ( lastHi - lastLo ) * PriceScale, 0 ), "" );
	waveTxt = Text_New_Dt( datetime[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar], plotText );
	Text_SetStyle( waveTxt, 2, 1 );
	Text_SetSize( waveTxt, Font_Size );
	Text_SetColor( waveTxt, TextColor );
end;
end;

Link to comment
Share on other sites

I don't know TS, but it has PowerEditor which is where you need to create a new indicator, copy and paste the above code and then compile it. If it's compatible with TS, then it should compile error free and work but if not, then it will need tweaking. Maybe someone with more TS experience on the forum can help you out more than I can.
Link to comment
Share on other sites

Уважаемый, Smithee. Для компиляции индикатора необходима функция "DateTimeToHMS".

 

---------------------------------------------------------------------------------------------------------

 

Dear Smithee. To compile the indicator, you need the "DateTimeToHMS" function.

Link to comment
Share on other sites

Уважаемый, Smithee. Для компиляции индикатора необходима функция "DateTimeToHMS".

 

---------------------------------------------------------------------------------------------------------

 

Dear Smithee. To compile the indicator, you need the "DateTimeToHMS" function.

 

inputs: XDateTime_s( numericsimple );

var: var0(0),var1(0),var2(0);

var0 = 24 * IntPortion( XDateTime_s ) + IntPortion( 24 * FracPortion( XDateTime_s ) ); // hours
var1 = IntPortion( 60 * FracPortion( 24 * XDateTime_s ) ); // minutes
var2 = IntPortion( 60 * FracPortion( 60 * FracPortion( 24 * XDateTime_s ) ) ); // seconds
                          
DateTimeToHms = NumToStr( var0, 0 ) + "h" + NumToStr( var1, 0 ) + "m" + NumToStr( var2, 0 ) + "s";

Link to comment
Share on other sites

@smithee

 

Hi there mate, what is that extra piece of code, and where does it go?

 

Was it missing from that Weis Wave code you posted? If yes, can you complete it and post it again?

 

Best regards

Edited by logicgate
Link to comment
Share on other sites

@smithee

 

Hi there mate, what is that extra piece of code, and where does it go?

 

Was it missing from that Weis Wave code you posted? If yes, can you complete it and post it again?

 

Best regards

 

The 2nd post is a function. You need to create that as a function in TS and only include that code. Then you need to create an indicator and use the code from the first post. The indicator references the function code so it won't work without it.

Link to comment
Share on other sites

@smithee

 

I see, so it´s two things I need to do.

 

1st - Create a function using the latest piece of code posted (even though I have no clue about doing that)

 

2nd - Create the indicator using the 1st code posted (which will only work if I Create the function first)

 

I believe TS will have "create function" and "create indicator" as separate options? Well, time to watch tutorials...

Link to comment
Share on other sites

So I found this page here that has a tutorial, but for a total noob in programming this already makes my brain smoke...

 

https://markplex.com/free-tutorials/tutorial-8-create-a-simple-easylanguage-function/

 

 

@zonpex

 

If you compile the indicator successfully just upload and post the link here please.

Link to comment
Share on other sites

@smithee

 

Would be too much to ask if you could add to the Weis Wave code the option to choose which volume to use? As it is right now it sums the total volume per bar, can you add an option to choose to sum the delta? From what I can see Tradestation has the Bid-Ask indicator which will give you this value per bar, it is just a matter of adding this option in Weis Wave indicator settings.

Link to comment
Share on other sites

@smithee

 

Would be too much to ask if you could add to the Weis Wave code the option to choose which volume to use? As it is right now it sums the total volume per bar, can you add an option to choose to sum the delta? From what I can see Tradestation has the Bid-Ask indicator which will give you this value per bar, it is just a matter of adding this option in Weis Wave indicator settings.

 

That's beyond my coding skills. Sorry.

Link to comment
Share on other sites

@smithee

 

Would be too much to ask if you could add to the Weis Wave code the option to choose which volume to use? As it is right now it sums the total volume per bar, can you add an option to choose to sum the delta? From what I can see Tradestation has the Bid-Ask indicator which will give you this value per bar, it is just a matter of adding this option in Weis Wave indicator settings.

 

// Initialize variables

dailyTF = BarType >= 2 and BarType < 5;

hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );

lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );

vol = iff( dailyTF, Volume, Ticks );

 

change

 

// Initialize variables

dailyTF = BarType >= 2 and BarType < 5;

hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );

lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );

vol = iff( dailyTF, Volume, Upticks-DownTicks );

Link to comment
Share on other sites

@@zonpex

 

Thanks a lot! But wouldn´t it be easier if you just upload for me the indicator already compiled? You seem to have the hang of it. I am a total noob with TS (and programming I am less than noob)

 

 

Are you sure that upticks-downticks means bid-ask in tradestation? Because this seems like you are asking it to calculate tick volume. Unless in easy language it means bid - ask?

Link to comment
Share on other sites

I wonder if it is simple as adding Bid-Ask in the code, like:

 

 

// Initialize variables

dailyTF = BarType >= 2 and BarType < 5;

hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );

lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );

vol = iff( dailyTF, Volume, Bid-Ask ); <<<<<<<

Link to comment
Share on other sites

@zonpex

 

I think I understand why you are using tick volume. I just found out that Tradestation servers do not store bid and ask volume data!!! So the delta and cumulative delta won´t work, They only work "live" and it seems their servers store only 5 days of time and sales data, which means that the indicator would plot 5 days max of history.

 

Tradestation only offers regular volume historically

 

I just find that unbelievable

 

http://help.tradestation.com/10_00/eng/tradestationhelp/elanalysis/indicator/volume_updn_indicator_.htm

http://help.tradestation.com/09_01/tradestationhelp/data_network/about_ts_data_network.htm

 

 

I won´t even bother installing and wasting time with Tradestation

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...