NexusFi: Find Your Edge


Home Menu

 





convert variable to constant


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
TrickyDick
Dallas Tx/USA
 
Posts: 2 since Jul 2012
Thanks Given: 0
Thanks Received: 0

how can i convert the close for today to a constant value that I can use in other calculations? I don't want to use code like x = close() because then x would vary each day.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Zytrade: Devin Brady, CEO - Ask Me Anything (AMA)
Brokers
White House Drops First Alien Files Today -- Market Says …
Prediction Markets & Event Contracts
ATFX Suspends Prop Trading Unit ATFunded -- Full Review …
Funded Trading Evaluation Firms
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
 ckkoh 
Singapore
 
Experience: Beginner
Platform: ThinkOrSwim, NinjaTrader
Trading: options, currency
Posts: 13 since Apr 2011
Thanks Given: 23
Thanks Received: 12

@TrickyDick

You can try the following. It is assigned to the first Close bar.

 
Code
double todayClose = 0; // initialized in OnStartup() 

// In OnBarUpdate()
if( todayClose == 0 )
   todayClose = Close[0];  // Assigned once only


Reply With Quote
  #3 (permalink)
TrickyDick
Dallas Tx/USA
 
Posts: 2 since Jul 2012
Thanks Given: 0
Thanks Received: 0


Thank you for responding, but I don't understand your answer for two reasons.
I pasted your code into a new ThinkOrSwim study, and the study rejected almost every line.
(1) TOS doesn't accept the word double. I tried double.NAN and other things but TOS still doesn't accept it.
(2) I think you're using '//' as a remark, but TOS requires '#' to show remarks
I changed '//' to '#' but then the script was still rejected because of (1) is an invalid statement

Would you please provide more information.
Thank you.


Reply With Quote




Last Updated on October 30, 2014


© 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