how use zigzag
how use zigzag
02 Jul 2014, 00:18
hi
i want use zigzag and show up trend or down trend
i try this link
/algos/cbots/show/159
this cod :
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class testZigZag : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } private Position _position; private ZigZag _zigZag; private double _prevValue; [Parameter(DefaultValue = 12)] public int ZzDepth { get; set; } [Parameter(DefaultValue = 550)] public int StopLoss { get; set; } [Parameter(DefaultValue = 5)] public int ZzDeviation { get; set; } [Parameter(DefaultValue = 3)] public int ZzBackStep { get; set; } [Parameter(DefaultValue = 100000, MinValue = 0)] public int Volume { get; set; } protected override void OnStart() { // Put your initialization logic here _zigZag = Indicators.GetIndicator<ZigZag>(ZzDepth, ZzDeviation, ZzBackStep); } protected override void OnTick() { // Put your core logic here double lastValue = _zigZag.Result.LastValue; if (lastValue < _prevValue) Print("Up Trend"); else if (lastValue > _prevValue && _prevValue > 0.0) Print("Down Trend"); _prevValue = lastValue; } protected override void OnStop() { // Put your deinitialization logic here } } }
but expert not print any thing
Replies
RootFX
03 Jul 2014, 04:42
RE:
Spotware said:
First of all, value which you assign to the _prevValue field cannot be considered as a previous value of ZigZag. It is a last value calculated on the previous tick.
Second of all, ZigZag indicator doesn't write values to every index. Therefore in order to retrieve value which you selected on the image, you need to iterate through _zigZag.Result DataSeries and find a value which is not double.NaN.
thank you team Spotware
please you can set example .?
@RootFX
Spotware
03 Jul 2014, 08:56
Please have a look at the following code snippet:
ZigZag zigzag; protected override void OnStart() { zigzag = Indicators.GetIndicator<ZigZag>(12, 5, 3); } double GetZigZagValue(DataSeries dataSeries, int indexFromEnd) { for (var i = MarketSeries.Close.Count - 1; i >= 0; i--) { if (!double.IsNaN(zigzag.Result[i])) { if (indexFromEnd == 0) return zigzag.Result[i]; indexFromEnd--; } } return double.NaN; } protected override void OnTick() { var lastValue = GetZigZagValue(zigzag.Result, 0); var previousValue = GetZigZagValue(zigzag.Result, 1); if (lastValue > previousValue) Print("lastValue {0} > previousValue {1}", lastValue, previousValue); if (lastValue < previousValue) Print("lastValue {0} < previousValue {1}", lastValue, previousValue); }
@Spotware
ABR170173
16 Mar 2015, 19:10
Hi,
Does someone could to glue all these codes together correctly? (Base Zig Zag code, 1st post correction and next 4th post correction to 1st post)
I've tried to do it by myself but my C# is definitely too weak at this level.
Many thanks
@ABR170173
cjdduarte
17 Mar 2015, 13:49
RE:
Interestingly, had not read this topic.
I will try to do what you asked.
ABR170173 said:
Hi,
Does someone could to glue all these codes together correctly? (Base Zig Zag code, 1st post correction and next 4th post correction to 1st post)
I've tried to do it by myself but my C# is definitely too weak at this level.
Many thanks
@cjdduarte
ABR170173
17 Mar 2015, 18:58
Thanks for try cjdduarte.
Of course I mean indy, not cBot ZigZag like is in this section.
Generally, I'm surprised that custom indicators section, in net, working at this platform is quite small. Especially that many people swap her with MT4.
@ABR170173
seyhaan
16 Sep 2017, 21:38
RE:
Spotware said:
Please have a look at the following code snippet:
ZigZag zigzag; protected override void OnStart() { zigzag = Indicators.GetIndicator<ZigZag>(12, 5, 3); } double GetZigZagValue(DataSeries dataSeries, int indexFromEnd) { for (var i = MarketSeries.Close.Count - 1; i >= 0; i--) { if (!double.IsNaN(zigzag.Result[i])) { if (indexFromEnd == 0) return zigzag.Result[i]; indexFromEnd--; } } return double.NaN; } protected override void OnTick() { var lastValue = GetZigZagValue(zigzag.Result, 0); var previousValue = GetZigZagValue(zigzag.Result, 1); if (lastValue > previousValue) Print("lastValue {0} > previousValue {1}", lastValue, previousValue); if (lastValue < previousValue) Print("lastValue {0} < previousValue {1}", lastValue, previousValue); }Hi!
I m very new on zig zag indicator. I have different programme which is based on c# but I could not working out your codes. (visit here, http://estore.directfn.com.tr/ReadMore.aspx?rmc=ideal). So what can I do?
@seyhaan
Spotware
18 Sep 2017, 10:23
Dear seyhaan,
Thanks for posting in our forum. It is not very clear what you are asking for. Do you want to use our indicators in your program? This is not possible, our Indicators require cAlgo or cTrader to run. If we misunderstood your question, please feel free to elaborate.
Best Regards,
cTrader Team
@Spotware
ericjavier.santiago
09 Jun 2020, 23:01
RE: Use values as Series
Hi Spotware Team:
Is it possible to obtain the values of the ZigZag as a Series? Below the values are stored in var.
Thanks!
@ericjavier.santiago
PanagiotisCharalampous
10 Jun 2020, 08:32
Hi ericjavier.santiago,
In principle it is possible but the code needs to be modified accordingly.
Best Regards,
Panagiotis
@PanagiotisCharalampous
Spotware
02 Jul 2014, 10:22
First of all, value which you assign to the _prevValue field cannot be considered as a previous value of ZigZag. It is a last value calculated on the previous tick.
Second of all, ZigZag indicator doesn't write values to every index. Therefore in order to retrieve value which you selected on the image, you need to iterate through _zigZag.Result DataSeries and find a value which is not double.NaN.
@Spotware