NexusFi: Find Your Edge


Home Menu

 





Highest High Lowest Low


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one johnnymustard with 4 posts (0 thanks)
    2. looks_two StockT8er with 2 posts (0 thanks)
    3. looks_3 masterelf1 with 1 posts (0 thanks)
    4. looks_4 JayC with 1 posts (0 thanks)
    1. trending_up 2,452 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Highest High Lowest Low

  #1 (permalink)
 johnnymustard 
Las Vegas, NV
 
Experience: Intermediate
Platform: NT 8
Broker: NT Brokerage, IQFeed
Trading: ES, 6E & CL
Posts: 87 since Aug 2013
Thanks Given: 9
Thanks Received: 43

Hello,

Can anyone help me out with a ToS coding question?
I'm looking at the past 20 periods in total but it could be any number.
I'm trying to find the Highest High Value (HHV) and Lowest Low Value (LLV).
Starting with those 20 periods, I need a way to separate the first 10 periods
from the second 10 periods.

To keep things as simple as possible, let's ignore dates, weekends, holidays etc...
So if my 20 periods in total are December 1st to December 20th, then I'm trying to find
the HHV & LLV for Dec 1st thru the 10th.

And then find the HHV & LLV for Dec 11th thru the 20th. And finally find HHV & LLV for
Dec 1st thru the 20th. Without getting overly complicated here, I will then compare these
values for the indicator I'm writing.

I understand how to use displace (or at least I believe so). I can reference data from X periods
ago using something like "Close[10]" to get the closing price from 10 periods ago. I don't think
that's the problem I'm having.

I don't know how to get the HHV & LLV from between Dec 1st to Dec 10th. I do know how to find
HHV & LLV for Dec 11th to Dec 20th, HHV[10] will do it. And I know how to find HHV & LLV
for the entire 20 bars, LLV[20]. It's just that first 10 bars that I can't figure.

Using a start/stop date/time setup won't work because I use Range bars.
I tried to keep it simple but if there is any confusion, please let me know.
I certainly do appreciate any guidance on the topic.

I thank you and stay healthy,
JM

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Quant vue
Trading Reviews and Vendors
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 StockT8er 
ROY, Utah
 
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6

Try ToS Study ZigZagPercent

Reply With Quote
  #3 (permalink)
 johnnymustard 
Las Vegas, NV
 
Experience: Intermediate
Platform: NT 8
Broker: NT Brokerage, IQFeed
Trading: ES, 6E & CL
Posts: 87 since Aug 2013
Thanks Given: 9
Thanks Received: 43



StockT8er View Post
Try ToS Study ZigZagPercent

Thank you but apparently I don't know ToS code as well I was thought.
I don't see what I'm looking for in the 'ZigZagPercent'. I'll figure it out sooner or later.
Thanks again, JM

Started this thread Reply With Quote
  #4 (permalink)
 StockT8er 
ROY, Utah
 
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6

I'm not that great myself. I'm mostly self taught. Just study the code and experiment with different setting until you like the results

Reply With Quote
  #5 (permalink)
masterelf1
Roanoke
 
Posts: 5 since Apr 2017
Thanks Given: 0
Thanks Received: 11


johnnymustard View Post
Hello,

Can anyone help me out with a ToS coding question?
I'm looking at the past 20 periods in total but it could be any number.
I'm trying to find the Highest High Value (HHV) and Lowest Low Value (LLV).
Starting with those 20 periods, I need a way to separate the first 10 periods
from the second 10 periods.

To keep things as simple as possible, let's ignore dates, weekends, holidays etc...
So if my 20 periods in total are December 1st to December 20th, then I'm trying to find
the HHV & LLV for Dec 1st thru the 10th.

And then find the HHV & LLV for Dec 11th thru the 20th. And finally find HHV & LLV for
Dec 1st thru the 20th. Without getting overly complicated here, I will then compare these
values for the indicator I'm writing.

I understand how to use displace (or at least I believe so). I can reference data from X periods
ago using something like "Close[10]" to get the closing price from 10 periods ago. I don't think
that's the problem I'm having.

I don't know how to get the HHV & LLV from between Dec 1st to Dec 10th. I do know how to find
HHV & LLV for Dec 11th to Dec 20th, HHV[10] will do it. And I know how to find HHV & LLV
for the entire 20 bars, LLV[20]. It's just that first 10 bars that I can't figure.

Using a start/stop date/time setup won't work because I use Range bars.
I tried to keep it simple but if there is any confusion, please let me know.
I certainly do appreciate any guidance on the topic.

I thank you and stay healthy,
JM

I imagine you will have to just code explicitly from 20th bar to 10th bar and save the HHV and LLV found.
Then repeat from 10 bars out to current bar and do your compares. Not sure the is a premade indi that will give you what you are looking for.

Reply With Quote
  #6 (permalink)
 johnnymustard 
Las Vegas, NV
 
Experience: Intermediate
Platform: NT 8
Broker: NT Brokerage, IQFeed
Trading: ES, 6E & CL
Posts: 87 since Aug 2013
Thanks Given: 9
Thanks Received: 43


masterelf1 View Post
I imagine you will have to just code explicitly from 20th bar to 10th bar and save the HHV and LLV found.
Then repeat from 10 bars out to current bar and do your compares. Not sure the is a premade indi that will give you what you are looking for.


I didn't figure I'd get lucky enough to find something already written. I'm happy to write my own, just not sure how to.

