NexusFi: Find Your Edge


Home Menu

 





Plotting agg variables


Discussion in ThinkOrSwim

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




 
Search this Thread

Plotting agg variables

  #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?
Are there any eval firms that allow you to sink to your …
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 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


© 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