building using Delphi 2010

Examples step by step how to make your own automated strategy or user indicator
Message
Author
eklavya
Posts: 5
Joined: Wed Jun 11, 2008 11:26 am

building using Delphi 2010

#1 Postby eklavya » Fri Aug 06, 2010 10:17 pm

Hi,

I am trying to build an indicator using Delphi 2010. I am getting the dll fild created and am able to add it successfully. However, when I try to add the indicator to the chart, I can only see the first character of the indicator short name in this case "t" and not the expected "test1".

In fact when I compile any existing FT indicator such as MACD and install the dll file and the upon add the indicator to the chart I see only "M" and not "MACD"

Here is the code. Appreciate any help on this.

Code: Select all

library test1;

uses
  SysUtils, classes, graphics, math, IndicatorInterfaceUnit, TechnicalFunctions;

  //---------------------------------------------------------------------------
// Initialization
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
  // define parameters
  IndicatorShortName('test1');
  SetOutputWindow(ow_ChartWindow);
end;

//---------------------------------------------------------------------------
// Deinitialization
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
end;

//---------------------------------------------------------------------------
// Calculate bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
begin
end;

exports
Init, Done, Calculate;
end.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Sat Aug 07, 2010 12:40 am

Hello,

This problem appears because in new delphi version "string" means unicode string but in old delphi version "string" was equal to "AnsiString".
Forex Tester requires all strings in AnsiString format, so please do the following to fix this issue:

1) use attached API libraries. We'll include these libraries into Forex Tester 2.6.

2) change type for all "string" variables to "AnsiString"
Attachments
NewDelphiAPI.zip
(9.57 KiB) Downloaded 1051 times
Last edited by FT Support on Tue Aug 10, 2010 2:46 am, edited 1 time in total.
Check our other product here:
http://www.forexcopier.com

eklavya
Posts: 5
Joined: Wed Jun 11, 2008 11:26 am

#3 Postby eklavya » Sat Aug 07, 2010 9:32 am

Hello..thank you..

I don't have too much of a coding experience...can you please advice on how exactly I can do the above.

What changes will I have to make to the code above to make it work?

eklavya
Posts: 5
Joined: Wed Jun 11, 2008 11:26 am

#4 Postby eklavya » Mon Aug 09, 2010 4:04 pm

Could you please kindly help out with this issue?

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#5 Postby FT Support » Tue Aug 10, 2010 3:03 am

Hello,

Just try to download attached API and replace your versions of "TechnicalFunctions.pas" and "IndicatorInterfaceUnit.pas" files.

No changes are required in your code for now.

Let me know if you still have problems with this.
Attachments
NewDelphiAPI.zip
(9.57 KiB) Downloaded 1015 times
Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

How to compile TPL to dpr

#6 Postby hjabu » Tue Apr 19, 2011 9:31 am

eklavya,

Hi , i ,m new using delphi xe, for compiling my tpl file indicator, couldgive some tips how do i start using Delphi xe, to convert tpl into dpr and dll please.. Thank you

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#7 Postby FT Support » Tue Apr 19, 2011 3:36 pm

Hello,

Sorry but "tpl" is not an indicator, is it correct that you need to convert a template?
Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

Tpl to dpr and dll

#8 Postby hjabu » Tue Apr 19, 2011 6:23 pm

eklavya,

Yes it is template , so how do you convert them using delphi...

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

Template convert to dpr and dll

#9 Postby hjabu » Tue Apr 19, 2011 6:28 pm

Picture chart look like this:[/img]
Attachments
eurusd template.gif
Picture chart look like this:
eurusd template.gif (25.35 KiB) Viewed 85486 times

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#10 Postby FT Support » Wed Apr 20, 2011 3:27 am

Hmm, i'm pretty sure that this template uses some indicators that have to be converted into FT format as well. Please contact Tantalus (member of our forum), I think that he can help you with the conversion.
Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

Cannot get "Init proc address"

#11 Postby hjabu » Wed Apr 20, 2011 3:58 am

I have found my tpl to dpr succeded converted and copile it to dll, afther that i ve try to install at my Forex tester it appear repor:

Cannot get "Init proc address"

Please could somone experties in delphi to solve this problem,, do i miss something a code that should i add them?

because i ,m get use to create using delphi now .

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#12 Postby FT Support » Thu Apr 21, 2011 3:31 am

Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

recreate the indicators code

#13 Postby hjabu » Sun Apr 24, 2011 3:24 pm

Hi , i have re write the code using delphi , could you please check my code as shown below:
//---------------------------------------------------------------------------
// idyllictrading
//---------------------------------------------------------------------------
library idyllictrading;



uses
SysUtils,
classes,
graphics,
math,
DateUtils,
IndicatorInterfaceUnit,
TechnicalFunctions in 'TechnicalFunctions.pas';

