NexusFi: Find Your Edge


Home Menu

 





Need help with TOS Script


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,466 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?
Strike Pause Holds, Oil Erases Monday Spike -- May CPI W …
Traders Hideout
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 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