NexusFi: Find Your Edge


Home Menu

 





convert variable to constant


Discussion in ThinkOrSwim

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




 
Search this Thread

convert variable to constant

  #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?
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didnĀ“t know anyth …
Psychology and Money Management
How to apply profiles
Traders Hideout
What broker to use for trading palladium futures
Commodities
Better Renko Gaps
The Elite Circle
 
  #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


© 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