Assign value to the close price at a specific time - futures io
futures io futures trading



Assign value to the close price at a specific time


Discussion in Platforms and Indicators

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Assign value to the close price at a specific time

(login for full post details)
  #1 (permalink)
hong kong
 
 
Posts: 6 since May 2013
Thanks: 1 given, 1 received

Hi, I would like to assign the close of a specific time to a variable but I still couldn't figure out. I really appreciate if someone can give me a hand. The logic is as follows,

if time = 093000 then
refprice = close;

Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(154 thanks from 29 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(111 thanks from 32 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 16 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #2 (permalink)
Zurich/Switzerland
 
 
Posts: 79 since Oct 2014


sunsun View Post
Hi, I would like to assign the close of a specific time to a variable but I still couldn't figure out. I really appreciate if someone can give me a hand. The logic is as follows,

if time = 093000 then
refprice = close;

Not sure what you wanna do with it but here you can see the difference between using ValueWhen and Iif.
See the help description of those two functions

 
Code
timecondition = TimeNum() == 093000;
iifclose = IIf( timecondition, Close, Null );
valclose = ValueWhen( timecondition, Close );

// Plot
SetChartOptions( 0, chartShowDates | chartShowArrows | chartWrapTitle );
Plot( iifclose, "iifclose", colorRed, styleHistogram, Null, Null, 0, 0, width = -60 );
Plot( valclose, "valclose", colorOrange, styleLine, Null, Null, 0, 0, width = -20 );
If you wanna calculate some average or other calculations based on those specific time close prices only then you have to use different function(s). SparseCompress and SparseExpand. 5.91 has built-in functions of those ones, for older AB versions you have to use AFL functions. See AmiBroker 5.91.0 BETA Read Me

Reply With Quote
 
(login for full post details)
  #3 (permalink)
Zurich/Switzerland
 
 
Posts: 79 since Oct 2014



prouser View Post
If you wanna calculate some average or other calculations based on those specific time close prices only then you have to use different function(s). SparseCompress and SparseExpand. 5.91 has built-in functions of those ones, for older AB versions you have to use AFL functions. See AmiBroker 5.91.0 BETA Read Me


 
Code
// for versions lower than 5.91 use AFL functions of sparsecompress/expand
//http://www.amibroker.com/devlog/wp-content/uploads/2015/02/readme5910.html

Version( 5.91 );

SetBarsRequired( 10000, 10000 );

timecondition = TimeNum() == 093000;
only_when = timecondition; // only when condition
x = SparseCompress( only_when, Ref( Close, -1 ) ); // compact sparse data, Close of 09:29:59.999
y = MA( x, 10 ); // regular calculation
y = SparseExpand( only_when, y ); // expand sparse data

// Plot
SetChartOptions( 0, chartShowDates | chartShowArrows | chartWrapTitle );
Plot( C, "Price", colorDefault, styleBar, Null, Null, 0, 0, width = -20 );
Plot( ValueWhen( timecondition, y ), "Sparse MA from time condition", colorRed );

// exploration
Filter = timecondition;
AddColumn( Ref( Close, -1 ), "Close of 09:29:59.999", 1.5 );

Reply With Quote


futures io Trading Community Platforms and Indicators > Assign value to the close price at a specific time


Last Updated on March 3, 2015


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Identifying Setups & Targets Using Profile Charts w/Trevor & Tradovate

Feb 25
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts