TRO's middle for NeoTicker
Posted: Wed Jan 17, 2007 9:27 pm
Hello,
I'm posting TRO's "middle" indicator, rewritten for NeoTicker.
It shows the previous middle and the current middle.
NeoTicker IDL & DLL along with the source code attached.
Michal
I'm posting TRO's "middle" indicator, rewritten for NeoTicker.
It shows the previous middle and the current middle.
NeoTicker IDL & DLL along with the source code attached.
Code: Select all
using NeoTicker;
using KreslikLib.Common;
using System.Windows.Forms;
namespace TROmiddle
{
public class EntryPointClass : IDLIndicator
{
bool settingsOK;
int inputHour;
int inputMinute;
int state;
double high;
double low;
double previousMiddle;
public double IDLCallEx(NTIndicatorObjects N)
{
if (N.ItSelf().FirstCall)
{
settingsOK = CheckIfSettingsOK(N, ref inputHour, ref inputMinute);
}
if (settingsOK && N.Data1().get_Valid(0))
{
if (state > 0)
{
high = KTools.HigherValue(high, N.Data1().get_High(0));
low = KTools.LowerValue(low, N.Data1().get_Low(0));
}
if (state > 1)
{
N.ItSelf().set_Plot(1, previousMiddle);
// plot the "temporary middle", which is
// a middle of the currently recorded high and low
N.ItSelf().set_Plot(2, (high + low) / 2);
}
else
{
N.ItSelf().SuccessAll = false;
}
// N.Data1().get_Hour(0) is the current bar's hour
// N.Data1().get_Minute(0) is the current bar's minute
if (inputHour == N.Data1().get_Hour(0) && inputMinute == N.Data1().get_Minute(0))
{
previousMiddle = (high + low) / 2;
ResetHighAndLow();
if (state < 2)
state++;
}
}
else
{
N.ItSelf().SuccessAll = false;
}
return 0;
}
private void ResetHighAndLow()
{
low = 1000;
high = -1000;
}
private bool CheckIfSettingsOK(NTIndicatorObjects N, ref int inputHour, ref int inputMinute)
{
state = 0;
ResetHighAndLow();
inputHour = N.Params().get_Items("hour").Int;
inputMinute = N.Params().get_Items("minute").Int;
if (!(inputHour >= 0 && inputHour <= 23 && inputMinute >= 0 && inputMinute <= 59))
{
MessageBox.Show("Settings error:\nHour should be between 0 and 23, minute should be between 0 and 59.", "Error in settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
else
{
return true;
}
}
}
}
Michal