NexusFi: Find Your Edge


Home Menu

 





Assign value to the close price at a specific time


Discussion in Platforms and Indicators

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




 
Search this Thread
  #1 (permalink)
sunsun
hong kong
 
Posts: 6 since May 2013
Thanks Given: 1
Thanks Received: 1

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

Can you help answer these questions
from other members on NexusFi?
How reliable is ninjatrader 8?
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Brendt Skorupinsky
Trading Reviews and Vendors
MC Advanced Simulated Trading.
MultiCharts
What You Know vs How much you know about it
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
ApexTraderFunding.com experience and review
140 thanks
1 Minute Man
64 thanks
HumbleTraders next chapter
35 thanks
GFIs1 1 DAX trade per day journal
24 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
23 thanks
  #2 (permalink)
 prouser 
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 [AUTOLINK]BETA[/AUTOLINK] Read Me

Reply With Quote
  #3 (permalink)
 prouser 
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 [AUTOLINK]BETA[/AUTOLINK] 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




Last Updated on March 3, 2015


© 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