problem incorporating data series to plotpaintbar

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Macdaddy
Posts: 5
Joined: 08 Apr 2010
Been thanked: 1 time

problem incorporating data series to plotpaintbar

Postby Macdaddy » 09 Dec 2011

Hello,

In the simple code below I using a one minute chart of the S&P Emini and I've added a 5min data series of the same symbol (data2). When the the 5 min adx is turned up (ADX2Value > ADX2Value[1]) I want the 1 min candlesticks to be painted green when and stay green while this condition is met.

What is happening is one candlestick turns green every 5 minutes while the condition is meet. For example: If the 5 min adx turns up and and remains up lets say for 20 minutes. I will get a green candle at lets say at 00:05 then another green candle at 00:10 and again at 00:15 and again at 00:20.

I would like the one min candlestick to be painted in real time when the 5 min adx turns up, lets say that happens to be 00:03 and each candle to stay painted green while the condition is meet.

If you would please advise, I've worked on this for quite so time and can not figure how to do this....Thank you!

Code: Select all

inputs:
ADXLenght ( 10 );

variables:
ADX2Value( 0 );

ADX2Value = ADX( ADXLenght ) of Data2 ;

if
ADX2Value > ADX2Value[1] then

PlotPaintBar(High, Low, Open, Close, "Data1", green)

else
PlotPaintBar(High, Low, Open, Close, "Data1", White) ;
Thank you,
Mac

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

Re: problem incorporating data series to plotpaintbar

Postby TJ » 09 Dec 2011

Hello,

In the simple code below I using a one minute chart of the S&P Emini and I've added a 5min data series of the same symbol (data2). When the the 5 min adx is turned up (ADX2Value > ADX2Value[1]) I want the 1 min candlesticks to be painted green when and stay green while this condition is met.

What is happening is one candlestick turns green every 5 minutes while the condition is meet. For example: If the 5 min adx turns up and and remains up lets say for 20 minutes. I will get a green candle at lets say at 00:05 then another green candle at 00:10 and again at 00:15 and again at 00:20.

I would like the one min candlestick to be painted in real time when the 5 min adx turns up, lets say that happens to be 00:03 and each candle to stay painted green while the condition is meet.

If you would please advise, I've worked on this for quite so time and can not figure how to do this....Thank you!

Code: Select all

inputs:
ADXLenght ( 10 );

variables:
ADX2Value( 0 );

ADX2Value = ADX( ADXLenght ) of Data2 ;

if
ADX2Value > ADX2Value[1] then

PlotPaintBar(High, Low, Open, Close, "Data1", green)

else
PlotPaintBar(High, Low, Open, Close, "Data1", White) ;
Thank you,
Mac

give this a try:

Code: Select all

inputs:
ADXLenght ( 10 );

variables:
color(0),
ADX2Value( 0 );

ADX2Value = ADX( ADXLenght ) of Data2 ;


if ADX2Value > ADX2Value[1] then

color = green

else

if ADX2Value < ADX2Value[1] then

color = white

else

color = color[1];


PlotPaintBar(High, Low, Open, Close, "Data1", color);

Macdaddy
Posts: 5
Joined: 08 Apr 2010
Been thanked: 1 time

Re: problem incorporating data series to plotpaintbar

Postby Macdaddy » 10 Dec 2011

I tried your suggestion with the 1 minute ADX added and it did not seem to work properly. I also noticed a similar problem when I used different data series when plotting my cci indicator. The indicator only plotted on the closing bar of the high time frame. In other words a 5 min adx or cci plotted on a 1 min chart seems only to change the values every 5th bar. The same cci or adx values change in real time on the actual 5 min chart with price movement.

Please advise.

Thank you!

Code: Select all

inputs:
ADXLenght ( 10 );

variables:
color(0),
ADX1Value( 0 ),
ADX2Value( 0 );

ADX1Value = ADX( ADXLenght ) of Data1 ;
ADX2Value = ADX( ADXLenght ) of Data2 ;

if ADX1Value > ADX1Value[1] and ADX2Value > ADX2Value[1] then

color = green

else

if ADX1Value < ADX1Value[1] and ADX2Value < ADX2Value[1] then

color = white

else

color = color[1];


PlotPaintBar(High, Low, Open, Close, "Data1", color);

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

Re: problem incorporating data series to plotpaintbar

Postby TJ » 10 Dec 2011

I tried your suggestion with the 1 minute ADX added and it did not seem to work properly. ...
What do you mean by "it did not seem to work properly"?

Should I read your mind?

There is no reason it does not work. There must be something else.

Macdaddy
Posts: 5
Joined: 08 Apr 2010
Been thanked: 1 time

Re: problem incorporating data series to plotpaintbar

Postby Macdaddy » 10 Dec 2011

If you run code below on a 1 minute chart and compare it to a 1 min adx ploted on a one min chart and a 5 min adx ploted on a 5 min chart you will see instances were the 5 min adx is closed up and later if the 1 min turns up the candlestick does turn green until the one minute charts falls on the next 5 minute interval. In other words it the 5 min adx is up at 00:05 and the one minut adx turns up at 00:07 the candlestick does not turn green until 00:10. This is what I meant when I said it does not seem to work properly.

Please advise and thank you for your help!

Code: Select all

inputs:
ADXLenght ( 10 );

variables:
color(0),
ADX1Value( 0 ),
ADX2Value( 0 );

ADX1Value = ADX( ADXLenght ) of Data1 ;
ADX2Value = ADX( ADXLenght ) of Data2 ;

if ADX1Value > ADX1Value[1] and ADX2Value > ADX2Value[1] then

color = green

else

if ADX1Value < ADX1Value[1] or ADX2Value < ADX2Value[1] then

color = white

else

color = color[1];


PlotPaintBar(High, Low, Open, Close, "Data1", color);

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

Re: problem incorporating data series to plotpaintbar

Postby TJ » 10 Dec 2011

If you run code below on a 1 minute chart and compare it to a 1 min adx ploted on a one min chart and a 5 min adx ploted on a 5 min chart you will see instances were the 5 min adx is closed up and later if the 1 min turns up the candlestick does turn green until the one minute charts falls on the next 5 minute interval. In other words it the 5 min adx is up at 00:05 and the one minut adx turns up at 00:07 the candlestick does not turn green until 00:10. This is what I meant when I said it does not seem to work properly.

Please advise and thank you for your help!

Code: Select all

inputs:
ADXLenght ( 10 );

variables:
color(0),
ADX1Value( 0 ),
ADX2Value( 0 );

ADX1Value = ADX( ADXLenght ) of Data1 ;
ADX2Value = ADX( ADXLenght ) of Data2 ;

if ADX1Value > ADX1Value[1] and ADX2Value > ADX2Value[1] then

color = green

else

if ADX1Value < ADX1Value[1] or ADX2Value < ADX2Value[1] then

color = white

else

color = color[1];


PlotPaintBar(High, Low, Open, Close, "Data1", color);
If you need more help, you have to provide more info. eg. a screen shot of your chart, with notes on it describing what should happen, and what is wrong. What you are describing is in contradiction to the requirement in your first post.


Return to “User Contributed Studies and Indicator Library”