# Converting Drummond PLDot to Thinkscript? #### Sully

##### New member
Hello,

My first attempt of converting TS code to TOS is for the Drummond PLDot.

It seems simple enough until I get to the plot portion. For some reason, the plot is a few hundred dollars above the actual price rendering the chart useless.

This is the TS code:

Code:
``````c=close
h=high
l=low

a=avg(h,l,c)
b=avg(h,l,c)
t=avg(h,l,c)
k=a+b+t
Pldot=k/3
Cosodelcolor = input(title="Cosodelcolor ?", type=bool, defval=true)

Pldotcolor= Cosodelcolor ? (Pldot > Pldot ? lime :  red) : orange
plot(Pldot, title="PLDOT", style=circles, linewidth=4, color=Pldotcolor, transp=0, offset=1)``````
This is what I have so far for the TOS code:
Code:
``````#Charles Drummond PLDot
# 1/8/2020 Version 1.0 Sully attempt

def H = high;
def L = low;
def C = close;

# Calculate Averages

def A1 = H + L + C / 3;
def A2 = H + L + C / 3;
def A3 = H + L + C / 3;

def Average = A1 + A2 + A3 /3;

# Plot the PLDot

plot PLDot = Average;

PLDot.SetLineWeight(3);
PLDot.SetStyle(Curve.POINTS);

#END PLDot CODE``````
Ideally, there would be two plots;

1- Plot dot of one color when dot is greater than the previous dot
2- Plot dot of another color when dot is less than the previous dot

Appreciate any assistance/guidance, recommendations, or revisions!

Thank you!

Last edited by a moderator:
T

#### tomsk

##### Well-known member
VIP
Hello,

My first attempt of converting TS code to TOS is for the Drummond PLDot.

It seems simple enough until I get to the plot portion. For some reason, the plot is a few hundred dollars above the actual price rendering the chart useless.

This is the TS code:

c=close
h=high
l=low

a=avg(h,l,c)
b=avg(h,l,c)
t=avg(h,l,c)
k=a+b+t
Pldot=k/3
Cosodelcolor = input(title="Cosodelcolor ?", type=bool, defval=true)

Pldotcolor= Cosodelcolor ? (Pldot > Pldot ? lime : red) : orange
plot(Pldot, title="PLDOT", style=circles, linewidth=4, color=Pldotcolor, transp=0, offset=1)

This is what I have so far for the TOS code:

#Charles Drummond PLDot
# 1/8/2020 Version 1.0 Sully attempt

def H = high;
def L = low;
def C = close;

# Calculate Averages

def A1 = H + L + C / 3;
def A2 = H + L + C / 3;
def A3 = H + L + C / 3;

def Average = A1 + A2 + A3 /3;

# Plot the PLDot

plot PLDot = Average;

PLDot.SetLineWeight(3);
PLDot.SetStyle(Curve.POINTS);

#END PLDot CODE

Ideally, there would be two plots;

1- Plot dot of one color when dot is greater than the previous dot
2- Plot dot of another color when dot is less than the previous dot

Appreciate any assistance/guidance, recommendations, or revisions!

Thank you!

@Sully I have modified your code including varying the color of the DOTS - see if this works better for you

Code:
``````#Charles Drummond PLDot
# 1/8/2020 Version 1.0 Sully attempt

def H = high;
def L = low;
def C = close;

# Calculate Averages

def A1 = (H + L + C) / 3;
def A2 = (H + L + C) / 3;
def A3 = (H + L + C) / 3;

def Average = (A1 + A2 + A3) /3;

# Plot the PLDot

plot PLDot = Average;
PLDot.SetLineWeight(3);
PLDot.SetStyle(Curve.POINTS);
PLDot.AssignValueColor(if Average > Average then Color.CYAN else Color.YELLOW);

#END PLDot CODE`````` #### Sully

##### New member
@tomsk

Thank you! It seems to be working perfectly with your modification and it is aligned with price now Great assist!!

• markos
T

#### tomsk

##### Well-known member
VIP
Glad it helped, essentially you had a typical math precedence issue. Use this as an opportunity to see the differences so that you can gain from the experience. Very minimal changes on my end modulo the color assignments.

H

#### HighBredCloud

##### Well-known member
VIP
Can this be made into a lower study? #### Sully

##### New member
@tomsk

Thank you! It seems to be working perfectly with your modification and it is aligned with price now Great assist!!
Yes, I noticed the brackets for the math - I had the same challenge during my dBaseIII coding days also How many people are asking what the hell is dBase III ... lol #### Sully

##### New member
Can this be made into a lower study?

Declare lower;

to the top of the code.

Drummond designed it to be used on price charts to see where the dots are in relation to price.

• HighBredCloud
H

#### HighBredCloud

##### Well-known member
VIP
@Sully But how do you make the dots straight and not resembling the upper study? #### Sully

##### New member
@Sully But how do you make the dots straight and not resembling the upper study?
I'm not sure what you are asking since the dots are the average of the last 3 averages. Not sure how to make the dots straight.
I yield to the group. #### horserider

##### Well-known member
VIP
Change dots to line in settings, hope that is what you are asking.

H

#### HighBredCloud

##### Well-known member
VIP
@horserider This is what I mean...make the dots straight not all over the place by simply declaring it lower...