Going from Dec 1st to Dec 20th from the original post, HHV[20-10] just uses last 10 bars in the calculation.
I was hoping that would use the 10 bars from Dec 1st to Dec 10th.
Unfortunately, all it does is use the last 10 bars, Dec 11th to Dec 20th.

The rub is that I'm only doing this on ToS because I can't write code in NT8 at all.
If it performs as expected, I'll pay to have it written for NT8.

The search goes on, thanks, JM

Started this thread Reply With Quote
  #7 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

This solution is a bit involved, but I couldn't think of an easier way to achieve your request. I used the BarNumber() function to create conditions to call highest or lowest at the correct time. Highest and Lowest already can lookback a specific number of bars.

Let me know if you have questions,
Jay


 
Code

input period1 = 20;
input period2 = 10;

def barNum = if IsNaN(close) then Double.NaN else barNumber();
def lastBar = HighestAll(barNum);
def barPeriod1 = if lastBar <= period1 then 1 else lastBar - period1 + 1;
def barPeriod2 = if lastBar <= period2 then 1 else lastBar - period2 + 1;

AddChartBubble(lastBar == BarNumber(), "price location" = HIGH, "Last: " + lastBar, Color.CYAN);
AddChartBubble(barPeriod1 == BarNumber(), "price location" = HIGH, "P1: " + barPeriod1, Color.CYAN);
AddChartBubble(barPeriod2 == BarNumber(), "price location" = HIGH, "P2: " + barPeriod2, Color.CYAN);


AddVerticalLine(barPeriod1 == BarNumber(), "Period1: " + BarNumber(), Color.CYAN);
AddVerticalLine(barPeriod2 == BarNumber(), "Period2: " + BarNumber(), Color.CYAN);

def period1Length = period1 - period2;
assert(period1Length > 0, "Period 1 needs to be greater than period 2");

def period1H = if barPeriod2 - 1 == BarNumber() then Highest(high, period1Length) else 0;
def period1L = if barPeriod2 - 1 == BarNumber() then Lowest(low, period1Length) else Double.POSITIVE_INFINITY;

plot period1High = HighestAll(period1H);
plot period1Low = LowestAll(period1L);

def period2H = if lastBar == BarNumber() then Highest(high, period2) else Double.NaN;
def period2L = if lastBar == BarNumber() then Lowest(low, period2) else Double.NaN;

plot period2High = HighestAll(period2H);
plot period2Low = LowestAll(period2L);


def overallH = if lastBar == BarNumber() then Highest(high, period1) else Double.NaN;
def overallL = if lastBar == BarNumber() then Lowest(low, period1) else Double.NaN;

plot overallHigh = HighestAll(overallH);
plot overallLow = LowestAll(overallL);

Reply With Quote
  #8 (permalink)
 johnnymustard 
Las Vegas, NV
 
Experience: Intermediate
Platform: NT 8
Broker: NT Brokerage, IQFeed
Trading: ES, 6E & CL
Posts: 87 since Aug 2013
Thanks Given: 9
Thanks Received: 43


JayC View Post
This solution is a bit involved, but I couldn't think of an easier way to achieve your request. I used the BarNumber() function to create conditions to call highest or lowest at the correct time. Highest and Lowest already can lookback a specific number of bars.

Let me know if you have questions,
Jay


 
Code

input period1 = 20;
input period2 = 10;

def barNum = if IsNaN(close) then Double.NaN else barNumber();
def lastBar = HighestAll(barNum);
def barPeriod1 = if lastBar <= period1 then 1 else lastBar - period1 + 1;
def barPeriod2 = if lastBar <= period2 then 1 else lastBar - period2 + 1;

AddChartBubble(lastBar == BarNumber(), "price location" = HIGH, "Last: " + lastBar, Color.CYAN);
AddChartBubble(barPeriod1 == BarNumber(), "price location" = HIGH, "P1: " + barPeriod1, Color.CYAN);
AddChartBubble(barPeriod2 == BarNumber(), "price location" = HIGH, "P2: " + barPeriod2, Color.CYAN);


AddVerticalLine(barPeriod1 == BarNumber(), "Period1: " + BarNumber(), Color.CYAN);
AddVerticalLine(barPeriod2 == BarNumber(), "Period2: " + BarNumber(), Color.CYAN);

def period1Length = period1 - period2;
assert(period1Length > 0, "Period 1 needs to be greater than period 2");

def period1H = if barPeriod2 - 1 == BarNumber() then Highest(high, period1Length) else 0;
def period1L = if barPeriod2 - 1 == BarNumber() then Lowest(low, period1Length) else Double.POSITIVE_INFINITY;

plot period1High = HighestAll(period1H);
plot period1Low = LowestAll(period1L);

def period2H = if lastBar == BarNumber() then Highest(high, period2) else Double.NaN;
def period2L = if lastBar == BarNumber() then Lowest(low, period2) else Double.NaN;

plot period2High = HighestAll(period2H);
plot period2Low = LowestAll(period2L);


def overallH = if lastBar == BarNumber() then Highest(high, period1) else Double.NaN;
def overallL = if lastBar == BarNumber() then Lowest(low, period1) else Double.NaN;

plot overallHigh = HighestAll(overallH);
plot overallLow = LowestAll(overallL);

Jay, WOW!!
I thank you very much. It certainly does appear to do what I'm looking for.
I really appreciate it.
Cheers & a Happy 2021 to you and yours.

Started this thread Reply With Quote




Last Updated on January 19, 2021


© 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