Plot text in scanner column based on conditions  [SOLVED]

Questions about MultiCharts and user contributed studies.
brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Plot text in scanner column based on conditions  [SOLVED]

Postby brunor » 06 Dec 2013

I would like to plot "UP" if condition1 is true, and "DN" if condition2 is true in a single column within the scanner window. This code plots the background colors, but I can't figure out the syntax for the plot1 function. I have tried placing the plot1 function in various positions, but can only get it to plot whatever text meets condition2.
Any assistance would be appreciated.

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;

Plot1("","",black);

If Condition1 then

SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);


If Condition2 then

SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);

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

Re: Plot text in scanner column based on conditions

Postby TJ » 06 Dec 2013

Try this:

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;

If Condition1 then
BEGIN
Plot1("UP");
SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);
END
else
If Condition2 then
BEGIN
Plot1("DN");
SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);
END;

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: Plot text in scanner column based on conditions

Postby brunor » 06 Dec 2013

I really appreciate your assistance TJ. Please have a look at the attached image.
My second attempt:

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;

Plot1("","",black);

If Condition1 then
Plot1("UP");
SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);

If Condition2 then
Plot1("DN");
SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);
Attachments
Code1.bmp
(928.58 KiB) Downloaded 803 times

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

Re: Plot text in scanner column based on conditions

Postby TJ » 06 Dec 2013

I really appreciate your assistance TJ. Please have a look at the attached image.
My second attempt:

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;
Plot1("","",black);
If Condition1 then
Plot1("UP");
SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);
If Condition2 then
Plot1("DN");
SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);
Please take a look at the BEGIN/END block in my code.

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: Plot text in scanner column based on conditions

Postby brunor » 06 Dec 2013

I added a third condition to your code and it now works as intended. Thank you very much for your assistance.

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;
Condition3 = BR_TrendUP = 0 and BR_TrendDOWN = 0;

If Condition1 then
BEGIN
Plot1("UP");
SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);
END
else
If Condition2 then
BEGIN
Plot1("DN");
SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);
END
else
if Condition3 then
Plot1("","",black);

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

Re: Plot text in scanner column based on conditions

Postby TJ » 06 Dec 2013

I added a third condition to your code and it now works as intended. Thank you very much for your assistance.

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;
Condition3 = BR_TrendUP = 0 and BR_TrendDOWN = 0;

If Condition1 then
BEGIN
Plot1("UP");
SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);
END
else
If Condition2 then
BEGIN
Plot1("DN");
SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);
END
else
if Condition3 then
Plot1("","",black);
You are welcome.
Good to know it is working.
Thanks for sharing the code.

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: Plot text in scanner column based on conditions

Postby brunor » 10 Dec 2013

I changed the code after conditon 3 (same as TJ's code for conditions 1 and 2). This version works perfectly.

Code: Select all

Condition1 = BR_TrendUP = 1;
Condition2 = BR_TrendDOWN = 1;
Condition3 = BR_TrendUP = 0 and BR_TrendDOWN = 0;

If Condition1 then
BEGIN
Plot1("UP");
SetPlotBGColor( 1, yellow);
SetPlotColor(1, black);
END
else
If Condition2 then
BEGIN
Plot1("DN");
SetPlotBGColor( 1, cyan) ;
SetPlotColor(1, black);
END
else
if Condition3 then
Begin
Plot1("","",black);
SetPlotBGColor( 1, black) ;
SetPlotColor(1, black);
End

User avatar
signalworks
Posts: 65
Joined: 06 Oct 2013
Location: Germany.Solingen
Has thanked: 23 times
Been thanked: 2 times
Contact:

Re: Plot text in scanner column based on conditions

Postby signalworks » 02 Jun 2014

Hello,
I have a requirement to show the first date of an instrument in a seperate column of a scanner-window. Is that possible?

The following code shows only the last date of an Instrument (supposely "currentbar = 1" is not possible here?):

Code: Select all

vars: fDate("");
if currentbar = 1 then
begin
fDate = NumToStr(FracPortion(date/100)*100,0) + "." + NumToStr(month(date),0)+ "." + NumToStr(1900+year(date),0);
end;
Plot1(fDate, "FirstDate");
Thanks & regards.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Plot text in scanner column based on conditions

Postby Henry MultiСharts » 03 Jun 2014

Hello,
I have a requirement to show the first date of an instrument in a seperate column of a scanner-window. Is that possible?

The following code shows only the last date of an Instrument (supposely "currentbar = 1" is not possible here?):

Code: Select all

vars: fDate("");
if currentbar = 1 then
begin
fDate = NumToStr(FracPortion(date/100)*100,0) + "." + NumToStr(month(date),0)+ "." + NumToStr(1900+year(date),0);
end;
Plot1(fDate, "FirstDate");
Thanks & regards.
Hello signalworks,

The indicator works as intended on my end. Please make sure the data range for the instrument is configured properly (right click on the instrument name in the scanner->Format Instrument->Settings tab).

User avatar
signalworks
Posts: 65
Joined: 06 Oct 2013
Location: Germany.Solingen
Has thanked: 23 times
Been thanked: 2 times
Contact:

Re: Plot text in scanner column based on conditions

Postby signalworks » 03 Jun 2014

Hello Henry,

Thank you, founded the "Use Custom Data Range"-Settings :-) I would like to set a range from a specific start date to a specific end date. Founded only Settings for "Days back/BarsBack". Is that possible?

Thanks & regards.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Plot text in scanner column based on conditions

Postby Henry MultiСharts » 03 Jun 2014

signalworks, only "Days back/BarsBack" option is available in the scanner window.


Return to “MultiCharts”