Floor Trader Pivot Points For ThinkOrSwim

KCLLive

New member
Hi, new user to TOS and ThinkScript, thanks in advance for any help you guys can offer. I'm trying to calculate floor trader pivot levels
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@KCLLive Haven't looked at your script any, but Mobius of the TSL coded Floor Trader Pivots for ThinkorSwim a decade ago. I'm certainly not trying to dissuade you from continuing your script - I think it very commendable that you are actively trying vs wanting others to do the coding. This may make it easier.

Code:
# Floor Traders pivots (can be used in scanner)
# Mobius
# V01.06.2011

def Today = GetDay() == GetLastDay();
def Yesterday = GetDay() == GetLastDay() - 1;
def last = if Today and !Today[1]
           then close[1]
           else last[1];
def prevHigh = if YesterDay and !YesterDay[1]
               then high
               else if Yesterday and
                       high > prevHigh[1]
                    then high
               else prevHigh[1];
def prevLow = if Yesterday and !Yesterday[1]
              then low
              else if Yesterday and
                      low < prevLow[1]
                    then low
               else prevLow[1];
def BubbleLocation = !yesterday and yesterday[1];

plot pHigh = prevHigh;
pHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pHigh.SetDefaultColor(color.dark_green);
AddChartBubble(BubbleLocation, prevHigh, "Prev High", Color.DARK_GRAY, no);
plot pLow = prevLow;
pLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pLow.SetDefaultColor(color.dark_red);
AddChartBubble(BubbleLocation, prevLow, "Prev low", Color.DARK_GRAY, no);
plot pivot = (prevHigh + prevLow + last) / 3;
pivot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pivot.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, pivot, "Pivot", Color.DARK_GRAY, no);
plot R1 = Round(((2 * pivot) - prevLow) / TickSize(), 0) * TickSize();
R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R1.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R1, "R1", Color.DARK_GRAY, no);
plot S1 = Round(((2 * pivot) - prevHigh) / TickSize(), 0) * TickSize();
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S1, "S1", Color.DARK_GRAY, yes);
plot R2 = Round((pivot + (R1 - S1)) / TickSize(), 0) * TickSize();
R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R2, "R2", Color.DARK_GRAY, no);
plot S2 = Round((pivot - (R1 - S1)) / TickSize(), 0) * TickSize();
S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S2, "S2", Color.DARK_GRAY, yes);
plot R3 = Round((prevHigh + (2 * (pivot - prevLow))) / TickSize(), 0) * TickSize();
R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R3, "R3", Color.DARK_GRAY, no);
plot S3 = Round((prevLow - (2 * (prevHigh - pivot))) / TickSize(), 0) * TickSize();
S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S3, "S3", Color.DARK_GRAY, yes);
plot R4 = Round((prevHigh + (3 * (pivot - prevLow))) / TickSize(), 0) * TickSize();
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R4.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R4, "R4", Color.DARK_GRAY, no);
plot S4 = Round((prevLow - (3 * (prevHigh - pivot))) / TickSize(), 0) * TickSize();
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S4, "S4", Color.DARK_GRAY, yes);
AddLabel(1, "Yesterdays Close = " + last,
         if close > last then color.green
         else if close == last then color.cyan
         else color.red);

# Scan examples
# If you name this study "Floor_Trader_Pivots_Scan" you can reference the study in the scanner and scan for equities crossing above or below any of the plots using the format below.

# close crosses above Floor_Trader_Pivots_Scan()."R1"

# End Code Floor Trader Pivots
 
Last edited by a moderator:
@KCLLive Haven't looked at your script any, but Mobius of the TSL coded Floor Trader Pivots for ThinkorSwim a decade ago. I'm certainly not trying to dissuade you from continuing your script - I think it very commendable that you are actively trying vs wanting others to do the coding. This may make it easier.

Code:
# Floor Traders pivots (can be used in scanner)
# Mobius
# V01.06.2011

def Today = GetDay() == GetLastDay();
def Yesterday = GetDay() == GetLastDay() - 1;
def last = if Today and !Today[1]
           then close[1]
           else last[1];
def prevHigh = if YesterDay and !YesterDay[1]
               then high
               else if Yesterday and
                       high > prevHigh[1]
                    then high
               else prevHigh[1];
def prevLow = if Yesterday and !Yesterday[1]
              then low
              else if Yesterday and
                      low < prevLow[1]
                    then low
               else prevLow[1];
def BubbleLocation = !yesterday and yesterday[1];

plot pHigh = prevHigh;
pHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pHigh.SetDefaultColor(color.dark_green);
AddChartBubble(BubbleLocation, prevHigh, "Prev High", Color.DARK_GRAY, no);
plot pLow = prevLow;
pLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pLow.SetDefaultColor(color.dark_red);
AddChartBubble(BubbleLocation, prevLow, "Prev low", Color.DARK_GRAY, no);
plot pivot = (prevHigh + prevLow + last) / 3;
pivot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pivot.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, pivot, "Pivot", Color.DARK_GRAY, no);
plot R1 = Round(((2 * pivot) - prevLow) / TickSize(), 0) * TickSize();
R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R1.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R1, "R1", Color.DARK_GRAY, no);
plot S1 = Round(((2 * pivot) - prevHigh) / TickSize(), 0) * TickSize();
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S1, "S1", Color.DARK_GRAY, yes);
plot R2 = Round((pivot + (R1 - S1)) / TickSize(), 0) * TickSize();
R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R2, "R2", Color.DARK_GRAY, no);
plot S2 = Round((pivot - (R1 - S1)) / TickSize(), 0) * TickSize();
S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S2, "S2", Color.DARK_GRAY, yes);
plot R3 = Round((prevHigh + (2 * (pivot - prevLow))) / TickSize(), 0) * TickSize();
R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R3, "R3", Color.DARK_GRAY, no);
plot S3 = Round((prevLow - (2 * (prevHigh - pivot))) / TickSize(), 0) * TickSize();
S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S3, "S3", Color.DARK_GRAY, yes);
plot R4 = Round((prevHigh + (3 * (pivot - prevLow))) / TickSize(), 0) * TickSize();
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R4.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, R4, "R4", Color.DARK_GRAY, no);
plot S4 = Round((prevLow - (3 * (prevHigh - pivot))) / TickSize(), 0) * TickSize();
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetDefaultColor(color.dark_gray);
AddChartBubble(BubbleLocation, S4, "S4", Color.DARK_GRAY, yes);
AddLabel(1, "Yesterdays Close = " + last,
         if close > last then color.green
         else if close == last then color.cyan
         else color.red);

