Help with Code  [SOLVED]

Questions about MultiCharts and user contributed studies.
fankc
Posts: 2
Joined: 27 Dec 2005
Has thanked: 1 time

Help with Code

Postby fankc » 16 Jul 2015

Hi All,

Can someone help me with this code? I am not really good in programming.

It's from this site

http://traders.com/Documentation/FEEDbk ... sTips.html

It compiled with error as shown. See attached.

Code: Select all

{ TASC Article, June 2013 }
{ "The 1-2-3 Wave Count" }
{ Sylvain Vervoort }

using elsystem ;

inputs:
double ZZPercent( 5 ), { 0 = no influence; enter
in percentage points; for 1% enter 1, Not 0.01 }
int ATRPeriod( 5 ), { number of bars for ATRCalc
calc }
double ATRFactor( 1.5 ), { 0 = no ATR influence }
int ZigZagColor( Cyan ), { trendline color }
int LineWidth( 1 ) ; { trendline thickeness }

variables:
double ATRCalc( 0 ),
intrabarpersist int trend( 1 ), { confirmed trend
of current zigzag, 1 = up, -1 = down (assume
trend is up at the start) }
int LHBDate( 0 ),
int LHBTime( 0 ),
intrabarpersist int uplineid( 0 ),
int LLBDate( 0 ),
int LLBTime( 0 ),
intrabarpersist int downlineid( 0 ),
intrabarpersist double HH( 0 ),
intrabarpersist double LL( 0 ),
intrabarpersist double HLPivot( 0 ) ;

method void DrawUpLine()

begin
uplineid = TL_New( LLBDate, LLBTime, LL, LHBDate,
LHBTime, HH ) ;
FormatTL( uplineid ) ;
end ;

Method void DrawDnLine()
begin
downlineid = TL_New( LHBDate, LHBTime, HH,
LLBDate, LLBTime, LL ) ;
FormatTL( downlineid ) ;
end ;

method void FormatTL( int TLID )
begin
TL_SetColor( TLID, ZigZagColor ) ;
TL_SetSize( TLID, LineWidth ) ;
end ;

once
begin
if ATRPeriod <= 0 then
RaiseRuntimeError( "ATRPeriod input must " +
"be greater than 0." ) ;
LLBDate = Date ;
LLBTime = Time ;
LHBDate = Date ;
LHBTime = Time ;
LL = Low ;
HH = High ;
end ;

ATRCalc = AvgTrueRange( ATRPeriod ) ;

if ATRFactor = 0 then { only use percent setting }
HLPivot = ZZPercent * 0.01
else if ZZPercent = 0 then { only use ATR }
HLPivot = ATRCalc / Close * ATRFactor
else { use ATR and ZZPercent }
HLPivot = ZZPercent * 0.01 + ATRCalc / Close *
ATRFactor ;

{ look for swing points and draw lines }
if trend > 0 then { trend is up, look for new swing
low }
begin
if High >= HH then { new higher high detected }
begin
HH = High ;
LHBDate = Date ;
LHBTime = Time ;
if uplineid <> 0 then
TL_Delete( uplineid ) ;
DrawUpLine() ;
end
else if Low < HH - HH * HLPivot then { found a
swing low }
begin
LL = Low ;
LLBDate = Date ;
LLBTime = Time ;
trend = -1 ;
DrawDnLine() ;
end ;
end
else { trend is down, look for new swing high }
begin
if Low <= LL then { new lower low detected }
begin
LL = Low ;
LLBDate = Date ;
LLBTime = Time ;
if downlineid > 0 then
TL_Delete( downlineid ) ;
DrawDnLine() ;
end
else if High > LL + LL * HLPivot then { found a
swing high }
begin
HH = High ;
LHBDate = Date ;
LHBTime = Time ;
trend = 1 ;
DrawUpLine() ;
end ;
end ;
Attachments
zzswing.png
(171.43 KiB) Downloaded 722 times

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Help with Code

Postby TJ » 16 Jul 2015

Hi All,

Can someone help me with this code? I am not really good in programming.

It's from this site

http://traders.com/Documentation/FEEDbk ... sTips.html

It compiled with error as shown. See attached.

Code: Select all

{ TASC Article, June 2013 }
{ "The 1-2-3 Wave Count" }
{ Sylvain Vervoort }
::

This is not pure EasyLanguage code.
This code has the new TS OOP extension; it is not compatible with MultiCharts.

Do a search on the word "method" and you will find some attempts to recode the script for MultiCharts use.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Help with Code  [SOLVED]

