NexusFi: Find Your Edge


Home Menu

 





recursion indicator


Discussion in ThinkOrSwim

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




 
Search this Thread

recursion indicator

  #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?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 Cloudy 
desert CA
 
Experience: Intermediate
Platform: NT7, various
Broker: various, TDA
Trading: NQ,ES
Posts: 2,124 since Jul 2011
Thanks Given: 2,396
Thanks Received: 1,748


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,124 since Jul 2011
Thanks Given: 2,396
Thanks Received: 1,748

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


© 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