NexusFi: Find Your Edge


Home Menu

 





Need help with TOS Script


Discussion in ThinkOrSwim

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




 
Search this Thread

Need help with TOS Script

  #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?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts