Cannot Install Indicator

Bug reports and errors in the program
Message
Author
avnguyen1988
Posts: 8
Joined: Wed May 31, 2017 2:08 am

Cannot Install Indicator

#1 Postby avnguyen1988 » Wed May 31, 2017 2:22 am

After creating a DLL file from the codes below, I tried to install this new indicator but failed. The error is shown in the screenshot. Can you tell me how to fix this?

"//---------------------------------------------------------------------------
// Average Daily Range
//
// The Indicator works in the 24, 12, 8, 6, 4, 3, 2, 1 hr TimeFrames
// The selected Period (in days) applies to all Timeframes
// The Indicator calculates pips
// The Indicator can distinguish between Yen pairs and non-Yen pairs
//---------------------------------------------------------------------------
library ADR;

uses
SysUtils,
Math,
Graphics,
IndicatorInterfaceUnit,
TechnicalFunctions;

var
// External variables
Period: integer;

// Buffers
ADRBuffer: TIndexBuffer;
TempBuffer: TIndexBuffer;

//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define properties
IndicatorShortName('Average Daily Range Multiple Timeframes (ADR)');
SetOutputWindow(ow_SeparateWindow);

// register options
AddSeparator('Common: this Indicator works in TimeFrame 1 day and below');

RegOption('Period (days)', ot_Integer, Period);
SetOptionRange('Period', 1, MaxInt);
Period := 14;

// create buffers
ADRBuffer := CreateIndexBuffer;
TempBuffer := CreateIndexBuffer;

IndicatorBuffers(1);
SetIndexBuffer(0, ADRBuffer);
SetIndexStyle(0, ds_Line, psSolid, 3, clLime);
SetIndexLabel(0, 'Pips');
IndicatorDigits(2);
//SetFixedMinMaxValues(0, 400);
end;

//---------------------------------------------------------------------------
// Deinitialize indicator
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin

end;

//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
var
i, Position, Multiplier, TFMultiplier: integer;
P_High, P_Low, sum: double;

begin

if (Timeframe = 1440) or (Timeframe = 720) or (Timeframe = 480) or (Timeframe = 360)
or (Timeframe = 240) or (Timeframe = 180) or (Timeframe = 120) or (Timeframe = 60) then
begin

end
else
Exit;

if Timeframe = 1440 then TFMultiplier := 1; //24 hrs
if Timeframe = 720 then TFMultiplier := 2; //12 hrs
if Timeframe = 480 then TFMultiplier := 3; //8 hrs
if Timeframe = 360 then TFMultiplier := 4; //6 hrs
if Timeframe = 240 then TFMultiplier := 6; //4 hrs
if Timeframe = 180 then TFMultiplier := 8; //3 hrs
if Timeframe = 120 then TFMultiplier := 12; //2 hrs
if Timeframe = 60 then TFMultiplier := 24; //1 hr

Position := AnsiPos('JPY', Symbol);
if Position <> 0
then Multiplier := 100
else Multiplier := 10000;

P_High := High(index);
P_Low := Low(index);
TempBuffer[index] := P_High - P_Low;

sum:=0;
for i:=0 to ((Period * TFMultiplier) - 1) do
sum := sum + TempBuffer[index + i];
ADRBuffer[index] := (sum/(Period*TFMultiplier))*Multiplier;

end;

exports

Init, Done, Calculate;

end.
"
Attachments
Screen Shot 2017-05-31 at 2.07.40 PM.png
Screen Shot 2017-05-31 at 2.07.40 PM.png (153.37 KiB) Viewed 17610 times

FX Helper
Posts: 1477
Joined: Mon Apr 01, 2013 3:55 am

Re: Cannot Install Indicator

#2 Postby FX Helper » Thu Jun 01, 2017 4:06 am

Hello,

Can you please attach this indicator?
Or send it to us to email support@forextester.com

Please try to run the Forex Tester program as administrator (right-click on the icon -> run as administrator) and then try to add this indicator again.

avnguyen1988
Posts: 8
Joined: Wed May 31, 2017 2:08 am

Re: Cannot Install Indicator

#3 Postby avnguyen1988 » Thu Jun 01, 2017 11:54 pm

I ran FT2 in Administrator mode and tried installing the indicator again but still encountered the same error. I have sent the indicator file to FT support email.

User avatar
neHcioHep
Posts: 18
Joined: Sat Nov 21, 2009 5:49 pm
Contact:

Re: Cannot Install Indicator

#4 Postby neHcioHep » Fri Jun 02, 2017 1:06 am

In line with TempBuffer[index + i]; index of TempBuffer(with index + i) can try to access to the bar that does not exist (if it index more than Bars variable)

Please try to replace part of your code

Code: Select all

for i:=0 to ((Period * TFMultiplier) - 1) do
sum := sum + TempBuffer[index + i];
ADRBuffer[index] := (sum/(Period*TFMultiplier))*Multiplier;


with some new

Code: Select all

var elementsForSum :integer;

//...

elementsForSum := Period * TFMultiplier;
if (index + elementsForSum > Bars) then
   elementsForSum := Bars - index;

for i:=0 to (elementsForSum - 1) do
    sum := sum + TempBuffer[index + i];

ADRBuffer[index] := (sum/elementsForSum)*Multiplier;


or something like this

Code: Select all

if (index + (Period * TFMultiplier)) > Bars then exit;
for i:=0 to ((Period * TFMultiplier) - 1) do
sum := sum + TempBuffer[index + i];
ADRBuffer[index] := (sum/(Period*TFMultiplier))*Multiplier;

avnguyen1988
Posts: 8
Joined: Wed May 31, 2017 2:08 am

Re: Cannot Install Indicator

#5 Postby avnguyen1988 » Fri Jun 02, 2017 5:46 am

I just tried the above recommended code but still encountered the exact same error. Can you check again?


Return to “Bug reports”

Who is online

Users browsing this forum: No registered users and 9 guests