Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 09-28-2011, 08:55 AM   #1

Join Date: Jul 2009
Posts: 39
Ignore this user

Thanks: 36
Thanked 3 Times in 3 Posts

Paintbar Indicator..

I am attempting to code a Paintbar indicator, for use w/ my trading.
The goal for now is to just use a SMA, and when price is below the MA to plot the color of the bar RED, when price is above the MA to plot the color of the bar BLUE,

I have done this and it works, but my next task that I wanted to do, is to make it so that the first time price closes above the SMA, or below the color would be changed to yellow.....

Any idea on how to modify the code to support this??

Inputs: price(Close), SMA(12),
upColour(Blue), downColour(Red);

plotpb(high,low, "SMA");

{ Color criteria }
if (Value1 > Value1[1]) then
setplotcolor(1, upColour)
else if (Value1 < Value1[1]) then
SetPlotColor(1, downColour);
v101 is offline  
Reply With Quote
Old 09-28-2011, 09:09 AM   #2

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Paintbar Indicator..

Quote:
Originally Posted by v101 »
I am attempting to code a Paintbar indicator, for use w/ my trading.
The goal for now is to just use a SMA, and when price is below the MA to plot the color of the bar RED, when price is above the MA to plot the color of the bar BLUE,

I have done this and it works, but my next task that I wanted to do, is to make it so that the first time price closes above the SMA, or below the color would be changed to yellow.....

Any idea on how to modify the code to support this??

Inputs: price(Close), SMA(12),
upColour(Blue), downColour(Red);

plotpb(high,low, "SMA");

{ Color criteria }
if (Value1 > Value1[1]) then
setplotcolor(1, upColour)
else if (Value1 < Value1[1]) then
SetPlotColor(1, downColour);

just add the 2nd criteria, as you have described...


Code:
Inputs: price(Close), SMA(12),
		upColour(Blue), downColour(Red);

plotpb(high,low, "SMA");

{ Color criteria }
if ((Value1 > Value1[1]) 
and (Value1[1] < Value1[2]) )

or 

( (Value1 < Value1[1]) 
and (Value1[1] > Value1[2]) )

then 
	setplotcolor(1, Yellow);


ps. please use code tag when posting codes. It is the # key at the top of the message window frame.
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 09-28-2011, 03:19 PM   #3

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Paintbar Indicator..

Quote:
Originally Posted by v101 »
my next task that I wanted to do, is to make it so that the first time price closes above the SMA, or below the color would be changed to yellow.....

Any idea on how to modify the code to support this??
Code:
Inputs: price(Close), SMA_Lngth(12),
upColour(Blue), downColour(Red);

var: TheSMA(0), CurrentColor(0), ClosedOvr(False), ClosedUndr(False), FirstClsOvr(False), FirstClsUndr(False);

plotpb(high,low, "SMA");

TheSMA=AVERAGE(Close, SMA_Lngth);
ClosedOvr=Close > TheSMA;
ClosedUndr=Close < TheSMA;

FirstClsOvr = ClosedOvr[1] and ClosedOvr[2] = False;
FirstClsUndr = ClosedUndr[1] and ClosedUndr[2] = False;

If FirstClsOvr then 
	CurrentColor = 0
Else If FirstClsOvr[1] then
	CurrentColor = 1
Else if FirstClsUndr[1] then
	CurrentColor = -1;
	
{ Color criteria }
if CurrentColor = 1 then
setplotcolor(1, upColour)
else if CurrentColor = -1 then
SetPlotColor(1, downColour) else SetPlotColor(1, Yellow);
Attached Thumbnails
Paintbar Indicator..-paintbarssma.jpg  
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 09-29-2011, 08:24 AM   #4

Join Date: Jan 2009
Location: Planet Earth
Posts: 2
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Paintbar Indicator..

Raghee has what she calls a GRaB indicator coded and posted over at her blog.
It's set for the 34EMA but its easily changed.
kc8flq is offline  
Reply With Quote
Old 09-30-2011, 06:46 AM   #5

Join Date: Jul 2009
Posts: 39
Ignore this user

Thanks: 36
Thanked 3 Times in 3 Posts

Re: Paintbar Indicator..

Thanks, I will check out the indicator, working with these suggestions, its getting closer to what I want, thanks everyone!!!
v101 is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Creating a 9/30 Crossover Paintbar Indicator Disco Scottie Coding Forum 3 12-13-2010 04:38 AM
Paintbar Factory ultacom Trading Indicators 1 11-21-2010 03:38 PM
VPCI As PaintBar mcerio Coding Forum 17 10-17-2010 11:59 PM
Trend Indicator Paintbar Squire69 Coding Forum 12 08-15-2010 05:11 PM
Paintbar Plotting chrisleonard Coding Forum 8 10-02-2009 12:50 PM

All times are GMT -4. The time now is 11:02 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.