Page 1 of 11

ZigZag Channel

PostPosted: Mon May 26, 2014 5:16 am
by Apprentice
ZigZag Channel.png

ZigZag Channel.lua
(13.74 KiB) Downloaded 1914 times

ZigZag Channel with Output.lua
(14.48 KiB) Downloaded 1545 times

Tick ZigZag Channel with Output.lua
(14.44 KiB) Downloaded 1391 times

Re: ZigZag Channel

PostPosted: Tue Feb 21, 2017 8:43 pm
by Cactus
Great find. Can you please check why lines disappear sometimes when moving the chart around with many instances of the same indicator applied?
When zooming in/out or scrolling back, the lines simply disappear, until I go into indicator settings and click apply/ok again.

Re: ZigZag Channel

PostPosted: Wed Feb 22, 2017 3:32 am
by Apprentice
Objects are drawn via Draw() function.
I believe this is the reason.

Re: ZigZag Channel

PostPosted: Wed Feb 22, 2017 4:50 pm
by Cactus
Apprentice wrote:Objects are drawn via Draw() function.
I believe this is the reason.


I see. In this case, what is the solution? Is it possible to make this behavior go away? Can you re-write this indicator using same principle as "trend line helper" or something? Can this draw() function be fixed? This would make for a very good channel indicator if lines would not disappear

Re: ZigZag Channel

PostPosted: Fri Feb 24, 2017 5:56 am
by Apprentice
We can rewrite, use ouput core.drawLine and two output streams,
or core.host:execute ("drawLine"...

Re: ZigZag Channel

PostPosted: Fri Feb 24, 2017 3:37 pm
by Cactus
Apprentice wrote:We can rewrite, use ouput core.drawLine and two output streams,
or core.host:execute ("drawLine"...


That's great, can you please provide this indicator with two output streams for the lines as you mention?

Re: ZigZag Channel

PostPosted: Sat Feb 25, 2017 4:17 pm
by Apprentice
ZigZag Channel with Output added.

Re: ZigZag Channel

PostPosted: Sat Feb 25, 2017 7:48 pm
by Cactus
This is perfect, thank you Apprentice, very good indicator
I have a problem after adding it to a strategy, the following in the backtester:

C:/Program Files (x86)/Candleworks/FXTS2/Strategies/Custom/my_strat.lua:239:
C:/Program Files (x86)/Candleworks/FXTS2/Indicators/Custom/ZigZag Channel with Output.lua (409, -1) : E19 - The first parameter must be a number

Strategy line code
Code: Select all
ZIGZAG_CHANNEL_WITH_OUTPUT:update(core.UpdateLast);

However this does not happen in Simulation Mode so I guess it shoudn't be a problem live either
I am guessing it is to do with no candle history being available in backtester to draw the zigzag

Thank you

Re: ZigZag Channel

PostPosted: Sun Feb 26, 2017 4:58 am
by Apprentice
I can not help you without access to underlying strategy.

Re: ZigZag Channel

PostPosted: Sun Feb 26, 2017 8:23 am
by Cactus
Ok! Here's a sample strategy to demonstrate this problem I created using FX Wizard:

I have added a screenshot of the settings
Running it on EUR/USD on the past week (13.02.2017 - 17.02.2017), I get the following error:

Code: Select all
C:/Program Files (x86)/Candleworks/FXTS2/Strategies/Custom/zig_output_channel_strat.lua:230:  C:/Program Files (x86)/Candleworks/FXTS2/Indicators/Custom/ZigZag Channel with Output.lua (409, -1) : E19 -  The first parameter must be a number


But when I do the same in "simualtion mode" (where there is more candle data available, not just the chosen range), the backtesting runs fine, but is very slow, and the equity looks like this: (with settings take_profit 0.1 and max_positions 100)

However, sometimes, with different settings, I get a similar error, just talking about "third parameter"

Also, can you please say what stream is "out" corresponding to? I understand "Top" and "Bottom".
But on chart there's also "Up" and in FX Wizard there's "out". Is this causing the error?
Or is it because I am checking every tick for updates? How can I fix this strategy to work in backtester?

Also, I mostly rely on FX Wizard to create my strategies, would you be so kind to inspect the code and advice on any changes I should perform every time, since it's the same template every time, I want to know if there's a better way of writing strategies, since the project has not been updated in a while. By "better" I mean without unecessary code, more efficient, optimal, etc. For example, I like to use (ask + bid / 2) price = median. In this strategy I use this indicator and BB. I have two BB (1 ask and 1 bid) and perform the median calculation to get one reading. I also have "mid_tick" which is the median price, I am sure I could replace the BB source with mid_tick instead of calculating it twice, one for ask and one for bid and dividing by two... And stuff like that.

All suggestions and comments are welcome please.

This strategy uses 3 timeframes: tick, m1, m15


Thanks