indicator doesn't plot correctly these points

Questions about MultiCharts and user contributed studies.
nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

indicator doesn't plot correctly these points

Postby nuno-online » 18 Dec 2008

Hello
I hope someone can help with an EasyLanguage Problem.
I want to write an indicator to plot points like swing points. The trouble
is that the indicator doesn't plot correctly these points

here is the code

Thanks for your help.

Code: Select all

Vars: DnTrend(False), UpTrend(False), Trend(0), UpTrendBar(0),
DnTrendBar(0),

DnTrendLow(999999), UpTrendHigh(-999999), UpTrendLow(0), DnTrendHigh(
0), UpTrendDate(0),DnTrendDate(0);

Arrays: LastH[3](0), LastLo[3](0),DateH[3](0),DateLo[3](0);

{ Downtrend = one down bar / Uptrend = one up bar }

DnTrend = High < High[1] and Low < Low[1];
UpTrend = High > High[1] and Low > Low[1];

{ Keep track of the high recorded on the day of the lowest low of a
Downtrend
Keep track of the low recorded on the day of the hightest high of an Uptrend
}

If Trend = -1 and Low < DnTrendLow and Low < Low[1] then
Begin
DnTrendHigh = High;
DnTrendBar= CurrentBar;
End;

If Trend = 1 and High > UpTrendHigh and High > High[1] then
Begin
UpTrendLow = Low;
UpTrendBar= CurrentBar;
End;

{ When defining a trend change, we reference these values to confirm the
change. }

{ We define a change from an Uptrend to a Downtrend as a simple Downtrend
combined with the low lower than the low recorded on the day of the highest
bar of the latest Uptrend. }

If DnTrend = True and Low < UpTrendLow then Trend = -1;

{ We define a change from a Downtrend to an Uptrend as a simple Uptrend
combined with the high greater than the high recorded on the day of the
lowest bar of the latest Downtrend. }

If UpTrend = True and High > DnTrendHigh then Trend = 1;

If Trend = 1 and UpTrendHigh < High then
Begin
UpTrendHigh = High;
UpTrendDate = Date;
End;

If Trend = -1 and DnTrendLow > Low then
Begin
DnTrendLow = Low;
DnTrendDate = Date;
End;

If Trend = 1 and Trend[1] <> 1 then
Begin
LastLo[0] = DnTrendLow;
DateLo[0] = DnTrendDate;
Plot1[CurrentBar - UpTrendBar](LastLo[0],"Dn");
End;

If Trend = - 1 and Trend[1] <> -1 then
Begin
LastH[0] = UpTrendHigh;
DateH[0] = UpTrendDate;
Plot2[CurrentBar - DnTrendBar](LastH[0],"Up");
End

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 18 Dec 2008

pls post a screen shot indicating the problem.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 18 Dec 2008

Hi nuno-online,

TJ is right. We would need a screenshot with your comments point out how you expect the indicator to work and how its behavior is different from what you expected.

Regards.

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

the screenshots

Postby nuno-online » 19 Dec 2008

hELLO

Here are the screenshots about the indicator's behavior and what i want to do (plot points at highest and lowest bars)
Attachments
WHAT THE CODE DO.png
(94.52 KiB) Downloaded 984 times
WHAT I WANT TO DO.PNG
(46.84 KiB) Downloaded 991 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 19 Dec 2008

If Trend = - 1 and Trend[1] <> -1 then
Begin
LastH[0] = UpTrendHigh;
DateH[0] = UpTrendDate;
Plot2[CurrentBar - DnTrendBar](LastH[0],"Up");
End
else
noplot(2);


User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: the screenshots

Postby TJ » 19 Dec 2008

hELLO

Here are the screenshots about the indicator's behavior and what i want to do (plot points at highest and lowest bars)
which plots are not correct?
can you add an arrow?
to point out the wrong positions,
and point to the correct place?

drwar
Posts: 218
Joined: 31 Jul 2005

Postby drwar » 19 Dec 2008

Looks to me like your code is indicating the trigger bar for up or down and the plot you want show the extremes of the hi/lo . Without looking at your code it would require you having some code to remember the highest hi and lowest low price and time. Is that what your issue is because otherwise it is not clear. ON one chart you show trend lines to the extremes and the other just dots. So its hard to interpret what your intent is.

