I have been trying to re-write the Aroon indicator for Forextester, the code compiles OK but when i try to add the indicator to the FX tester app, the application sits there doing nothing and become non responding javascript:emoticon(':(') . Attached is the full code in C++, can anyone check and see what am i doing wrong in this code?
Thanks.
Code: Select all
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "IndicatorInterfaceUnit.h"
#include "TechnicalFunctions.h"
// External variables
int Aroon_Period= 14;
// Buffers
TIndexBuffer Aroon_Up, Aroon_Dn;
EXPORT void __stdcall Init()
{
// define properties
IndicatorShortName("Aroon");
SetOutputWindow(ow_SeparateWindow);
AddLevel(30, psDash, 1, clYellow);
AddLevel(70, psDash, 1, clYellow);
AddLevel(100, psDash, 1, clYellow);
// register options
RegOption("Aroon_Period", ot_Integer, &Aroon_Period);
// create buffers
IndicatorBuffers(2);
Aroon_Up = CreateIndexBuffer();
Aroon_Dn = CreateIndexBuffer();
//SetFixedMinMaxValues(0, 1.2);
SetEmptyValue(0.0);
SetIndexBuffer(0, Aroon_Up);
SetIndexBuffer(1, Aroon_Dn);
SetIndexStyle(0, ds_Line, psSolid, 1, clGreen);
SetIndexStyle(1, ds_Line, psSolid, 1, clRed);
SetIndexLabel(0, "Aroon_Up");
SetIndexLabel(1, "Aroon_Dn");
SetBufferShift(0, 0);
SetBufferShift(1, 0);
}
EXPORT void __stdcall OnParamsChange()
{
}
EXPORT void __stdcall Calculate(int index)
{
int j, K, KLAST, Indx_low, Indx_high, High_Dist, Low_Dist;
double High_val, Low_val, High_tmp, Low_tmp;
if(Bars()>=Aroon_Period)
{
K=1; //starting the calculations on the first closed bar.
KLAST=K+Aroon_Period; //the last price bar that should be included in the calculations
for(j=KLAST;j>=K;j--)
{
High_val=iHigh(Symbol(),PERIOD_D1,j); //get the high value from the last bar in range
Low_val=iLow(Symbol(),PERIOD_D1,j); // get the low value from the last bar in range
if (j=KLAST) //it will fill the variable with the first found high and low and get the respective indexes.
{
High_tmp=High_val;
Low_tmp=Low_val;
Indx_high=j;
Indx_low=j;
}
if(High_val>=High_tmp) //replace the high with the previous high and update the index value
{
High_tmp=High_val;
Indx_high=j;
}
if(Low_val<=Low_tmp) // replace the low with the Prev and update the index
{
Low_tmp=Low_val;
Indx_low=j;
}
}
High_Dist=Indx_high-1; // real distance from the start bar
Low_Dist=Indx_low-1;
Aroon_Up[index+1] = ((Aroon_Period-High_Dist)/Aroon_Period)*100; / calculation for the indicator.
Aroon_Dn[index+1] = ((Aroon_Period-Low_Dist)/Aroon_Period)*100;
}
}