help needed yHOD values and trendline drawstarttime issues for todays chart - futures io
futures io futures trading

help needed yHOD values and trendline drawstarttime issues for todays chart

Discussion in TradeStation

    1. trending_up 1,524 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 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

help needed yHOD values and trendline drawstarttime issues for todays chart

(login for full post details)
  #1 (permalink)
Mound, MN
Posts: 3 since Feb 2016
Thanks: 0 given, 0 received

Hi, I have coded a Yesterday HOD indicator that draws from my specified start time and has an alert associated with a cross over of YHOD. HOWEVER, I want the YHOD timeframe to be regular trading hours, 0830-1500 central, but draw the lines from 0700 to 1600 on todays chart. When I put in the specified values into my Vector time (yesterday) and DrawStartTime (today) it will only draw the line correctly if I make the DrawStartTime later then yesterdays calculation timeframe. For example, if the calculation timefram is 0830-1500, I can't have my start my drawstarttime earlier than 0835 if I want the trendline to plot correctly on todays chart, otherwise it is not horizontal.

Any help would be appreciated!

Here is my code: I want the draw start time to be 0700-1600 on todays chart

{This indicator is designed to plot the period high and low for a time period set by
the "StartTime" and "EndTime" inputs. The OHLCV calculations are reset when the new
time period starts as evaluated by the "ResetCalcs" calculations.

This indicator is intended for application only to intraday bars (tick or time-

Commentary on the use of vectors for OHLCV, along with calculation explanations,
can be found in the "OHLCVCollection" function.

*** This indicator was customized to allow the start and ending times of when
the trend lines are draw can be controlled with inputs and the trend line
values are labeled.}

{ code will use classes from these namespaces }
using elsystem ;
using elsystem.collections ;

int NumSubSessionsAgo( 1), { number of sub-sessions ago; use zero to refer to
the current sub-session }
int StartTime( 0830), { start time for OHLCV calculations }
int EndTime( 1500), { end time for OHLCV calculations }

int DrawStartTime( 0835), // *** user input to control when trend lines start
int DrawEndTime( 1600) ; // *** user input to control when trend lines end

Vector OHLCV_Vector( NULL ), { this is the vector that will be passed by
reference to the function OHLCVCollection; it will hold all the OHLCV values }
Vector HighVector( NULL ), { High Prices }
bool ResetCalcs( false ),
bool IncludeThisBar( false ),
int RtnValOrErrorCode( 0 ), { variable to hold the value returned by call to
OHLCVCollection function }
intrabarpersist bool ValuesAvailable( false ), { used to ensure that there is
enough data in the vector before requesting a value }
double SubSessionHigh( -1 ), { holds High of NumSessionsAgo }

HighTLID (0),
Lev1Txt (0);

// *** Change from Init to InitializeComponent so this code runs
// first thing before the OHLCVCollections function does, else we
// we will get an object not found error
method override void InitializeComponent() begin

if BarType >= 2 then
RaiseRuntimeError( "Price Channel (Time-based) can be applied to " +
"intraday bars only." ) ;

OHLCV_Vector = new Vector ;
HighVector = new Vector ;

end ;

{ condition upon which OHLCV values will be reset for next period }
ResetCalcs = ( Time > StartTime and Time[1] <= StartTime )
or ( Time > StartTime and Time[1] > Time )
or ( Time[1] > Time and StartTime > Time[1] ) ;

{ IncludeThisBar is passed in to OHLCVCollection to designate whether this bar is to
be used in the OHLCV calcultions. This variable is true if the bar falls within the
time frame established by the StartTime and EndTime inputs and false if the bar is
outside the time frame. }

IncludeThisBar = IFFLogic( StartTime > EndTime, Time > StartTime or Time <= EndTime,
Time > StartTime and Time <= EndTime ) ;

RtnValOrErrorCode = OHLCVCollection( ResetCalcs, IncludeThisBar, OHLCV_Vector ) ;

{ set-up HighVector }
HighVector = OHLCV_Vector[1] astype Vector ; { [1] = High Price }
end ;

{ only allow retrieval of data once there is enough data loaded into the vector }
once ( RtnValOrErrorCode > NumSubSessionsAgo )
ValuesAvailable = true ;

if ValuesAvailable then begin

SubSessionHigh = HighVector.At( NumSubSessionsAgo ) astype double ;

// *** If the prior bar time is less than the draw start time but the
// current bar time is greater than the draw start time then we are on the
// first bar of the draw time window, so create the high and low trend lines
// as initial points with the start and end values
if Time[1] < DrawStartTime and Time >= DrawStartTime then begin

HighTLID = TL_New( Date, Time, SubSessionHigh, Date, Time, SubSessionHigh ) ;

// Set the high trend line to light blue and the low trend line to purple
Value1 = TL_SetColor( HighTLID, magenta) ;
Value1 = TL_SetSize (HighTLID, 1);
Value1 = Tl_SetStyle (HighTLID,1);

// Create a text label of the subsession high value above the subsession high trend line


// *** Else if we have a high trend line ID defined and the time is between
// the draw start and end times, stretch out the end of the high and low
// trend lines to the current date/time
else if HighTLID > 0 and Time >= DrawStartTime and Time <= DrawEndTime then begin
Value1 = TL_SetEnd( HighTLID, Date, SessionendTime(1,1), SubSessionHigh ) ;
end ;

{alert criteria}
If C Crosses Above HighTLID then begin
Alert ("> YHOD - Bullish");


Reply With Quote

Can you help answer these questions
from other members on futures io?
Neurological explanations for trading Success
Psychology and Money Management
NT8 indicator to simulate a Funding Evaluation where to …
Cross border fund flows / fx correlations
Treasury Notes and Bonds
If ES tracks SPX, why do support/resistance, Level 2, vo …
Emini and Emicro Index
Second Entry Indicator (Looking for testers/feedback)
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
111 thanks
Selling Options on Futures?
109 thanks
Rank your Futures vs Stocks trading priority
37 thanks
Want your NinjaTrader indicator created, free?
26 thanks
Bitcoin storage wallet recommendations
18 thanks
(login for full post details)
  #2 (permalink)
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received


it probably has something to do with at what time that you update the values in the vector, but this is just a guess as your post doesn't include all the code. My guess is that the vector is updated at the beginning of the new tracking period. So if you try to draw a trendline before that, the vector would not yet include the most recent high.



Follow me on Twitter Reply With Quote

futures io Trading Community Platforms and Indicators TradeStation > help needed yHOD values and trendline drawstarttime issues for todays chart

Last Updated on December 16, 2016

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


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


Importance of Finding Your Own Way w/Adam Grimes

Elite only

Journal Challenge w/Jigsaw


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