Postby JoshM » 16 Jul 2015

Can someone help me with this code? I am not really good in programming.
Hello,

See the attached indicator (source code below). I've replaced the TS methods (just copy/paste). The indicator looks like this:

Image
123WaveCount.pla
(9.82 KiB) Downloaded 594 times
===========

Code: Select all

{
1-2-3 Wave Count
----------------
Indicator by Sylvain Vervoort.
Stocks & Commodities June 2013.

Source: http://traders.com/Documentation/FEEDbk_docs/2013/06/TradersTips.html
Changes made:
* Removed TS specific methods
* Replaced TL_New with TL_New_s so it also works on seconds bars
}

Inputs:
ZZPercent( 5 ), { 0 = no influence; enter
in percentage points; for 1% enter 1, Not 0.01 }
ATRPeriod( 5 ), { number of bars for ATRCalc
calc }
ATRFactor( 1.5 ), { 0 = no ATR influence }
ZigZagColor( Green ), { trendline color }
LineWidth( 1 ) ; { trendline thickeness }

Variables:
ATRCalc( 0 ),
intrabarpersist trend( 1 ), { confirmed trend
of current zigzag, 1 = up, -1 = down (assume
trend is up at the start) }
LHBDate( 0 ),
LHBTime( 0 ),
intrabarpersist uplineid( 0 ),
LLBDate( 0 ),
LLBTime( 0 ),
intrabarpersist downlineid( 0 ),
intrabarpersist HH( 0 ),
intrabarpersist LL( 0 ),
intrabarpersist HLPivot( 0 ) ;


once
begin
if ATRPeriod <= 0 then
RaiseRuntimeError( "ATRPeriod input must " +
"be greater than 0." ) ;
LLBDate = Date ;
LLBTime = Time ;
LHBDate = Date ;
LHBTime = Time ;
LL = Low ;
HH = High ;
end ;

ATRCalc = AvgTrueRange( ATRPeriod ) ;

if ATRFactor = 0 then { only use percent setting }
HLPivot = ZZPercent * 0.01
else if ZZPercent = 0 then { only use ATR }
HLPivot = ATRCalc / Close * ATRFactor
else { use ATR and ZZPercent }
HLPivot = ZZPercent * 0.01 + ATRCalc / Close *
ATRFactor ;

{ look for swing points and draw lines }
if trend > 0 then { trend is up, look for new swing
low }
begin
if High >= HH then { new higher high detected }
begin
HH = High ;
LHBDate = Date ;
LHBTime = Time_s ;
if uplineid <> 0 then
TL_Delete( uplineid ) ;

// Draw up line
uplineid = TL_New_s( LLBDate, LLBTime, LL, LHBDate,
LHBTime, HH ) ;
TL_SetColor( uplineid, ZigZagColor ) ;
TL_SetSize( uplineid, LineWidth ) ;

end
else if Low < HH - HH * HLPivot then { found a
swing low }
begin
LL = Low ;
LLBDate = Date ;
LLBTime = Time_s ;
trend = -1 ;

// Draw down line
downlineid = TL_New_s( LHBDate, LHBTime, HH,
LLBDate, LLBTime, LL ) ;
TL_SetColor( downlineid, ZigZagColor ) ;
TL_SetSize( downlineid, LineWidth ) ;

end ;
end
else { trend is down, look for new swing high }
begin
if Low <= LL then { new lower low detected }
begin
LL = Low ;
LLBDate = Date ;
LLBTime = Time_s ;
if downlineid > 0 then
TL_Delete( downlineid ) ;

// Draw down line
downlineid = TL_New_s( LHBDate, LHBTime, HH,
LLBDate, LLBTime, LL ) ;
TL_SetColor( downlineid, ZigZagColor ) ;
TL_SetSize( downlineid, LineWidth ) ;

end
else if High > LL + LL * HLPivot then { found a
swing high }
begin
HH = High ;
LHBDate = Date ;
LHBTime = Time_s ;
trend = 1 ;

// Draw up line
uplineid = TL_New_s( LLBDate, LLBTime, LL, LHBDate,
LHBTime, HH ) ;
TL_SetColor( uplineid , ZigZagColor ) ;
TL_SetSize( uplineid , LineWidth ) ;

end ;
end ;

Attachments
scr.16-07-2015 16.05.34.png
(7.93 KiB) Downloaded 819 times

fankc
Posts: 2
Joined: 27 Dec 2005
Has thanked: 1 time

Re: Help with Code

Postby fankc » 19 Jul 2015

Thanks everyone for your help.


Return to “MultiCharts”