NexusFi: Find Your Edge


Home Menu

 





Need help with TOS Script


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,531 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
vicosobase
Detroit MI
 
Posts: 1 since Dec 2016
Thanks Given: 1
Thanks Received: 0

Please, can anyone help with this (ThinkOrSwim)? I am trying to display "BULLISH DAY" or "BEARISH DAY" based on whether the main PIVOT LINE is below or above the Previous Day Close.

That is if Main Pivot Line is above Previous Day Close, Display BEARISH and if Main Pivot Line is below Previous Day Close, Display BULLISH.

I have the below code but I am NOT skilled enough to make do the above. The attachment shows what the below code is showing, which is not what I want.

input aggregationPeriod = AggregationPeriod.DAY;

def PreDayClose = close(period = aggregationPeriod)[1];
def PH = high(period = aggregationPeriod)[1];
def PL = low(period = aggregationPeriod)[1];
def PC = close(period = aggregationPeriod)[1];

plot close = PreDayClose;
def PP = (PH + PL + PC) / 3;

def BULL = PP < PreDayClose;
def BEAR = PP > PreDayClose;

AddLabel(yes, "BULLISH =" + BULL, Color.GREEN);
AddLabel(yes, "BEARISH =" + BEAR, Color.YELLOW);


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trump Media to sell instant access to market-moving soci …
Traders Hideout
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
$500M Riding on World Cup 2026: France/Spain Co-Favored …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
ColoradoCliff
Parker CO/USA
 
Posts: 22 since Jun 2017
Thanks Given: 0
Thanks Received: 5

Well, there's a lot going on in your code that doesn't make a ton of sense to me, and there's no attachment so I can't see what you're seeing on your charts.

First, are you wanting to calculate the pivot based on the previous day's price action, or the current day's action? If it's the current day's price pivot, get rid of all the [1] subscripts when calculating the Pivot

Secondly, you're always going to show both the BULLISH & BEARISH labels, why not just show the label that matches the condition you care about?

Thirdly, it's not clear what timeframe charts you will typically use this -- I'm assuming an Intraday rather than Daily/Weekly.

I've changed a few things and added some additional AddLabels to help with diagnosing the code (comment or delete the extra AddLabel statements when you get what you want.

input aggregationPeriod = AggregationPeriod.DAY;

def PreDayClose = close(period = aggregationPeriod)[1];
def PH = high(period = aggregationPeriod)[1];
def PL = low(period = aggregationPeriod)[1];
def PC = close(period = aggregationPeriod)[1];

def PP = (PH + PL + PC) / 3;

def BULL = PP < PreDayClose;
def BEAR = PP > PreDayClose;

plot myClose = PreDayClose;
plot myPivot = PP;

AddLabel(yes,"PH/PL/PC= " + PH + " / " + PL + " / " + PC);


AddLabel(BULL, "BULLISH", Color.GREEN);
AddLabel(BEAR, "BEARISH", Color.YELLOW);



vicosobase View Post
Please, can anyone help with this (ThinkOrSwim)? I am trying to display "BULLISH DAY" or "BEARISH DAY" based on whether the main PIVOT LINE is below or above the Previous Day Close.

That is if Main Pivot Line is above Previous Day Close, Display BEARISH and if Main Pivot Line is below Previous Day Close, Display BULLISH.

I have the below code but I am NOT skilled enough to make do the above. The attachment shows what the below code is showing, which is not what I want.

input aggregationPeriod = AggregationPeriod.DAY;

def PreDayClose = close(period = aggregationPeriod)[1];
def PH = high(period = aggregationPeriod)[1];
def PL = low(period = aggregationPeriod)[1];
def PC = close(period = aggregationPeriod)[1];

plot close = PreDayClose;
def PP = (PH + PL + PC) / 3;

def BULL = PP < PreDayClose;
def BEAR = PP > PreDayClose;

AddLabel(yes, "BULLISH =" + BULL, Color.GREEN);
AddLabel(yes, "BEARISH =" + BEAR, Color.YELLOW);


Reply With Quote
Thanked by:




Last Updated on June 19, 2022


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts