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.
"
Cannot Install Indicator
-
- Posts: 8
- Joined: Wed May 31, 2017 2:08 am
Cannot Install Indicator
- Attachments
-
- Screen Shot 2017-05-31 at 2.07.40 PM.png (153.37 KiB) Viewed 17781 times
-
- Posts: 1479
- Joined: Mon Apr 01, 2013 3:55 am
Re: Cannot Install Indicator
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.
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.
-
- Posts: 8
- Joined: Wed May 31, 2017 2:08 am
Re: Cannot Install Indicator
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.
- neHcioHep
- Posts: 18
- Joined: Sat Nov 21, 2009 5:49 pm
- Contact:
Re: Cannot Install Indicator
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
with some new
or something like this
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;
-
- Posts: 8
- Joined: Wed May 31, 2017 2:08 am
Re: Cannot Install Indicator
I just tried the above recommended code but still encountered the exact same error. Can you check again?
Who is online
Users browsing this forum: No registered users and 12 guests