# Scan examples
# If you name this study "Floor_Trader_Pivots_Scan" you can reference the study in the scanner and scan for equities crossing above or below any of the plots using the format below.

# close crosses above Floor_Trader_Pivots_Scan()."R1"

# End Code Floor Trader Pivots

If you ever need or want a script and can't find it here at UseThinkscript, try https://tinyurl.com/tsCommunity - its a OneNote kept up by Johnny Quotron of the TSL. There's far more codes there than anyone could ever use.
Hi, thanks for the code can you share this study via TOS?
 
To get valid Floor Trader Pivots on Monday, is there a modification to be able to use Friday's data when working on a Monday daily chart, rather than using no data and getting no Floor Trader Pivots or using Sunday night's limited data? Thanks.
 
Good afternoon!
I was working on updating floor trading pivots and im running in this issue with code plotting next day:
b086eb4dc1aff940dc2f67319ba82f4e.png


Is there a way to hide it if i want? I wrote input PlotNextDay but not sure how to apply it to this

Code:

input Timeframe = AggregationPeriod.DAY;
input ShowOnlyToday = YES;
input PlotNextDay = YES;
input price = FundamentalType.CLOSE;

#declare hide_on_daily;

#Cloud Color
defineGlobalColor("Cloud", Color.VIOLET);

def high = high(period = Timeframe);
def low = low(period = Timeframe);
def close = close(period = Timeframe);

plot PP;
plot LOD;
plot HOD;
plot BC;
plot TC;

#RESITANCES / SUPPORTS

plot R1;
plot R2;
plot R3;
plot R4;

plot S1;
plot S2;
plot S3;
plot S4;

if ShowOnlyToday and !IsNaN(close(period = Timeframe)[-2])

then {

PP = Double.NaN;
LOD = Double.NaN;
HOD = Double.NaN;
BC = Double.NaN;
TC = Double.NaN;

# RESISTANCES / SUPPORTS

R1 = Double.NaN;
R2 = Double.NaN;
R3 = Double.NaN;
R4 = Double.NaN;

S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;

} else {


PP = (high[1] + low[1] + close[1]) / 3;
LOD = low[1];
HOD = high[1];
BC = (high[1] + low[1]) / 2;
TC = (PP - BC) + PP;

# RESISTANCES / SUPPORTS

R1 = 2 * PP - low[1];
R2 = PP + (high[1] - low[1]);
R3 = R1 + (high[1] - low[1]);
R4 = R3 + (R2 - R1);

S1 = 2 * PP - high[1];
S2 = PP - (high[1] - low[1]);
S3 = S1 - (high[1] - low [1]);
S4 = S3 - (S1 - S2);

}


#PLOT LINES
PP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LOD.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
HOD.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
BC.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
TC.setPaintingStrategy(PaintingStrategy.HORIZONTAL);

#SUPPORTS / RESISTANCES

R1.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
R4.setPaintingStrategy(PaintingStrategy.HORIZONTAL);

S1.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.setPaintingStrategy(PaintingStrategy.HORIZONTAL);

#ADD COLOR

PP.SetDefaultColor(color = Color.VIOLET);
LOD.SetDefaultColor(color = Color.LIGHT_ORANGE);
HOD.SetDefaultColor(color = Color.LIGHT_ORANGE);
BC.SetDefaultColor(color = Color.VIOLET);
TC.SetDefaultColor(color = Color.VIOLET);

R1.SetDefaultColor(color = Color.GRAY);
R2.SetDefaultColor(color = Color.GRAY);
R3.SetDefaultColor(color = Color.GRAY);
R4.SetDefaultColor(color = Color.GRAY);

S1.SetDefaultColor(color = Color.GRAY);
S2.SetDefaultColor(color = Color.GRAY);
S3.SetDefaultColor(color = Color.GRAY);
S4.SetDefaultColor(color = Color.GRAY);

#CLOUDS
AddCloud(BC, TC, color1 = globalColor("Cloud"), color2 = globalColor("Cloud"));


Thank you!
 
@GRINKT change the first line of your IF statement to this:
Ruby:
if (ShowOnlyToday and !IsNaN(close(period = Timeframe)[-2])) or (!PlotNextDay and IsNaN(close(period = Timeframe)))
 
Appreciate that i was doing or statement inside first if so i couldnt get it to work...
If anyone wants this, here my version of floor pivots - http://tos.mx/HZG74pF
Hi, I've enjoyed trying out your script and it works well. I have used and modified a few scripts from here, but I have fairly limited coding ability to be honest. I wonder if you know how to add a label above each pivot line that stays at the far right edge of the window, as shown in the picture I've attached - this is a Ninjatrader script.
 

Attachments

  • yesterday high correctly placed.png
    yesterday high correctly placed.png
    387.8 KB · Views: 137

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
446 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top