ZigZag with Depth and Backstep - futures io
futures io



ZigZag with Depth and Backstep


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,414 views
    2. thumb_up 2 thanks given
    3. group 5 followers
    1. forum 2 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

ZigZag with Depth and Backstep

(login for full post details)
  #1 (permalink)
eggzactly
lisbon Portugal
 
 
Posts: 2 since Jan 2013
Thanks: 0 given, 1 received

Hi,

Can someone please help me and add Depth and Backstep calculation to the ZigZag% indicator

Thanks in advance,

ELD Code

{ Search Tag: WA-ZigZag % }

using elsystem;
using elsystem.drawing;
using elsystem.drawingobjects;

inputs:
double HighPivotPrice( High ) [
DisplayName = "HighPivotPrice",
ToolTip = "Enter an EasyLanguage expression to use in the calculation of high ZigZag pivots."],

double LowPivotPrice( Low ) [
DisplayName = "LowPivotPrice",
ToolTip = "Enter an EasyLanguage expression to use in the calculation of low ZigZag pivots."],

double RetracePct( 5 ) [
DisplayName = "RetracePct",
ToolTip = "Retracement Percentage. Enter The amount of retracement of the price specified in the price input that will cause a new zigzag line to be drawn."],

int LineColor( MyColors( "DodgerBlue" ) ) [
DisplayName = "LineColor",
ToolTip = "Enter the color to be used for the zigzag lines."],

int LineWidth( 1 ) [
DisplayName = "LineWidth",
ToolTip = "Enter the width, specified as a number, of the zigzag lines. This value can have any integer value from 0 to 6."];

variables:
intrabarpersist bool UseBNPoint( false ),
int DrawingObjectBarNumber( 0 ),
TrendLine ZigZagTrendline( NULL ),
DTPoint SwingDTPoint( NULL ),
DTPoint LastSwingDTPoint( NULL ),
BNPoint SwingBNPoint( NULL ),
BNPoint LastSwingBNPoint( NULL ),
double NewSwingPrice( 0 ),
double SwingPrice( Close ), { used as a convenient 2-element array }
int TLDir( 0 ), { TLDir = -1 implies prev TL dn, +1 implies prev TL up }
double RetraceFctrUp( 1 + RetracePct * .01 ),
double RetraceFctrDn( 1 - RetracePct * .01 ),
bool SaveSwing( false ),
bool AddTL( false ),
bool UpdateTL( false );

method TrendLine CreateNewTrendline()
variables: TrendLine tempTL;
begin
if UseBNPoint then
tempTL = TrendLine.Create( LastSwingBNPoint, SwingBNPoint )
else { use DTPoint }
tempTL = TrendLine.Create( LastSwingDTPoint, SwingDTPoint );

{
Setting 'Persist' to false causes the trendline to be deleted on an
intrabar tick. When set to false, a trendline that is created on the
closing tick of the bar is saved/retained.
}
tempTL.Persist = false;
tempTL.Lock = true; { prevent inadvertent moving }
tempTL.Color = GetColorFromInteger( 255, LineColor );
tempTL.ExtLeft = false;
tempTL.ExtRight = false;
tempTL.Weight = LineWidth;

{
this is how the trendline is "shown"; the trendline is added to the
DrawingObjects collection; if you want to remove the trendline, you can
use the Delete method of the DrawingObjects class; DrawingObjects collection
is not available in RadarScreen (it is NULL), so we only add the trendlines
to the collection if not NULL
}
if DrawingObjects <> NULL then
DrawingObjects.Add( tempTL );

return tempTL;
end;

{ convert integer color to a color object and return the color object }
method Color GetColorFromInteger( int Alpha, int ColorInteger )
begin
return Color.FromARGB( Alpha, GetRValue( ColorInteger ),
GetGValue( ColorInteger ), GetBValue( ColorInteger ) );
end;

once
begin
{
When this study is applied to tick bars or advanced bars, we use BNPoint
positioning of text labels. This ensures that the text labels are positioned
on the correct bar even when multiple bars occur in the same second (as can
occur with very short-term tick bars). When positioning time-based bars, on
the other hand, we’ll use DTPoint positioning. This type of positioning can
account for missing bars in the data stream (periods of no trading activity,
as can occur with ‘thin’ issues). Missing bars, of course, cannot occur when
using tick-based charts or advanced bars, since these bar-building mechanisms
do not move along the x-axis until enough trades have occurred to complete a
bar. Thus, the approach illustrated here gives us the best of both worlds
– sub-second positioning and automatic accounting for missing bars.
}
UseBNPoint = BarType = 0 or ( BarType > 4 and BarType <> 14 );