var
//THVSDXTzPivots
;Local _HrsServerTzFromGMT=0
Destination _HrsNewTZfromGMT=0
Show_1Daily_2FibonacciPivots=2
FullScreenLines:0
__withMarginPrices=1
MoveLabels_LR_DecrIncr=0
R5_Color:2237106
R5_LineStyle_01234=2
R5_SolidLineThickness=1
R4_Color=2237106
R4_LineStyle_01234=2
R4_SolidLineThickness=1
R3_Color=2237106
R3_LineStyle_01234=2
R3_SolidLineThickness=1
R2_Color=1973915
R2_LineStyle_01234=2
R2_SolidLineThickness=1
R1_Color=1513341
R1_LineStyle_01234=2
R1_SolidLineThickness=1
CentralPivotColor=6447616
CentralPivotLineStyle_01234=0
CentralPivotSolidLineThickness=1
S1_Color=25600
S1_LineStyle_01234=2
S1_SolidLineThickness=1
S2_Color=32768
S2_LineStyle_01234=2
S2_SolidLineThickness=1
S3_Color=2263842
S3_LineStyle_01234=2
S3_SolidLineThickness=1
S4_Color=2263842
S4_LineStyle_01234=2
S4_SolidLineThickness=1
S5_Color=2263842
S5_LineStyle_01234=2
S5_SolidLineThickness=1
MidPivotsColor=25186
MidPivotsLineStyle_01234=2
MidPivotsLineThickness=1
ShowMidPivots=0
QtrPivotsColor=1262987
QtrPivotsLineStyle_01234=2
QtrPivotsLineThickness=1
ShowQtrPivots=0
YesterdayHighLowColor=4802889
HighLowLineStyle_01234=2
HighLowSolidLineThickness=1
ShowYesterdayHighLow=1
TodayOpenColor=7405681
TodayOpenLineStyle_01234=2
TodayOpenSolidLineThickness=1
ShowTodayOpen=1
CamarillaColor=14053594
CamarillaLineStyle_01234=2
CamarillaSolidLineThickness=1
ShowCamarilla=0
PeriodSeparatorLinesColor=25186
SeparatorLinesStyle_01234=0
SeparatorLinesThickness=1
ShowPeriodSeparatorLines=1
PeriodSeparatorsLabelsColor=25186
PlaceAt_TopBot_12_OfChart=2
SeparatorLabelFontSize=9
S_Label_Norm_Bold_Black_123=2
ShowPeriodSeparatorLabels=1
PivotLinesLabelColor=25186
LineLabelsFontSize=9
L_Label_Norm_Bold_Black_123=1
LineLabelsIncludePrice=1
Relabeler_Adjustment=10
Show_Relabeler_Comment=0
Show_Data_Comment=0
var
//AMA optimized
period AMA=10
nfast=2.00000000
nslow=30.00000000
G=2.00000000
dK=2.00000000
PriceType=0
AMA_Trend_Type=1
var
//NonLagMA
Price=0
Length=55
Displace=0
PctFilter=0.00000000
Color=1
ColorBarBack=1
Deviation=0.00000000
SoundAlertMode=0
var
//#4X 3 Semafor Alert
Period1=5.00000000
Period2=12.00000000
Period3=35.00000000
Dev_Step_1=5,3
Dev_Step_2=5,3
Dev_Step_3=5,3
Symbol_1_Kod=159
Symbol_2_Kod=159
Symbol_3_Kod=82
_____=
Box.Alerts=0
Email.Alerts=0
Sound.Alerts=1
Alert.Lv1=0
Alert.Lv2=1
Alert.Lv3=1


//---------------------------------------------------------------------------
// Initialization
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define parameters
IndicatorShortName('THVSDXTZPivots');
SetOutputWindow(ow_ChartWindow);
extern int Local__HrsServerTzFromGMT = 0;
extern int Destination__HrsNewTZfromGMT = 0;
extern int Show_1Daily_2FibonacciPivots = 2;
extern bool FullScreenLines = FALSE;
extern bool __withMarginPrices = TRUE;
extern int MoveLabels_LR_DecrIncr = 0;
extern color R5_Color = FireBrick;
extern int R5_LineStyle_01234 = 2;
extern int R5_SolidLineThickness = 1;
extern color R4_Color = FireBrick;
extern int R4_LineStyle_01234 = 2;
extern int R4_SolidLineThickness = 1;
extern color R3_Color = FireBrick;
extern int R3_LineStyle_01234 = 2;
extern int R3_SolidLineThickness = 1;
extern color R2_Color = C'0x9B,0x1E,0x1E';
extern int R2_LineStyle_01234 = 2;
extern int R2_SolidLineThickness = 1;
extern color R1_Color = C'0x7D,0x17,0x17';
extern int R1_LineStyle_01234 = 2;
extern int R1_SolidLineThickness = 1;
extern color CentralPivotColor = C'0x00,0x62,0x62';
extern int CentralPivotLineStyle_01234 = 0;
extern int CentralPivotSolidLineThickness = 1;
extern color S1_Color = DarkGreen;
extern int S1_LineStyle_01234 = 2;
extern int S1_SolidLineThickness = 1;
extern color S2_Color = Green;
extern int S2_LineStyle_01234 = 2;
extern int S2_SolidLineThickness = 1;
extern color S3_Color = ForestGreen;
extern int S3_LineStyle_01234 = 2;
extern int S3_SolidLineThickness = 1;
extern color S4_Color = ForestGreen;
extern int S4_LineStyle_01234 = 2;
extern int S4_SolidLineThickness = 1;
extern color S5_Color = ForestGreen;
extern int S5_LineStyle_01234 = 2;
extern int S5_SolidLineThickness = 1;
extern color MidPivotsColor = C'0x62,0x62,0x00';
extern int MidPivotsLineStyle_01234 = 2;
extern int MidPivotsLineThickness = 1;
extern bool ShowMidPivots = TRUE;
extern color QtrPivotsColor = SaddleBrown;
extern int QtrPivotsLineStyle_01234 = 2;
extern int QtrPivotsLineThickness = 1;
extern bool ShowQtrPivots = FALSE;
extern color YesterdayHighLowColor = C'0x49,0x49,0x49';
extern int HighLowLineStyle_01234 = 2;
extern int HighLowSolidLineThickness = 1;
extern bool ShowYesterdayHighLow = TRUE;
extern color TodayOpenColor = C'0x71,0x00,0x71';
extern int TodayOpenLineStyle_01234 = 2;
extern int TodayOpenSolidLineThickness = 1;
extern bool ShowTodayOpen = TRUE;
extern color CamarillaColor = Orchid;
extern int CamarillaLineStyle_01234 = 2;
extern int CamarillaSolidLineThickness = 1;
extern bool ShowCamarilla = FALSE;
extern color PeriodSeparatorLinesColor = C'0x62,0x62,0x00';
extern int SeparatorLinesStyle_01234 = 0;
extern int SeparatorLinesThickness = 1;
extern bool ShowPeriodSeparatorLines = TRUE;
extern color PeriodSeparatorsLabelsColor = C'0x62,0x62,0x00';
extern int PlaceAt_TopBot_12_OfChart = 2;
extern int SeparatorLabelFontSize = 9;
extern int S_Label_Norm_Bold_Black_123 = 2;
extern bool ShowPeriodSeparatorLabels = TRUE;
extern color PivotLinesLabelColor = C'0x62,0x62,0x00';
extern int LineLabelsFontSize = 9;
extern int L_Label_Norm_Bold_Black_123 = 1;
extern bool LineLabelsIncludePrice = TRUE;
extern int Relabeler_Adjustment = 10;
extern bool Show_Relabeler_Comment = FALSE;
extern bool Show_Data_Comment = FALSE;
int gi_392;
int gi_396 = 0;
int gi_400 = 0;

procedure Init; stdcall;
begin
// define parameters
IndicatorShortName('AMA optimized');
SetOutputWindow(ow_ChartWindow);
extern int PriceType = 0;
extern int AMA_Trend_Type = 1;
double gda_120[];
double gda_124[];
double gda_128[];
double gda_132[];
double gda_136[];
double gda_140[];
double gda_144[];
bool gi_172 = FALSE;
// define parameters
IndicatorShortName('NonLagMA');
SetOutputWindow(ow_ChartWindow);
double gda_116[];
double gda_120[];
double gda_124[];
double gda_128[];
double gda_132[];
double gda_136[];
double gda_140[];
int gi_144;
int gi_148;
int gi_152;
int gi_156 = 4;
double gd_160;
double gd_168;
double gd_176;
double gd_192;
double gd_200;
double gd_208 = 3.1415926535;
bool gi_216 = FALSE;
bool gi_220 = FALSE;
// define parameters
IndicatorShortName('#4X 3 Semafor Alert');
SetOutputWindow(ow_ChartWindow);
string gs_168 = "stage one level high.wav";
string gs_176 = "stage one level low.wav";
string gs_184 = "stage two level high.wav";
string gs_192 = "stage two level low.wav";
string gs_200 = "stage three level high.wav";
string gs_208 = "stage three level low.wav";
double gda_216[];
double gda_220[];
double gda_224[];
double gda_228[];
double gda_232[];
double gda_236[];
int gi_240;
int gi_244;
int gi_248;
int gi_252;
int gi_256;
int gi_260;
int gi_264;
int gi_268;
int gi_272;
string gs_276;
string gs_284;
string gs_292;
int gi_300;
int gi_304;
int gi_320 = -1;
int gi_324 = 65535;
end;
// IndicatorBuffers(6);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, gda_116);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, gda_120);
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, gda_124);
SetIndexBuffer(3, gda_128);
SetIndexBuffer(4, gda_132);
SetIndexBuffer(5, gda_136);
IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
string ls_0 = "MOACX NonLagMA (" + Length + ")";
IndicatorShortName(ls_0);
SetIndexLabel(0, "NonLagMA");
SetIndexLabel(1, "Up");
SetIndexLabel(2, "Dn");
SetIndexShift(0, Displace);
SetIndexShift(1, Displace);
SetIndexShift(2, Displace);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexDrawBegin(0, Length * gi_156 + Length + 1);
SetIndexDrawBegin(1, Length * gi_156 + Length + 1);
SetIndexDrawBegin(2, Length * gi_156 + Length + 1);
if (Period1 > 0.0)
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, Symbol_1_Kod);
SetIndexBuffer(0, gda_216);
SetIndexEmptyValue(0, 0.0);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, Symbol_1_Kod);
SetIndexBuffer(1, gda_220);
SetIndexEmptyValue(1, 0.0);

if (Period2 > 0.0)
SetIndexStyle(2, DRAW_ARROW);
SetIndexArrow(2, Symbol_2_Kod);
SetIndexBuffer(2, gda_224);
SetIndexEmptyValue(2, 0.0);
SetIndexStyle(3, DRAW_ARROW);
SetIndexArrow(3, Symbol_2_Kod);
SetIndexBuffer(3, gda_228);
SetIndexEmptyValue(3, 0.0);

if (Period3 > 0.0)
SetIndexStyle(4, DRAW_ARROW);
SetIndexArrow(4, Symbol_3_Kod);
SetIndexBuffer(4, gda_232);
SetIndexEmptyValue(4, 0.0);
SetIndexStyle(5, DRAW_ARROW);
SetIndexArrow(5, Symbol_3_Kod);
SetIndexBuffer(5, gda_236);
SetIndexEmptyValue(5, 0.0);


IndicatorBuffers(11);

SetIndexBuffer(0, R3);
SetIndexStyle(0, ds_Line, psSolid, 1, clGreen);
SetIndexLabel(0, 'R3');

SetIndexBuffer(1, R2);
SetIndexStyle(1, ds_Line, psDashDot, 1, clBlue);
SetIndexLabel(1, 'R2');

SetIndexBuffer(2, R1);
SetIndexStyle(2, ds_Line, psDot, 1, clRed);
SetIndexLabel(2, 'R1');

SetIndexBuffer(3, PP);
SetIndexStyle(3, ds_Line, psDot, 1, clMaroon);
SetIndexLabel(3, 'PP');

