Intraday Range on minutes chart with Trend Line


Category:
0
0

Hello Pete,

I been working on one custom indicator on Trade station where it put Trend Line at the High and Lows of time range ,also put a Text at High and Low value with Total range (High – Low) ,and it should work on any minutes chart ,

Here is so far i got into this indicator code ,currently code put a Trend line at High and lows of specific time range , but I have notice some issue with it and need your help with it please

Issue 1) Multiple trend line on top of one another , If time range is 60 min then on chart i see 60 Trend line at High and 60 trend line at the lows
Issue 2) Multiple Highs and lows range on chart Historically is fine , but I have noticed multiple range within same time range
I have attached image one with issue I’m having with this indicator when i plot on chart , and one image which i’m trying to achieve as a end results

Here is the trade station code

Input: StratTime(1400),
EndTime(1530);

Vars: PeriodHigh(0),
LastPeriodHigh(0),
PeriodLow( 999999 ),
LastPeriodLow( 999999 );

// Find High
If T >= StratTime and T <= EndTime then
Begin
If H > PeriodHigh then PeriodHigh = H;
If L < PeriodLow then PeriodLow = L;
End;

If T > EndTime and T[1] <= EndTime then
Begin
LastPeriodHigh = PeriodHigh;
PeriodHigh = 0;
LastPeriodLow = PeriodLow;
PeriodLow = 999999;
End ;

Value1 = TL_New (D,StratTime,LastPeriodHigh ,D,EndTime,LastPeriodHigh );
TL_setcolor (Value1, DarkGreen);
Tl_setsize (Value1, 1);

Value2 = TL_New (D,StratTime,LastPeriodLow ,D,EndTime,LastPeriodLow );
TL_setcolor (Value2, RED);
Tl_setsize (Value2, 1);

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on December 21, 2018 9:39 am
160 views
0
Private answer

Working with drawing objects in TradeStation is a bit more complex than is provided by your code. Drawing objects must be created once (inside of a Once/Begin statement). Then you assign their values and properties. When you try to create them outside of a Once/Begin statement you will get replication of trendlines as you have described.

The solution is a bit more complex than what we provide for no charge in the Q&A forum. But perhaps I have given you enough information that you can work out the rest on your own. Be sure to find some trendline based studies included with TradeStation and examine their code to understand how it’s done properly.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on December 24, 2018 8:58 am