ZigZag Channel

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

ZigZag Channel

Postby Apprentice » Mon May 26, 2014 5:16 am

ZigZag Channel.png

ZigZag Channel.lua
(13.74 KiB) Downloaded 1914 times

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

Tick ZigZag Channel with Output.lua
(14.44 KiB) Downloaded 1391 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ZigZag Channel

Postby Cactus » Tue Feb 21, 2017 8:43 pm

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.
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: ZigZag Channel

Postby Apprentice » Wed Feb 22, 2017 3:32 am

Objects are drawn via Draw() function.
I believe this is the reason.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ZigZag Channel

Postby Cactus » Wed Feb 22, 2017 4:50 pm

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
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: ZigZag Channel

Postby Apprentice » Fri Feb 24, 2017 5:56 am

We can rewrite, use ouput core.drawLine and two output streams,
or core.host:execute ("drawLine"...
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ZigZag Channel

Postby Cactus » Fri Feb 24, 2017 3:37 pm

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?
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: ZigZag Channel

Postby Apprentice » Sat Feb 25, 2017 4:17 pm

ZigZag Channel with Output added.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ZigZag Channel

Postby Cactus » Sat Feb 25, 2017 7:48 pm

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
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: ZigZag Channel

Postby Apprentice » Sun Feb 26, 2017 4:58 am

I can not help you without access to underlying strategy.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ZigZag Channel

Postby Cactus » Sun Feb 26, 2017 8:23 am

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
Attachments
error_zig_output_strat.jpg
zig_output_channel_strat.lua
(36.01 KiB) Downloaded 1176 times
error_zig_output_strat2.jpg
error_zig_output_strat2.jpg (32.6 KiB) Viewed 7619 times
simualtormode.jpg
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Next

Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 6 guests