SetIndexBuffer(4, S1);
SetIndexStyle(4, ds_Line, psDot, 1, clRed);
SetIndexLabel(4, 'S1');

SetIndexBuffer(5, S2);
SetIndexStyle(5, ds_Line, psDashDot, 1, clBlue);
SetIndexLabel(5, 'S2');

SetIndexBuffer(6, S3);
SetIndexStyle(6, ds_Line, psSolid, 1, clGreen);
SetIndexLabel(6, 'S3');

SetIndexBuffer(7, M1);
SetIndexStyle(7, ds_Line, psDot, 1, clGray);
SetIndexLabel(7, 'M1');

SetIndexBuffer(8, M2);
SetIndexStyle(8, ds_Line, psDot, 1, clGray);
SetIndexLabel(8, 'M2');

SetIndexBuffer(9, M3);
SetIndexStyle(9, ds_Line, psDot, 1, clGray);
SetIndexLabel(9, 'M3');

SetIndexBuffer(10, M4);
SetIndexStyle(10, ds_Line, psDot, 1, clGray);
SetIndexLabel(10, 'M4');
end;

//---------------------------------------------------------------------------
// Deinitialization
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
//
end;
// calculate THVSDXTZPivots
int init()
if (Ask > 10.0)
gi_392 = 2;
else gi_392 = 4;
Print("Period= ", Period());
return (0);

// calculate AMA optimized
double Price(int ai_0)
double ld_4;
switch (PriceType)
case 1:
ld_4 = Open[ai_0];
break;
case 2:
ld_4 = High[ai_0];
break;
case 3:
ld_4 = Low[ai_0];
break;
case 4:
ld_4 = (High[ai_0] + Low[ai_0]) / 2.0;
break;
case 5:
ld_4 = (High[ai_0] + Low[ai_0] + Close[ai_0]) / 3.0;
break;
case 6:
ld_4 = (High[ai_0] + Low[ai_0] + 2.0 * Close[ai_0]) / 4.0;
break;
default:
ld_4 = Close[ai_0];

return (ld_4);


// calculate NonLagMA
gd_160 = 3.0 * gd_208;
gi_148 = Length - 1;
gi_152 = Length * gi_156 + gi_148;
ArrayResize(gda_140, gi_152);
gd_192 = 0;
for (gi_144 = 0; gi_144 < gi_152 - 1; gi_144++)
if (gi_144 <= gi_148 - 1)
gd_176 = 1.0 * gi_144 / (gi_148 - 1);
else gd_176 = (gi_144 - gi_148 + 1) * (2.0 * gi_156 - 1.0) / (gi_156 * Length - 1.0) + 1.0;
gd_168 = MathCos(gd_208 * gd_176);
gd_200 = 1.0 / (gd_160 * gd_176 + 1.0);
if (gd_176 <= 0.5) gd_200 = 1;
gda_140[gi_144] = gd_200 * gd_168;
gd_192 += gda_140[gi_144];

return (0);
// calculate #4X 3 Semafor Alert

int li_0 = 0;
int li_4 = 0;
int li_12 = 0;
if (IntFromStr(Dev_Step_1, li_12, lia_8) == 1)
gi_256 = lia_8[1];
gi_252 = lia_8[0];

if (IntFromStr(Dev_Step_2, li_12, lia_8) == 1)
gi_264 = lia_8[1];
gi_260 = lia_8[0];

if (IntFromStr(Dev_Step_3, li_12, lia_8) == 1)
gi_272 = lia_8[1];
gi_268 = lia_8[0];

return (0);




end;
end;

exports

Init, Done, Calculate;

begin

end.

the problem is there are some eror says"Expected : but anditifier from line local till show 1 adily

and some symbol =, AMA, nFast, and Alert . only, please explain and how di i solve this?
Thank you

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#14 Postby FT Support » Tue Apr 26, 2011 10:28 am

Hello, your code is totally wrong because you simply copied and pasted MQL code into Delphi.

for example in this code:

Code: Select all

procedure Init; stdcall;
begin
// define parameters
IndicatorShortName('THVSDXTZPivots');
SetOutputWindow(ow_ChartWindow);
extern int Local__HrsServerTzFromGMT = 0;

line

Code: Select all

extern int Local__HrsServerTzFromGMT = 0;


is not correct at all.

1) in Delphi there is no "extern" keyword, please use RegOption method instead

2) there is no "int" data type in Delphi, use "integer" instead

it should look like:

Code: Select all

...
procedure Init; stdcall;
begin
// define parameters
IndicatorShortName('THVSDXTZPivots');
SetOutputWindow(ow_ChartWindow);
RegOption('put name of your variable here', ot_Integer, Local__HrsServerTzFromGMT);
Local__HrsServerTzFromGMT := 0;
...


please read our API description: Forex Tester -> Help -> Indicators API
also read more information about Delphi syntax over the internet.
Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

I dont have any idea eror"if"

#15 Postby hjabu » Mon May 02, 2011 1:00 pm

I have created another code , and almost done but i have no idea, on eror
" IF ", Please anyone has answer how to resolve this, my code as shown below,:

//---------------------------------------------------------------------------
// THV SDX-TzPivots_v4.9
//---------------------------------------------------------------------------

library THVSDXTzPivots;

