Page 1 of 2

TRO's middle for NeoTicker

Posted: Wed Jan 17, 2007 9:27 pm
by michal.kreslik
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.

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

Posted: Wed Jan 17, 2007 11:17 pm
by nicknextmove
Does not look as sexy as the TS one :lol:

Just kidding.

Posted: Thu Jan 18, 2007 4:37 am
by michal.kreslik
The only thing that I care about looking sexy is my bank account statement.

Well, and my girl-friend, of course.

Michal

Posted: Sun Jan 21, 2007 4:06 pm
by theperm
Tell me, out of curiosity why you use neoticker property accessors instead of the properties themselves in your code?

Posted: Tue Jan 23, 2007 12:01 am
by michal.kreslik
theperm wrote:Tell me, out of curiosity why you use neoticker property accessors instead of the properties themselves in your code?


Sometimes the properties themselves are not available in the NeoTicker object model. You are doomed to use whatever is available to you as a programmer.

Which property accessors/properties do you mean exactly?

Michal

Posted: Tue Jan 23, 2007 11:10 am
by theperm
any of them, tht start with get_ i.e N.Data1().get_High(0))

I wonder why the properties arent available to you?
They are all in the delphi TLB, which represents the interfaces for neoticker. Not sure how .net handles it.

So r you saying in your .Net environment using the properties doesnt compile or is it just your code insight feature only lists the methods and not the properties?

Because the properties should be available for you to use and if they arent i would imagine there is a configuration error.

Posted: Wed Jan 24, 2007 1:16 am
by michal.kreslik
Theperm,

just to check, could you please provide some exact pair of property accessor and property so that I may check whether this precise pair is available in .NET, too?

I guess there's no reason why the NeoTicker object model should not be available in its entirety in .NET, though.

Thanks,
Michal

Posted: Wed Jan 24, 2007 11:40 am
by theperm
every single get_ or set_ should have a property that you should beusing instead.

None of the get_ or set_ functions/method are supposed to be used publicly, well at least thats the norm in OOP. This is supposed to be common knowledge. One of the reasons for this is that you dont allways know how the developer intended to use the acessors, so the property should always be the primary way to use them. In other words you cant go wrong using Properties.

for example
N.Data1.High(0) uses Data1.get_High(0) and has no set_ cause its read only as do most of the orhter data1. properties

The simplest way for you is to take a function/method and look for a property of the same name without get_ or set_.

Didnt you think it odd none of these methods where documented in noeticker help?

Posted: Sat Jan 27, 2007 8:31 pm
by BC
I just joined your forum, I'm interested in neoticker.
Is it a true C+ language that it uses and are the files compiled by the program?

I am currently using metatrader, it uses a c -look alike code.
Some code for a sar indicator is below, would it work in neoticker?

#property indicator_separate_window

#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Green
#property indicator_color3 Green
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_maximum 1
#property indicator_minimum -1

extern double BIG_SARStep=0.2;
extern double MIDDLE_SARStep=0.4;
extern double SMALL_SARStep=0.06;
double ExtBuffer1[];
double ExtBuffer2[];
double ExtBuffer3[];
double ExtBuffer4[];
double ExtBuffer5[];
double ExtBuffer6[];

int init()
{
SetIndexBuffer(0, ExtBuffer1);
SetIndexStyle(0,DRAW_ARROW,EMPTY);//3
SetIndexArrow(0,108);

SetIndexBuffer(1, ExtBuffer2);
SetIndexStyle(1,DRAW_ARROW,EMPTY);//2
SetIndexArrow(1,108);

SetIndexBuffer(2, ExtBuffer3);
SetIndexStyle(2,DRAW_ARROW,EMPTY);//1
SetIndexArrow(2,108);

SetIndexBuffer(3, ExtBuffer4);
SetIndexStyle(3,DRAW_ARROW,EMPTY);//3
SetIndexArrow(3,108);

SetIndexBuffer(4, ExtBuffer5);
SetIndexStyle(4,DRAW_ARROW,EMPTY);//2
SetIndexArrow(4,108);

SetIndexBuffer(5, ExtBuffer6);
SetIndexStyle(5,DRAW_ARROW,EMPTY);//1
SetIndexArrow(5,108);

IndicatorShortName("Advanced SAR : Step ( "+BIG_SARStep+" )");
return(0);
}
int deinit()
{
return(0);
}
int start()
{
double Big_sarval,Middle_sarval,Small_sarval;
for(int i=0; i<Bars-1 ; i++)
{
Big_sarval=iSAR(NULL,0,BIG_SARStep,0.2,i);//0.2
if (Big_sarval<Low[i])
{
ExtBuffer1[i]=-0.3;//0.3
}
if (Big_sarval>High[i])
{
ExtBuffer4[i]=-0.3;//0.3
}

Middle_sarval=iSAR(NULL,0,MIDDLE_SARStep,0.2,i); //0.2
if (Middle_sarval<Low[i])
{
ExtBuffer2[i]=0;
}
if (Middle_sarval>High[i])
{
ExtBuffer5[i]=0;
}
Small_sarval=iSAR(NULL,0,SMALL_SARStep,0.2,i); //0.2
if (Small_sarval<Low[i])
{
ExtBuffer3[i]=0.3;//0.3
}
if (Small_sarval>High[i])
{
ExtBuffer6[i]=0.3;//0.3
}

}
return(0);
}

Posted: Sun Jan 28, 2007 1:11 am
by michal.kreslik
theperm wrote:Didnt you think it odd none of these methods where documented in noeticker help?


Ok, so the mystery is solved:



There's no Data1().High(int) property available in C#.NET and there never was. That's why I just couldn't understand about what property the hell were you talking about :)

theperm wrote:None of the get_ or set_ functions/method are supposed to be used publicly, well at least thats the norm in OOP. This is supposed to be common knowledge.


While I certainly agree that the common practice is to hide the methods that are manipulating with some private object within the class, you are wrong in assuming that one is not supposed to use public members of a class.

It's the other way round: once a member is declared public, the client object is actually supposed to use it. If the coder who was implementing the serving object wouldn't want you to use the member, he wouldn't make it public.

Michal