Erase a previous plotted dot  [SOLVED]

Questions about MultiCharts and user contributed studies.
Al3cs
Posts: 8
Joined: 22 Jun 2017
Location: Italy
Has thanked: 4 times

Erase a previous plotted dot

Postby Al3cs » 19 Dec 2017

Hi guys,
I'm writing an indicator for pattern recognition.
The indicator looks for lower highs and it starts looking for an high and marks it with a dot.
But if an higher high occurs I want to mark this recent one as the high and erase provious plotted dot.

This is the code but it doesn't erase previous dots

Code: Select all

if stato = 0 and High[1] > Highest(High[2],20) and High < High[1] then
begin
   stato = 1;
   barCount = 0;
   PVH1 = High[1];
   PVH1Pos = BarNumber;
   Plot1[BarNumber - PVH1Pos + 1](PVH1,"1");
   Print("Trovato 1 il ", Date);
end;

if stato = 1 then
begin
   barCount = barCount + 1;
   if barCount > numBarreReset then stato = 0;
   if high > PVH1 then begin
      NoPlot(1);
      PVH1 = high;
      Plot1[high-1](PVH1, "1");
      end;



Connessione Desktop remoto.png
Connessione Desktop remoto.png (4.56 KiB) Viewed 144 times

User avatar
TJ
Posts: 6638
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1919 times

Re: Erase a previous plotted dot

Postby TJ » 19 Dec 2017

Al3cs wrote:Hi guys,
I'm writing an indicator for pattern recognition.
The indicator looks for lower highs and it starts looking for an high and marks it with a dot.
But if an higher high occurs I want to mark this recent one as the high and erase provious plotted dot.

This is the code but it doesn't erase previous dots

Code: Select all

if stato = 0 and High[1] > Highest(High[2],20) and High < High[1] then
begin
   stato = 1;
   barCount = 0;
   PVH1 = High[1];
   PVH1Pos = BarNumber;
   Plot1[BarNumber - PVH1Pos + 1](PVH1,"1");
   Print("Trovato 1 il ", Date);
end;

if stato = 1 then
begin
   barCount = barCount + 1;
   if barCount > numBarreReset then stato = 0;
   if high > PVH1 then begin
      NoPlot(1);
      PVH1 = high;
      Plot1[high-1](PVH1, "1");
      end;



Connessione Desktop remoto.png



Which line of code is used to erase previous dots?

Al3cs
Posts: 8
Joined: 22 Jun 2017
Location: Italy
Has thanked: 4 times

Re: Erase a previous plotted dot

Postby Al3cs » 19 Dec 2017

There's a NoPlot(1) in the fourth line from the end.
The code finds and marks the high in the first indentation.
The second indentation checks for an higher high then it (tries to) delete the dot previously plotted and marks the new one.

User avatar
TJ
Posts: 6638
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1919 times

Re: Erase a previous plotted dot

Postby TJ » 19 Dec 2017

Al3cs wrote:There's a NoPlot(1) in the fourth line from the end.
The code finds and marks the high in the first indentation.
The second indentation checks for an higher high then it (tries to) delete the dot previously plotted and marks the new one.



The noplot removes the plot in the CURRENT BAR, not the previous bars.
These users thanked the author TJ for the post:
Al3cs

Al3cs
Posts: 8
Joined: 22 Jun 2017
Location: Italy
Has thanked: 4 times

Re: Erase a previous plotted dot

Postby Al3cs » 19 Dec 2017

Well, now I know what the problem is.
What about the solution?

User avatar
TJ
Posts: 6638
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1919 times

Re: Erase a previous plotted dot

Postby TJ » 19 Dec 2017

Try this:

Code: Select all


Plot1 [ BarNumber - PVH1Pos ] ( 0 );


User avatar
ABC
Posts: 537
Joined: 16 Dec 2006
Has thanked: 113 times
Been thanked: 299 times
Contact:

Re: Erase a previous plotted dot

Postby ABC » 19 Dec 2017

Al3cs,

Powerlanguage allows displacing NoPlot, too.

Code: Select all

Plot1( Close ) ;
NoPlot[10]( 1 ) ;


Regards,

ABC

Al3cs wrote:Well, now I know what the problem is.
What about the solution?
These users thanked the author ABC for the post:
sptrader

MAZINGUER
Posts: 15
Joined: 06 Jan 2017
Has thanked: 1 time
Been thanked: 10 times

Re: Erase a previous plotted dot  [SOLVED]

Postby MAZINGUER » 06 Jan 2018

Hi Al13cs,

I think it's better that you use blocks "if .... then begin .... end else ..." so that something like that remains:

Code: Select all

If .....{conditions}....  then begin
   ....{instructions ó assignments}....
   Plot1[BarNumber - PVH1Pos + 1](PVH1,"1");
Else
   NoPlot(1);
end;
These users thanked the author MAZINGUER for the post:
sptrader


Return to “MultiCharts”