{ #property copyright "Copyright Shimodax"
#property link "http://www.strategybuilderfx.com" }

uses
SysUtils,
classes,
graphics,
math,
DateUtils,
IndicatorInterfaceUnit,
TechnicalFunctions in 'TechnicalFunctions.pas';


var
Local__HrsServerTzFromGMT: integer = 0;
Destination__HrsNewTZfromGMT: integer = 0;
Show_1Daily_2FibonacciPivots: integer = 2;
FullScreenLines: boolean = FALSE;
__withMarginPrices: boolean = TRUE;
MoveLabels_LR_DecrIncr: integer = 0;
Relabeler_Adjustment: integer = 10;
Show_Relabeler_Comment: boolean = FALSE;
Show_Data_Comment: boolean = FALSE;
//---------------------------------------------------------------------------
// Initialization
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define parameters
IndicatorShortName('THVSDXTzPivots');
SetOutputWindow(ow_ChartWindow);

RegOption('Pivot Type', ot_EnumType, PivotType);
AddOptionValue('Pivot Type', 'Daily');

RegOption('YesterdayHighLowColor',ot_EnumType,yesterdayHighColor);
AddOptionValue('HighLowLineType','HighLowLineStyle_01234');
AddOptionValue('HighLowSolidLineType','HighLowSolidLineThickness');
AddOtionValue('ShowYesterdayType','ShowYesterdayHighLow');

RegOption('TodayOpenColor',ot_EnumType,TodayOpenColor);
AddOptionValue('TodayOpenLineType','OpenLineStyle_01234');
AddOptionValue('TodayOpenType','TodayOpenSolidLineThickness');
AddOptionValue('ShowTodayType','ShowTodayOpen');

RegOption('CamarillaColor',ot_EnumType,CamarillaColor);
AddOptionValue('CamarillaLineType','CamarillaLineStyle_01234');
AddOptionValue('CamarillaSolidLineType','CamarillaSolidLineThickness');
AddOptionValue('ShowCamarillaType','ShowCamarilla');

RegOption('PeriodSeparatorLinesColor',ot_EnumType,PeriodSeparatorLinesColor);
AddOptionValue('SeparatorLinesType','SeparatorLinesStyle_01234');
AddOptionValue('SeparatorLinesType','SeparatorLinesThickness');
AddOptionValue('ShowPeriodType','ShowPeriodSeparatorLines');

RegOption('PeriodSeparatorsLabelsColor',ot_EnumType,PeriodSeparatorsLabelsColor);
AddOptionValue('PlaceAtType','PlaceAt_TopBot_12_OfChart');
AddOptionValue('SeparatorLabelType','SeparatorLabelFontSize');
AddOptionValue('_Label_Norm_Type','_Label_Norm_Bold_Black_123');
AddOptionValue('ShowPeriodType','ShowPeriodSeparatorLabels');

RegOption('PivotLinesLabelColor',ot_EnumType,PivotLinesLabelColor);
AddOptionValue('LineLabelsType','LineLabelsFontSize');
AddOptionValue('L_Label_Type','L_Label_Norm_Bold_Black_123T');
AddOptionValue('LineLabelsType','LineLabelsIncludePrice');

// create index buffers
MidPivot := CreateIndexBuffer;
QtrPivot := CreateIndexBuffer;
R1 := CreateIndexBuffer;
R2 := CreateIndexBuffer;
R3 := CreateIndexBuffer;
R4 := CreateIndexBuffer;
R5 := CreateIndexBuffer;
S1 := CreateIndexBuffer;
S2 := CreateIndexBuffer;
S3 := CreateIndexBuffer;
S4 := CreateIndexBuffer;
S5 := CreateIndexBuffer;
CentralPivot := CreateIndexBuffer;
YesterdayHighLowColor := CreateIndexBuffer;
TodayOpenColor := CreateIndexBuffer;
Camarilla := CreateIndexBuffer;
PeriodSeparatorLines := CreateIndexBuffer;
PivotLinesLabel := CreateIndexBuffer;


IndicatorBuffers(18);

SetIndexBuffer(0, R5);
SetIndexStyle(0, ds_Line, psSolid, 1, clFireBrick);
SetIndexLabel(0, 'R5');

SetIndexBuffer(0, R4);
SetIndexStyle(0, ds_Line, psSolid, 1, clFireBrick);
SetIndexLabel(0, 'R4');

SetIndexBuffer(0, R3);
SetIndexStyle(0, ds_Line, psSolid, 1, clFireBrick);
SetIndexLabel(0, 'R3');

SetIndexBuffer(0, R2);
SetIndexStyle(0, ds_Line, psSolid, 1, clFireBrick);
SetIndexLabel(0, 'R2');

SetIndexBuffer(0, R1);
SetIndexStyle(0, ds_Line, psSolid, 1, clFireBrick);
SetIndexLabel(0, 'R1');

SetIndexBuffer(0, CentralPivot);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x00_0x62_0x62);
SetIndexLabel(0, 'CentralPivot');

SetIndexBuffer(0, MidPivot);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x62_0X62_0X00);
SetIndexLabel(0, 'MidPivot');

SetIndexBuffer(0, QtrP);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x62_0X62_0X00);
SetIndexLabel(0, 'QtrP')

SetIndexBuffer(0, S1);
SetIndexStyle(0, ds_Line, psSolid, 1, clDarkGreen);
SetIndexLabel(0, 'S1');

SetIndexBuffer(0, S2);
SetIndexStyle(0, ds_Line, psSolid, 1, clGreen);
SetIndexLabel(0, 'S2');

SetIndexBuffer(0, S3);
SetIndexStyle(0, ds_Line, psSolid, 1, clForestGreen);
SetIndexLabel(0, 'S3');

SetIndexBuffer(0, S4);
SetIndexStyle(0, ds_Line, psSolid, 1, clForestGreen);
SetIndexLabel(0, 'S4');

SetIndexBuffer(0, S5);
SetIndexStyle(0, ds_Line, psSolid, 1, clForestGreen);
SetIndexLabel(0, 'S5');

