Благодарю за помощь.
Код: Выделить всё
//--------------------------------------------------------------------------
// Objects test - Example how to work with objects from Script
//--------------------------------------------------------------------------
library ObjectsTest;
//-------------------------------------------
// Initialize Script
//-------------------------------------------
uses
ScriptInterfaceUnit,
TechnicalFunctions,
graphics;
procedure Init; stdcall;
begin
ScriptShortName('ObjectsTest');
ScriptDescription('Objects'' interface test');
end;
//-------------------------------------------
// Deinitialize Script
//-------------------------------------------
procedure Done; stdcall;
begin
end;
//-------------------------------------------
// Execute Script
//-------------------------------------------
procedure Execute; stdcall;
var
i: integer;
const
names: array[0..8] of string = ('Line0', 'Line1', 'Line2', 'Line3', 'Fibo1',
'Fibo2', 'Fibo3', 'Fibo4', 'Text1');
begin
if Bars < 80 then
exit;
// create vertical line
if not(ObjectExists(names[0])) then
begin
ObjectCreate(names[0], obj_VLine, 0,
ScriptInterfaceUnit.Time(0), 0);
ObjectSet(names[0], OBJPROP_STYLE, integer(psDot));
ObjectSet(names[0], OBJPROP_COLOR, clYellow);
ObjectSet(names[0], OBJPROP_WIDTH, 1);
end;
// create horizontal line
if not(ObjectExists(names[1])) then
ObjectCreate(names[1], obj_HLine, 0, 0, Close(0));
// create trend line
if not(ObjectExists(names[2])) then
ObjectCreate(names[2], obj_TrendLine, 0,
ScriptInterfaceUnit.Time(10), Close(10),
ScriptInterfaceUnit.Time(0), Close(0));
// create ray
if not(ObjectExists(names[3])) then
ObjectCreate(names[3], obj_Ray, 0,
ScriptInterfaceUnit.Time(10), Open(10),
ScriptInterfaceUnit.Time(0), Open(0));
// create fibo retracement
if not(ObjectExists(names[4])) then
begin
ObjectCreate(names[4], obj_FiboRetracement, 0,
ScriptInterfaceUnit.Time(40), Close(40),
ScriptInterfaceUnit.Time(10), Close(10));
ObjectSet(names[4], OBJPROP_FIBOCLOSEDENDS, 1);
ObjectSet(names[4], OBJPROP_FIBOSHOWPRICE, 0);
ObjectSet(names[4], OBJPROP_FIBOENDWIDTH, 40);
// define 3 levels
ObjectSet(names[4], OBJPROP_FIBOLEVELS, 3);
for i:=0 to 2 do
begin
ObjectSet(names[4], OBJPROP_FIBOLEVELN, i);
ObjectSet(names[4], OBJPROP_LEVELVALUE, i*50);
ObjectSet(names[4], OBJPROP_LEVELCOLOR, clBlue);
ObjectSet(names[4], OBJPROP_LEVELSTYLE, integer(psDot));
ObjectSet(names[4], OBJPROP_LEVELWIDTH, 1);
end;
end;
// create fibo fan
if not(ObjectExists(names[5])) then
begin
ObjectCreate(names[5], obj_FiboFan, 0,
ScriptInterfaceUnit.Time(80), Close(80),
ScriptInterfaceUnit.Time(50), Close(50));
// define 3 levels
ObjectSet(names[5], OBJPROP_FIBOLEVELS, 3);
for i:=0 to 2 do
begin
ObjectSet(names[5], OBJPROP_FIBOLEVELN, i);
ObjectSet(names[5], OBJPROP_LEVELVALUE, i*30);
ObjectSet(names[5], OBJPROP_LEVELCOLOR, clGreen);
ObjectSet(names[5], OBJPROP_LEVELSTYLE, integer(psSolid));
ObjectSet(names[5], OBJPROP_LEVELWIDTH, 1);
end;
end;
// create text
if not(ObjectExists(names[8])) then
begin
ObjectCreate(names[8], obj_Text, 0,
ScriptInterfaceUnit.Time(10), Close(0));
ObjectSetText(names[8], 'Test text', 12, 'Arial', clYellow);
ObjectSet(names[8], OBJPROP_VALIGNMENT, tlBottom);
ObjectSet(names[8], OBJPROP_HALIGNMENT,
ScriptInterfaceUnit.taLeftJustify);
end;
// set vertical line props
ObjectSet(names[0], OBJPROP_TIME1, ScriptInterfaceUnit.Time(0));
// set horizontal line props
ObjectSet(names[1], OBJPROP_PRICE1, Close(0));
// set trend line props
ObjectSet(names[2], OBJPROP_TIME1, ScriptInterfaceUnit.Time(10));
ObjectSet(names[2], OBJPROP_PRICE1, Close(10));
ObjectSet(names[2], OBJPROP_TIME2, ScriptInterfaceUnit.Time(0));
ObjectSet(names[2], OBJPROP_PRICE2, Close(0));
// set ray props
ObjectSet(names[3], OBJPROP_TIME1, ScriptInterfaceUnit.Time(10));
ObjectSet(names[3], OBJPROP_PRICE1, Open(10));
ObjectSet(names[3], OBJPROP_TIME2, ScriptInterfaceUnit.Time(0));
ObjectSet(names[3], OBJPROP_PRICE2, Open(0));
// set fibo retracement props
ObjectSet(names[4], OBJPROP_TIME1, ScriptInterfaceUnit.Time(40));
ObjectSet(names[4], OBJPROP_PRICE1, Close(40));
ObjectSet(names[4], OBJPROP_TIME2, ScriptInterfaceUnit.Time(10));
ObjectSet(names[4], OBJPROP_PRICE2, Close(10));
// set fibo fan props
ObjectSet(names[5], OBJPROP_TIME1, ScriptInterfaceUnit.Time(80));
ObjectSet(names[5], OBJPROP_PRICE1, Close(80));
ObjectSet(names[5], OBJPROP_TIME2, ScriptInterfaceUnit.Time(50));
ObjectSet(names[5], OBJPROP_PRICE2, Close(50));
// set text props
ObjectSet(names[8], OBJPROP_TIME1, ScriptInterfaceUnit.Time(10));
ObjectSet(names[8], OBJPROP_PRICE1, Close(0));
end;
exports
Init,
Done,
Execute;
end.
Если у кого-то компилятор будет ругаться на строчке с цветом, добавте перед названием цвета фразу "graphics".
Например, вместо "clYellow" запишите "graphics.clYellow".