NexusFi: Find Your Edge


Home Menu

 





help needed yHOD values and trendline drawstarttime issues for todays chart


Discussion in TradeStation

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




 
Search this Thread

help needed yHOD values and trendline drawstarttime issues for todays chart

  #1 (permalink)
Scalpin
Mound, MN
 
Posts: 3 since Feb 2016
Thanks Given: 0
Thanks Received: 0

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-
based).

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 ;

inputs:
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

variables:
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 }
once
begin
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

end

// *** 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");

end;
end;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Scalpin,

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.

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on December 16, 2016


© 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