Hi,
I added the ZigZag % indicator to my chart and would like to export the actual ZigZag values so I can modify in Excel. I notice it says No Plot. Anyways to plot this so I can export?
See attached yellow line.
Plot and Export Indicator : ZigZag [SOLVED]
Plot and Export Indicator : ZigZag
- Attachments
-
- Screen Shot 2014-03-06 at 8.36.52 PM.png
- (38.1 KiB) Downloaded 1126 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Plot and Export Indicator : ZigZag
If you want to output these values, you need to edit the code of the indicator and use FileAppend to output the data to a file, which then can be subsequently opened in Excel.I added the ZigZag % indicator to my chart and would like to export the actual ZigZag values so I can modify in Excel. I notice it says No Plot. Anyways to plot this so I can export?
Re: Plot and Export Indicator : ZigZag
Thanks Josh. Looking at the ZigZag code, I'm not sure what to put in the "Appended Text" field to represent the ZigZag value. Do you know?
FileAppend("C:\test.txt","Appended Text");
FileAppend("C:\test.txt","Appended Text");
Code: Select all
inputs:
Price( Close ),
RetracePct( 5 ),
LineColor( Yellow ),
LineWidth( 1 ) ;
variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( 1 + RetracePct * .01 ),
var6( 1 - RetracePct * .01 ),
var7( false ),
var8( false ),
var9( false ),
var10( 0 ) ;
var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 * var5 ;
if condition1 then
begin
var7 = true ;
var8 = true ;
var4 = 1 ;
end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var7 = true ;
var9 = true ;
end ;
end;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 * var6 ;
if condition1 then
begin
var7 = true ;
var8 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var7 = true;
var9 = true ;
end ;
end;
end ;
end ;
if var7 then
begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var7 = false ;
end ;
if var8 then
begin
var10 = TL_New( var2, var3, var1, var2[1], var3[1],
var1[1] ) ;
TL_SetExtLeft( var10, false ) ;
TL_SetExtRight( var10, false ) ;
TL_SetSize( var10, LineWidth ) ;
TL_SetColor( var10, LineColor ) ;
var8 = false ;
end
else if var9 then
begin
TL_SetEnd( var10, var2, var3, var1 ) ;
var9 = false ;
end ;
FileAppend("C:\test.txt","Appended Text");
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Plot and Export Indicator : ZigZag [SOLVED]
Before I answer this, I wanted to give a quick comment on MultiCharts' default indicators. In general, you're better off by adding descriptive variable names, whitespace, and comments to enhance the readability of code. The default indicators, such as the ZigZag code, are not a great example of understandable programming (and make it look a lot harder than it actually is).Thanks Josh. Looking at the ZigZag code, I'm not sure what to put in the "Appended Text" field to represent the ZigZag value. Do you know?
On to the programming code:
Code: Select all
inputs:
Price( Close ),
RetracePct( 5 ),
LineColor( Yellow ),
LineWidth( 1 ) ;
variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( 1 + RetracePct * .01 ),
var6( 1 - RetracePct * .01 ),
var7( false ),
var8( false ),
var9( false ),
var10( 0 ) ;
Variables:
outputString(""),
printLastValueOnce(false);
var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 * var5 ;
if condition1 then
begin
var7 = true ;
var8 = true ;
var4 = 1 ;
end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var7 = true ;
var9 = true ;
end ;
end;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 * var6 ;
if condition1 then
begin
var7 = true ;
var8 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var7 = true;
var9 = true ;
end ;
end;
end ;
end ;
// Generate data string and output to file
if (var8 = true) or (LastBarOnChart_s = true and printLastValueOnce = false) then begin
once ClearDebug;
outputString = Text(FormatDate("dd-MM-yyyy", ELDateToDateTime(Date)),
";", NumToStr(var1, 4));
Print(outputString);
FileAppend("C:\text.csv", Text(outputString, NewLine));
if (LastBarOnChart_s = true) then
printLastValueOnce = true;
end;
if var7 then
begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var7 = false ;
end ;
if var8 then
begin
var10 = TL_New( var2, var3, var1, var2[1], var3[1],
var1[1] ) ;
TL_SetExtLeft( var10, false ) ;
TL_SetExtRight( var10, false ) ;
TL_SetSize( var10, LineWidth ) ;
TL_SetColor( var10, LineColor ) ;
var8 = false ;
end
else if var9 then
begin
TL_SetEnd( var10, var2, var3, var1 ) ;
var9 = false ;
end ;
Code: Select all
Variables:
outputString(""),
printLastValueOnce(false);
Code: Select all
// Generate data string and output to file
if (var8 = true) or (LastBarOnChart_s = true and printLastValueOnce = false) then begin
once ClearDebug;
outputString = Text(FormatDate("dd-MM-yyyy", ELDateToDateTime(Date)),
";", NumToStr(var1, 4));
Print(outputString);
FileAppend("C:\text.csv", Text(outputString, NewLine));
if (LastBarOnChart_s = true) then
printLastValueOnce = true;
end;
This gives the following output:
Code: Select all
10-09-2012;1.2573
21-09-2012;1.3126
08-10-2012;1.2857
11-10-2012;1.3031
18-10-2012;1.2874
26-10-2012;1.3118
27-11-2012;1.2703
10-12-2012;1.3095
19-12-2012;1.2925
04-01-2013;1.3244
15-01-2013;1.3048
11-02-2013;1.3639
08-03-2013;1.2966
14-03-2013;1.3107
10-04-2013;1.2779
18-04-2013;1.3173
02-05-2013;1.3001
20-05-2013;1.3179
31-05-2013;1.2835
27-06-2013;1.3395
12-07-2013;1.2781
04-09-2013;1.3417
12-09-2013;1.3118
04-11-2013;1.3800
20-11-2013;1.3359
06-01-2014;1.3800
24-01-2014;1.3537
03-02-2014;1.3695
11-02-2014;1.3487
07-03-2014;1.3790
- Attachments
-
- scr.09-03-2014 06.42.25.png
- (83.29 KiB) Downloaded 1218 times
Re: Plot and Export Indicator : ZigZag
I missed this for some reason before. When I place a 10% on INTC I notice that the output values are correct but the dates are off.
For example:
6/2/2014; 26.67
26.67 is the correct value for last ZigZag high but date should be 1/15/2014. Do you see the same thing?
For example:
6/2/2014; 26.67
26.67 is the correct value for last ZigZag high but date should be 1/15/2014. Do you see the same thing?
- Attachments
-
- Screen Shot 2014-03-14 at 2.17.43 PM.png
- (126.61 KiB) Downloaded 1077 times
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Plot and Export Indicator : ZigZag
Good to know it is working.Got some help, here's the fix:
Replace
"ELDateToDateTime(Date)" with "ELDateToDateTime(var2)"