TRO's middle for NeoTicker

NeoTicker indicators

Moderator: moderators

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1032
Joined: Sat May 13, 2006 2:40 am
Reputation: 0
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male
Contact:

TRO's middle for NeoTicker

Postby michal.kreslik » 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.

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
Attachments
TROmiddle.zip
(79.48 KiB) Downloaded 185 times

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

nicknextmove
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Wed Dec 06, 2006 4:01 am
Reputation: 0
Gender: Male

Postby nicknextmove » Wed Jan 17, 2007 11:17 pm

Does not look as sexy as the TS one :lol:

Just kidding.

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1032
Joined: Sat May 13, 2006 2:40 am
Reputation: 0
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male
Contact:

Postby michal.kreslik » Thu Jan 18, 2007 4:37 am

The only thing that I care about looking sexy is my bank account statement.

Well, and my girl-friend, of course.

Michal

theperm
rank: <50 posts
rank: <50 posts
Posts: 4
Joined: Tue Oct 24, 2006 2:49 pm
Reputation: 0
Gender: Male

Postby theperm » Sun Jan 21, 2007 4:06 pm

Tell me, out of curiosity why you use neoticker property accessors instead of the properties themselves in your code?

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1032
Joined: Sat May 13, 2006 2:40 am
Reputation: 0
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male
Contact:

Postby michal.kreslik » Tue Jan 23, 2007 12:01 am

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

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

theperm
rank: <50 posts
rank: <50 posts
Posts: 4
Joined: Tue Oct 24, 2006 2:49 pm
Reputation: 0
Gender: Male

Postby theperm » Tue Jan 23, 2007 11:10 am

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.

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1032
Joined: Sat May 13, 2006 2:40 am
Reputation: 0
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male
Contact:

Postby michal.kreslik » Wed Jan 24, 2007 1:16 am

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

theperm
rank: <50 posts
rank: <50 posts
Posts: 4
Joined: Tue Oct 24, 2006 2:49 pm
Reputation: 0
Gender: Male

Postby theperm » Wed Jan 24, 2007 11:40 am

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?

BC
rank: <50 posts
rank: <50 posts
Posts: 35
Joined: Sat Jan 27, 2007 8:13 pm
Reputation: 0
Location: Show Low
Gender: Male

Postby BC » Sat Jan 27, 2007 8:31 pm

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);
}

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1032
Joined: Sat May 13, 2006 2:40 am
Reputation: 0
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male
Contact:

Postby michal.kreslik » Sun Jan 28, 2007 1:11 am

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

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “NeoTicker indicators”