Converting Drummond PLDot to Thinkscript?

Sully

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[1],l[1],c[1])
b=avg(h[2],l[2],c[2])
t=avg(h[3],l[3],c[3])
k=a+b+t
Pldot=k/3
Cosodelcolor = input(title="Cosodelcolor ?", type=bool, defval=true)

Pldotcolor= Cosodelcolor ? (Pldot > Pldot[1] ? 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[1] + L[1] + C[1] / 3;
def A2 = H[2] + L[2] + C[2] / 3;
def A3 = H[3] + L[3] + C[3] / 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[1],l[1],c[1])
b=avg(h[2],l[2],c[2])
t=avg(h[3],l[3],c[3])
k=a+b+t
Pldot=k/3
Cosodelcolor = input(title="Cosodelcolor ?", type=bool, defval=true)

Pldotcolor= Cosodelcolor ? (Pldot > Pldot[1] ? 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[1] + L[1] + C[1] / 3;
def A2 = H[2] + L[2] + C[2] / 3;
def A3 = H[3] + L[3] + C[3] / 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[1] + L[1] + C[1]) / 3;
def A2 = (H[2] + L[2] + C[2]) / 3;
def A3 = (H[3] + L[3] + C[3]) / 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[1] then Color.CYAN else Color.YELLOW);

#END PLDot CODE
 
Sully

Sully

New member
@tomsk

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

Great assist!!
 
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

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
 
H

HighBredCloud

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

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

horserider

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

Similar threads

Top