J~

I do something similar - see attached.
Attachments
Pivots.png
(37.4 KiB) Downloaded 979 times

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

MORE INFORMATIONS

Postby nuno-online » 19 Dec 2008

IN THE SCREENSHOT ' what i want to do' i only want to plot points at the extremes of high / low

in the screenshot 'more informations' , i had some arrows where i want to show you where to plot points


for example 24/10/2008
I add an arrow where i want to plot the point (low of the bar = 2959,29)
in screenshot, the point is plotted in 29/10/2008 instead of 24/10/2008
Attachments
24102008.png
(34.85 KiB) Downloaded 962 times
29102008.png
(97.11 KiB) Downloaded 968 times
more informations.png
(95.33 KiB) Downloaded 968 times
Last edited by nuno-online on 19 Dec 2008, edited 1 time in total.

drwar
Posts: 218
Joined: 31 Jul 2005

Postby drwar » 19 Dec 2008

Thats what I thought you meant. I will look at your code

J~

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

the code

Postby nuno-online » 19 Dec 2008

here the easylanguage code i modified

what is wrong?

Code: Select all

Vars: Trend(0), DnTrend(False), UpTrend(False), DnTrendLow(999999),UpTrendHigh(-99999),
UpTrendLow(0),DnTrendHigh(0), UpTrendDate(0), DnTrendDate(0), DownTrendBar(0), UpTrendBar(0);
Arrays: LastH[3](0), LastLo[3](0),DateH[3](0),DateLo[3](0);

{ Downtrend = one down bar / Uptrend = one up bar }
DnTrend = High < High[1] and Low < Low[1];
UpTrend = High > High[1] and Low > Low[1];

{ We define a change from an Uptrend to a Downtrend as a simple Downtrend combined with
the low lower than the low recorded on the day of the highest bar of the latest Uptrend. }
If DnTrend = True and Low <= UpTrendLow then Trend = -1;

{ We define a change from a Downtrend to an Uptrend as a simple Uptrend combined with
the high greater than the high recorded on the day of the lowest bar of the latest Downtrend. }
If UpTrend = True and High >= DnTrendHigh then Trend = 1;

{ Keep track of the high recorded on the day of the lowest low of a Downtrend
Keep track of the low recorded on the day of the hightest high of an Uptrend }
If Trend = 1 and High > UpTrendHigh and High > High[1] then UpTrendLow = Low;
If Trend = -1 and Low < DnTrendLow and Low < Low[1] then DnTrendHigh = High;

If Trend = -1 and DnTrendLow > Low then
Begin
DnTrendDate = Date;
DownTrendBar = CurrentBar;
DnTrendLow = Low;
End;

If Trend = 1 and UpTrendHigh < High then
Begin
UpTrendDate = Date;
UpTrendBar = CurrentBar;
UpTrendHigh = High;
End;

If Trend = 1 and Trend[1] <> 1 then
Begin
LastLo[0] = DnTrendLow;
DnTrendLow = Low;
DateLo[0] = DnTrendDate;
Plot1(LastLo[0],"Dn");
//Plot1[CurrentBar - UpTrendBar](LastLo[0],"Dn");
End
Else
NoPlot(1);

If Trend = - 1 and Trend[1] <> -1 then
Begin
LastH[0] = UpTrendHigh;
UpTrendHigh = High;
DateH[0] = UpTrendDate;
Plot2(LastH[0],"Up");
//Plot2[CurrentBar - DnTrendBar](LastH[0],"Up");
End
Else
Noplot(2);

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

look at my code

Postby nuno-online » 23 Dec 2008

did someone look at my code?

drwar
Posts: 218
Joined: 31 Jul 2005

Re: look at my code

Postby drwar » 23 Dec 2008

[quote]did someone look at my code?[/quote]

Yes, Its clear it will not work as intended. The plot statements will plot when triggered not on the bar which is the peak. You started trying to detect and save the peak bar and then changed the code for whatever reason probably because there was a bug in how you did that. You have too many things happening in different places in your code which makes it difficult but not impossible for you track what is wrong. What I would suggest is using print statements to print to a file and save each condition leading up to a swing confirmation. Then you will be able to pick one that plots wrong and figure out what is not happening correctly is you save the date time and current bar of each decision.

J~


Return to “MultiCharts”