NexusFi: Find Your Edge


Home Menu

 





Plotting agg variables


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
aquaticnomad
Los Angeles CA
 
Posts: 2 since Jun 2017
Thanks Given: 0
Thanks Received: 0

Trying to render multiple plots of a given variable throughout different aggregations.

Working with standard code for Ichimoku indicator. Lets get into it:

 
Code
input tenkan_period = 9;
input kijun_period = 26;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

rec spanALast = CompoundValue(1, if IsNaN(close[-1]) and !IsNaN(close) then "Span A"[-kijun_period] else spanALast[1], Double.NaN);
rec spanBLast = CompoundValue(1, if IsNaN(close[-1]) and !IsNaN(close) then "Span B"[-kijun_period] else spanBLast[1], Double.NaN);
plot trackSpanA = spanALast;

This plots the ichimoku indicator as well as drawing a horizontal line of the value of SPAN A for whichever time frame chart you are on. What I would like to add next is an additional plot of SPAN A's value for a different time frame.

I know that you can use
 
Code
period = Aggregation.DAY
to reference different time frames, but I don't know how to point that aggregation to a specific value to be plotted.

Can anyone point me in the right direction?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Warsh Confirmed 54-45 on PPI Day -- 97% Say He Holds in …
Prediction Markets & Event Contracts
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
Roland Garros Final Day: $3M on Zverev at 80.5% -- Leban …
Prediction Markets & Event Contracts
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
devildriver6
Dallas, Texas
 
Posts: 43 since Jun 2015
Thanks Given: 2
Thanks Received: 32


aquaticnomad View Post
Trying to render multiple plots of a given variable throughout different aggregations.

Working with standard code for Ichimoku indicator. Lets get into it:

 
Code
input tenkan_period = 9;
input kijun_period = 26;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

rec spanALast = CompoundValue(1, if IsNaN(close[-1]) and !IsNaN(close) then "Span A"[-kijun_period] else spanALast[1], Double.NaN);
rec spanBLast = CompoundValue(1, if IsNaN(close[-1]) and !IsNaN(close) then "Span B"[-kijun_period] else spanBLast[1], Double.NaN);
plot trackSpanA = spanALast;

This plots the ichimoku indicator as well as drawing a horizontal line of the value of SPAN A for whichever time frame chart you are on. What I would like to add next is an additional plot of SPAN A's value for a different time frame.

I know that you can use
 
Code
period = Aggregation.DAY
to reference different time frames, but I don't know how to point that aggregation to a specific value to be plotted.

Can anyone point me in the right direction?


To plot variable timeframes, you have to adjust the coding as follows....

first, add adjustable TF....
then, adjust "close" to show that TF....
any coding that goes into the adjustable TF has to be fixed as well.... So, for Span A, you have to correct the Tenkan and Kijun coding....

input Period1 = aggregationPeriod.DAY;
input Period2 = aggregationPeriod.WEEK;

def Period1_Tenkan = (Highest(high(Period = Period1), tenkan_period) + Lowest(low(Period = Period1), tenkan_period)) / 2;
def Period1_Kijun = (Highest(high(Period = Period1), kijun_period) + Lowest(low(Period = Period1), kijun_period)) / 2;
plot Period1_SpanA = (Period1_Tenkan[kijun_period] + Period1_Kijun[kijun_period]) / 2;

def Period2_Tenkan = (Highest(high(Period = Period2), tenkan_period) + Lowest(low(Period = Period2), tenkan_period)) / 2;
def Period2_Kijun = (Highest(high(Period = Period2), kijun_period) + Lowest(low(Period = Period2), kijun_period)) / 2;
plot Period2_SpanA = (Period2_Tenkan[kijun_period] + Period2_Kijun[kijun_period]) / 2;


Now, the Kijun and Tenkan are looking for highs and lows from your input value, which is day and week.
Then, your different SPAN A's are using the adjusted TF values accordingly.

Make sense?


Reply With Quote




Last Updated on September 4, 2017


© 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