SetIndexBuffer(0, CentralPivot);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x00_0x62_0x62);
SetIndexLabel(0, 'CentralPivot');

SetIndexBuffer(0, YesterdayHighLow);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x49_0x49_0x49);
SetIndexLabel(0, 'YesterdayHighLow');

SetIndexBuffer(0, TodayOpen);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x71_0x00_0x71);
SetIndexLabel(0, 'TodayOpen');

SetIndexBuffer(0, Camarilla);
SetIndexStyle(0, ds_Line, psSolid, 1, clOrchid);
SetIndexLabel(0, 'Camarilla');

SetIndexBuffer(0, PeriodSeparatorLines);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x62_0x62_0x00);
SetIndexLabel(0, 'PeriodSeparatorLines');


SetIndexBuffer(0, PivotLinesLabel);
SetIndexStyle(0, ds_Line, psSolid, 1, clC0x62_0x62_0x00);
SetIndexLabel(0, 'PivotLinesLabel');
end;

//---------------------------------------------------------------------------
// Deinitialization
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
//
end;

//---------------------------------------------------------------------------
// Calculate bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
var

integer: gi_392;
integer: gi_396 = 0;
integer: gi_400 = 0;


integer: init()
if (Ask > 10.0) EROR on EXPECTED on "IF " words
gi_392 = 2;
integer: gi_392 = 4;
Print("Period= ", Period());

exports

Init, Done, Calculate;

begin

end.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#16 Postby FT Support » Thu May 05, 2011 5:23 am

Hello,

This code is incorrect:

Code: Select all

procedure Calculate(index: integer); stdcall;
var

integer: gi_392;
integer: gi_396 = 0;
integer: gi_400 = 0;


integer: init()
if (Ask > 10.0) EROR on EXPECTED on "IF " words
gi_392 = 2;
integer: gi_392 = 4;
Print("Period= ", Period());


1) each procedure and function has to have "begin .. end;" block, I cannot see such block in your "Calculate" procedure.

2) what is "integer: init()" ? why you need that?

3) in Print function you cannot use "," use "+" instead and convert all operands to string type
so this is incorrect:

Code: Select all

Print("Period= ", Period());


this is correct:

Code: Select all

Print("Period= " + IntToStr(Period()));


4) In delphi "if" block should look like this: "if (...) then ... " i cannot see "then" in your code.
Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

To convert into symbol instead ZZ line bar

#17 Postby hjabu » Sun May 08, 2011 6:11 pm

Which part of code could i change into any symbol i want or i want to get Dot symbol and Arrow type, please specify which part of code do i have to change it ?

the indictor as below:

library wlxZZ_DT;

{ ZigZag îòñëåæèâàåò è ñîåäèíÿåò ìåæäó ñîáîé êðàéíèå òî÷êè ãðàôèêà
îòñòîÿùèå äðóã îò äðóãà íå ìåíåå ÷åì íà çàäàííûé ïðîöåíò ïî øêàëå öåíû.

Depth ýòî ìèíèìàëüíîå êîë-âî áàðîâ, íà êîòîðîì íå áóäåò âòîðîãî ìàêñèìóìà
(ìèíèìóìà) ìåíüøå (áîëüøå) íà Deviation ïèïñîâ, ÷åì ïðåäûäóùåãî, òî åñòü
ðàñõîäèòüñÿ ZigZag ìîæåò âñåãäà, à ñõîäèòñÿ (ëèáî ñäâèíóòüñÿ öåëèêîì) áîëüøå,
÷åì íà Deviation, ZigZag ìîæåò òîëüêî ïîñëå Depth áàðîâ.
Backstep ýòî ìèíèìàëüíîå êîëè÷åñòâî áàðîâ ìåæäó ìàêñèìóìàìè (ìèíèìóìàìè).

Ïîñëå òîãî, êàê ZigZag çàôèêñèðîâàë íèæíþþ òî÷êó, îí íà÷èíàåò èñêàòü òî÷êó
ðàçâîðîòà äî òåõ ïîð, ïîêà îòêàò âíèç îò ìàêñèìàëüíîãî çíà÷åíèÿ íå ïðåâûñèò
ïàðàìåòðà. Êàê òîëüêî îòêàò âíèç ïðåâûñèò ïàðàìåòð, âòîðàÿ (â íàøåì ñëó÷àå âåðõíÿÿ
òî÷êà ñ÷èòàåòñÿ çàôèêñèðîâàííîé) è ZigZag íà÷èíàåò èñêàòü òðåòüþ (â íàøåì ñëó÷àå
íèæíþþ òî÷êó) è òàê äàëåå.

Çà îñíîâó ðåàëèçàöèè âçÿò èíäèêàòîð ÇèãÇàã â ìåòàòðåéäåðå.

}

uses
SysUtils,
classes,
graphics,
windows,
IndicatorInterfaceUnit,
TechnicalFunctions in 'TechnicalFunctions.pas';

var
Depth :integer;

// èíäåêñíûå áóôåðà
ZZ : TIndexBuffer;
zzH: TIndexBuffer;
zzL: TIndexBuffer;
zzHPos: TIndexBuffer;
zzLPos: TIndexBuffer;


//---------------------------------------------------------------------------
// Ïðîöåäóðà èíèöèàëèçàöèè
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
IndicatorShortName('wlxZZ-DT');
SetOutputWindow(ow_ChartWindow);

// çàðåãèñòðèðîâàòü ïàðàìåòðû
AddSeparator('Common');

RegOption('Depth', ot_Integer, Depth);
SetOptionRange('Depth', 1, MaxInt);
Depth := 12;

// ñîçäàòü èíäåêñíûå áóôåðà
zz := CreateIndexBuffer;
zzH := CreateIndexBuffer;
zzL := CreateIndexBuffer;
zzHPos := CreateIndexBuffer;
zzLPos := CreateIndexBuffer;

IndicatorBuffers(1);

SetIndexBuffer(0, zz);
SetIndexStyle (0, ds_Section, psSolid, 2, clYellow);
SetEmptyValue(0.0);
end;

//---------------------------------------------------------------------------
// Ïðîöåäóðà äåèíèöèàëèçàöèè
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin

end;

//---------------------------------------------------------------------------
// Ïðîöåäóðà ðàññ÷åòà çàäàííîãî áàðà
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
var
cnt, i, shift, pos, lasthighpos, lastlowpos, curhighpos, curlowpos: integer;
curlow, curhigh, lasthigh, lastlow: double;
cmin, cmax: double;

//------------------------------------------------------------------
function LowestPos(sh: integer; cnt: integer): integer;
var
lmin: double;
j, clow: integer;
begin
lmin := Low(sh);
clow := sh;
for j:=sh to sh+cnt do
if lmin > Low(j) then
begin
lmin := Low(j);
clow := j;
end;
result := clow;
end;

//------------------------------------------------------------------
function HighestPos(sh: integer; cnt: integer): integer;
var
lmax: double;
j, chigh: integer;
begin
lmax := High(sh);
chigh := sh;
for j:=sh to sh+cnt do
if lmax < High(j) then
begin
lmax := High(j);
chigh := j;
end;
result := chigh;
end;

begin
if (index + depth >= Bars) or (index <> 0) then
exit;

cnt := 0;
pos := Bars - 1;
for shift:=0 to Bars - 1 do
begin
if zz[shift] <> 0 then
inc(cnt);
if cnt = 2 then
begin
pos := shift - 1;
break;
end;
end;

if pos = Bars - 1 then
begin
LastHighPos := pos;
LastLowPos := pos;
end
else
begin
LastHighPos := round(zzHPos[pos + 1]);
LastLowPos := round(zzLPos[pos + 1]);
end;

LastLow := Low(LastLowPos);
LastHigh := High(LastHighPos);

for shift:=pos downto 0 do
begin
zz[shift] := 0;
zzH[shift] := 0;
zzL[shift] := 0;
CurLowPos := LowestPos(shift, depth);
CurLow := Low(CurLowPos);
CurHighPos := HighestPos(shift, depth);
CurHigh := High(CurHighPos);

if (CurLow >= LastLow) then
LastLow := CurLow
else
begin
if (LastHighPos > CurLowPos) then
begin
zzL[CurLowPos] := CurLow;
cmin := 100000;
pos := LastHighPos;
for i:=LastHighPos downto CurLowPos do
begin
if (zzL[i] = 0) then continue;
if (zzL[i] < cmin) then
begin
cmin := zzL[i];
pos := i;
end;
zz[i] := 0;
end;
zz[pos] := cmin;
end;
LastLowPos := CurLowPos;
LastLow := CurLow;
end;

if (CurHigh <= LastHigh) then
LastHigh := CurHigh
else
begin
if (LastLowPos > CurHighPos) then
begin
zzH[CurHighPos] := CurHigh;
cmax := -100000;
pos := LastLowPos;
for i:=LastLowPos downto CurHighPos do
begin
if (zzH[i] = 0) then continue;
if (zzH[i] > cmax) then
begin
cmax := zzH[i];
pos := i;
end;
zz[i] := 0;
end;
zz[pos] := cmax;
end;
LastHighPos := CurHighPos;
LastHigh := CurHigh;
end;

zzHPos[shift] := LastHighPos;
zzLPos[shift] := LastLowPos;
end; {for}
end;



exports

// ýòè ïðîöåäóðû äîëæíû áûòü äåêëàðèðîâàíû êàê âíåøíèå

Init, Done, Calculate;



end.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#18 Postby FT Support » Tue May 10, 2011 2:09 pm

Sorry but I cannot understand your question, please add more details, what do you want to do?
Check our other product here:
http://www.forexcopier.com

hjabu
Posts: 30
Joined: Fri Aug 21, 2009 9:30 am
Contact:

How do i change the zigzag line into a dot or arrow symbol

#19 Postby hjabu » Sun May 15, 2011 2:43 pm

My question is about ZZ indicator , i want to change it into a symbol instead it appear a zizag line on the screen FT,

Could you please tell me which code i have to change it in delphi tool?

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#20 Postby FT Support » Wed May 18, 2011 2:24 pm

Try to change buffer style to from ds_Section to ds_Symbol
see Fractals indicator code as an example.
Check our other product here:
http://www.forexcopier.com

Steven Smith
Posts: 7
Joined: Thu Jan 17, 2013 1:50 am
Location: USA

#21 Postby Steven Smith » Thu Jan 17, 2013 2:09 am

Sorry guys i don't have too much of a coding experience.
Can you please advice on how exactly I can do the above.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#22 Postby FT Support » Thu Jan 17, 2013 12:36 pm

Did you try ds_Symbol buffer style?
Check our other product here:
http://www.forexcopier.com

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

zzFractals

#23 Postby KelvinHand » Sun Jul 21, 2013 2:24 am

hjabu wrote:My question is about ZZ indicator , i want to change it into a symbol instead it appear a zizag line on the screen FT,

Could you please tell me which code i have to change it in delphi tool?


This ZigZag is a give sample from FT.
I do Minor Modification.
Hope this work for you.

I no longer using delphi, so you can figure out and reverse back to delphi.

//--- C++ sample Code for your view only ---
//-- You will compile with errors
//------------------------------------------------

Code: Select all

//---------------------------------------------------------------------------
// Zig Zag indicator
//---------------------------------------------------------------------------
#include <ft3.h>   

// External variables
int      Depth=12;

// Buffers
_double   zz,  zzH,  zzL,  zzHPos,  zzLPos, zzFracHi, zzFracLo;


//-- KH: added
int zzSymHi = 217;
int zzSymLo = 218;

//-- KH: added
FT2DLL  OnParamsChange()
{
   SetIndexSymbol(0, zzSymHi,0, 10);
   SetIndexSymbol(1, zzSymLo,0, -10);
}



//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
FT2DLL   Init()
{
  // define properties
  IndicatorShortName("zzFractals");
  SetOutputWindow(indicator_chart_window);

  // register options
  AddSeparator("Coded:KelvinHand");

  RegOption("Depth", ot_Integer, &Depth);
  SetOptionRange("Depth", 1, MaxInt);
 
  //-- KH: added
  RegOption("zzFractHi", ot_Integer, &zzSymHi);
  SetOptionRange("zzFractHi", 1, 255);
 
  //-- KH: added
  RegOption("zzFractLo", ot_Integer, &zzSymLo);
  SetOptionRange("zzFractLo", 1, 255);

  zz  = CreateIndexBuffer();
  zzH = CreateIndexBuffer();
  zzL = CreateIndexBuffer();
  zzHPos = CreateIndexBuffer();
  zzLPos = CreateIndexBuffer();
 
  //-- KH: added
  zzFracHi = CreateIndexBuffer();
  zzFracLo = CreateIndexBuffer();

 
  IndicatorBuffers(2);

  //-- KH: added
  SetIndexBuffer(0, zzFracHi);
  SetIndexLabel (0, "zzSymHi");
  SetIndexSymbol(0, zzSymHi,0, 10);

  //-- KH: added
  SetIndexBuffer(1, zzFracLo);
  SetIndexSymbol(1, zzSymLo,0, -10);
  SetIndexLabel (1, "zzSymLo");

  //-- KH: added
  SetIndexStyle (0, DRAW_ARROW, STYLE_SOLID, 1, Lime);
  SetIndexStyle (1, DRAW_ARROW, STYLE_SOLID, 1, Red);
 
  SetEmptyValue(0.0);

}


//---------------------------------------------------------------------------
// Deinitialize indicator
//---------------------------------------------------------------------------
FT2DLL   Done()
{

}






//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
FT2DLL   Calculate(int index)
{
 
  if ((index + Depth >= Bars()) || (index != 0)) return;

  int i, shift, LastHighPos, LastLowPos, CurHighPos, CurLowPos;
  double CurLow, CurHigh, LastHigh, LastLow;
  double cmin, cmax;

  int cnt = 0;
  int nBars = Bars();
  int pos = Bars() - 1;

  for (shift=0;  shift<Bars(); shift++)
  {
     if (zz[shift] != 0) cnt++;

      if (cnt == 2)
     {
          pos = shift - 1;
          break;
     }

  }

  if (pos == Bars() - 1)
  {
      LastHighPos = pos;
      LastLowPos  = pos;
  }
  else
  {
   
      LastHighPos = MathRound(zzHPos[pos + 1]);
      LastLowPos  = MathRound(zzLPos[pos + 1]);
  }

  LastLow  = Low(LastLowPos);
  LastHigh = High(LastHighPos);


     for (shift=pos;  shift>=0; shift--)
     {
      zz[shift]  = 0;
      zzH[shift] = 0;
      zzL[shift] = 0;

      CurLowPos = iLowest(Symbol(), Timeframe(), MODE_LOW, Depth, shift);
      CurLow  = Low(CurLowPos);
      CurHighPos= iHighest(Symbol(), Timeframe(), MODE_HIGH, Depth, shift);
      CurHigh = High(CurHighPos);

      if (CurLow >= LastLow)
         LastLow = CurLow;
      else
      {
          if (LastHighPos > CurLowPos)
        {
              zzL[CurLowPos] = CurLow;
              cmin = 100000;
              pos = LastHighPos;
              for( i=LastHighPos; i>=CurLowPos; i--)
           {
                  if (zzL[i] == 0) continue;
                  if (zzL[i] < cmin)
              {
                      cmin = zzL[i];
                      pos = i;
              }
                  zz[i] = 0;
              zzFracLo[i]= 0;  //-- KH: added
           }
             zz[pos] = cmin;
          zzFracLo[pos]= cmin;   ////-- KH: added
         
        }
          LastLowPos = CurLowPos;
          LastLow = CurLow;
      }

      if (CurHigh <= LastHigh)
        LastHigh = CurHigh;
      else
     {
          if (LastLowPos > CurHighPos)
        {
              zzH[CurHighPos] = CurHigh;
              cmax = -100000;
              pos = LastLowPos;
              for(i=LastLowPos;  i>=CurHighPos; i--)
           {
                  if (zzH[i] == 0) continue;
                  if (zzH[i] > cmax)
              {
                      cmax = zzH[i];
                      pos = i;
              }
                  zz[i] = 0;
              zzFracHi[i]= 0;   //-- KH: added
           }
              zz[pos] = cmax;
           zzFracHi[pos]= cmax;  //-- KH: added
          
        }
          LastHighPos = CurHighPos;
          LastHigh = CurHigh;
     }

      zzHPos[shift] = LastHighPos;
      zzLPos[shift] = LastLowPos;
     } //for

 
 
}
Attachments
zzFractals.dll
(13.5 KiB) Downloaded 1101 times

teamx123
Posts: 1
Joined: Thu Aug 25, 2016 3:40 am

Re: building using Delphi 2010

#24 Postby teamx123 » Wed Aug 31, 2016 2:04 am

Could you please kindly help out with this issue?


Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 27 guests