I modified the fractal script to create a very simple indicator. See attached figure.
The condition are:
1. If (Open(0)>Open(1) and Open(1)>Open(2)) then put a ds_Symbol at index
2. If (Open(0)<Open(1) and Open(1)<Open(2)) then put a ds_Symbol at index
However, the indicator is not working and I cannot figure out why.
Please somebody fix my script below.
Code: Select all
//---------------------------------------------------------------------------
// Test Indicator
//---------------------------------------------------------------------------
library TestIndicator;
uses
graphics, IndicatorInterfaceUnit, SysUtils;
var
// Buffers
TrendUpBuff, TrendDownBuff: TIndexBuffer;
//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define properties
IndicatorShortName('Test Indicator');
SetOutputWindow(ow_ChartWindow);
// create buffers
TrendUpBuff := CreateIndexBuffer;
TrendDownBuff := CreateIndexBuffer;
SetIndexBuffer(0, TrendUpBuff);
SetIndexStyle(0, ds_Symbol, psSolid, 1, clGreen);
SetIndexSymbol(0, 217, 0, 10);
SetIndexLabel(0, 'Trend Up');
SetIndexBuffer(1, TrendDownBuff);
SetIndexStyle(1, ds_Symbol, psSolid, 1, clRed);
SetIndexSymbol(1, 218, 0, -10);
SetIndexLabel(1, 'Trend Down');
end;
//---------------------------------------------------------------------------
// Deinitialize indicator
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
end;
//---------------------------------------------------------------------------
// Mark Candlestick Patterns
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
begin
//*************Trend up**************
if not (Close(index)>Close(index+1)) and (Close(index+1)>Close(index+2)) then
begin
TrendUpBuff[index] := 0;
end
else
TrendUpBuff[index] := Close(index);
//*************Trend down*************
if not (Close(index)<Close(index+1)) and (Close(index+1)<Close(index+2)) then
begin
TrendDownBuff[index] := 0;
end
else
TrendUpBuff[index] := Close(index);
end;
exports
Init, Done, Calculate;
begin
end.