NexusFi: Find Your Edge


Home Menu

 





recursion indicator


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
Degault
Novosibirsk Russia
 
Posts: 4 since May 2013
Thanks Given: 2
Thanks Received: 1

Hello, I worked with tradestation (easy language) and now trying to write one of indicators in ToS, but it goes very hard for me, so i need some help.
What I need:

I need to save my variable "X" at the end of day and during next day "new_var" = X*(1+a-b) and at the end of the day X=new_var. But I have problems, because i can't write like in EL:

def new_var;
def x;

new_var=X*(1+a-b);
X=new_var;

or smth like that, that's not working =(


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
GDP Day: The First Economic Reckoning -- Pahlavi at 6.55 …
Prediction Markets & Event Contracts
Day 97: Israel-Lebanon Ceasefire Struck Overnight -- WTI …
Traders Hideout
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
SEC and CFTC Unlock Customer Cross-Margining for Treasur …
Treasury Notes and Bonds
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 Cloudy 
desert CA
 
Experience: Intermediate
Platform: NT7, various
Broker: various, TDA
Trading: NQ,ES
Posts: 2,126 since Jul 2011
Thanks Given: 2,398
Thanks Received: 1,751


Degault View Post
Hello, I worked with tradestation (easy language) and now trying to write one of indicators in ToS, but it goes very hard for me, so i need some help.
What I need:

I need to save my variable "X" at the end of day and during next day "new_var" = X*(1+a-b) and at the end of the day X=new_var. But I have problems, because i can't write like in EL:

def new_var;
def x;

new_var=X*(1+a-b);
X=new_var;

or smth like that, that's not working =(

Hi, if you're using the daily time frame, then you can have TOS reference the previous day's bars and defined variables by [n] where "n" is number of days back.

So it could be:

def new_var;
def x;

new_var = x[1]+1;
x = new_var;

plot xgraph = x;


Which would draw a sloped line on the daily time chart space.

Or you can use the "fold" statement where you can specify an index range.
Learning Center ? Charting

input n = 70;
plot xgraph = fold n = 0 to n do x[n] + 1;


Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
Degault
Novosibirsk Russia
 
Posts: 4 since May 2013
Thanks Given: 2
Thanks Received: 1


I'm using intraday time frame, your answer helped me, but I still have no idea, how I can save my vars at the end of day. Is there smth like "If T=1630 then blah-blah"? =)


Reply With Quote
  #4 (permalink)
 Cloudy 
desert CA
 
Experience: Intermediate
Platform: NT7, various
Broker: various, TDA
Trading: NQ,ES
Posts: 2,126 since Jul 2011
Thanks Given: 2,398
Thanks Received: 1,751

Maybe this will work for you:

def newDay = if getDay() != getDay()[1] then 1 else 0;
def new_var;
def x;

new_var = x[1]+1;
x = if newDay then new_var else x[1];

plot xgraph = x;

# n5minbars is number of 5min bars in a day
def n5minbars = 288;
def daysback = 5;
plot xgraph2 = x[daysback * n5minbars ];



More time TOS time functions here:
Learning Center ? Charting


Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on May 30, 2013


© 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