if UseBNPoint then
SwingBNPoint = BNPoint.Create( CurrentBar + MaxBarsBack - 1, Close )
else
SwingDTPoint = DTPoint.Create( BarDateTime, Close );
end;

{ set the bar number for the drawing object }
if UseBNPoint then
DrawingObjectBarNumber = CurrentBar + MaxBarsBack - 1;

NewSwingPrice = SwingHigh( 1, HighPivotPrice, 1, 2 );

if NewSwingPrice <> -1 then
begin
if TLDir <= 0 and NewSwingPrice >= SwingPrice * RetraceFctrUp then
begin
SaveSwing = true;
AddTL = true;
TLDir = 1;
end
else if TLDir = 1 and NewSwingPrice >= SwingPrice then
begin
SaveSwing = true;
UpdateTL = true;
end;
end
else
begin
NewSwingPrice = SwingLow( 1, LowPivotPrice, 1, 2 );
if NewSwingPrice <> -1 then
begin
if TLDir >= 0 and NewSwingPrice <= SwingPrice * RetraceFctrDn then
begin
SaveSwing = true;
AddTL = true;
TLDir = -1;
end
else if TLDir = -1 and NewSwingPrice <= SwingPrice then
begin
SaveSwing = true;
UpdateTL = true;
end;
end;
end;

{ save new swing and reset SaveSwing }
if SaveSwing then
begin
if UseBNPoint then
begin
LastSwingBNPoint = SwingBNPoint;
SwingBNPoint = BNPoint.Create( DrawingObjectBarNumber[1], NewSwingPrice );
end
else
begin
LastSwingDTPoint = SwingDTPoint;
SwingDTPoint = DTPoint.Create( BarDateTime[1], NewSwingPrice );
end;

SwingPrice = NewSwingPrice;
SaveSwing = false;
end;

if AddTL then { add new trendline }
begin
ZigZagTrendline = CreateNewTrendline();
AddTL = false;
end
else if UpdateTL then { update trendline }
begin
if ZigZagTrendline <> NULL then
begin
if UseBNPoint then
ZigZagTrendline.SetEndPoint( SwingBNPoint )
else
ZigZagTrendline.SetEndPoint( SwingDTPoint );
end;

UpdateTL = false;
end;

Reply With Quote
The following user says Thank You to eggzactly for this post:

Can you help answer these questions
from other members on futures io?
How do I create Strategy with the Second Entry indicator
NinjaTrader
Big Mo Indicator for NT8
NinjaTrader
help with take profit several targets
TradeStation
NT8 Order Management Strategy
The Elite Circle
in depth understanding of last, bid, and ask volume in c …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Is anyone actually making money?
88 thanks
An embarrassing, honest confession
25 thanks
Sierra vs. Ninja : why I chose .....
8 thanks
ApexTraderFunding.com experience and review
8 thanks
Want your NinjaTrader indicator created, free?
7 thanks
 
(login for full post details)
  #2 (permalink)
 nothingbutprofits 
rochester new york/USA
 
Experience: Advanced
Platform: ThinkOrSwim & NT
Broker: NT, TOS
Trading: ES NQ RTY CL NG
 
nothingbutprofits's Avatar
 
Posts: 78 since Feb 2021
Thanks: 245 given, 48 received

What trading platform?

eggzactly View Post
Hi,

Can someone please help me and add Depth and Backstep calculation to the ZigZag% indicator

Thanks in advance,

ELD Code

{ Search Tag: WA-ZigZag % }

end;


Reply With Quote
 
(login for full post details)
  #3 (permalink)
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
 
syswizard's Avatar
 
Posts: 344 since Jan 2019
Thanks: 20 given, 138 received



nothingbutprofits View Post
What trading platform?

Looks like EasyLangage.

Reply With Quote
The following user says Thank You to syswizard for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > ZigZag with Depth and Backstep


Last Updated on April 3, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts