Tradestation 2000i: Standard Error Channels
Hallo,
Ist es möglich, die Standardfehlerführungen zu zeichnen, die an einem spezifischen Datum wie einem niedrigen Gelenk oder an einem Gelenktief in TradeStaion eginnen code.
Sehen Sie das Beispiel unten durch Metatrader, der für Standardfehlerführungen MetaStock geschrieben wird. (und ChartTec) kann das Hoffen Sie verbinden,
Bester respekt,
Derek
______________________________________________________________________________
Hello,
Is it possible to draw Standard Error Channels starting at a specific date like a Pivot low or a Pivot low in TradeStaion code.
See the example below by Metatrader written for MetaStock Standard Error Channels. (And ChartTec)
Hoping you can oblige,
Best Regards,
Derek
==============================================================================
{Script for MetaStock 7.0+}
{Open Source: Veröffentlichung bitte nur inkl. Kommentaren}
{Automatischer Trendkanal, entwickelt von Claus Lampert / http://www.charttec.de}
{Open source: for free publishing. Please include comments}
{Automatic trend-channel, developed by Claus Lampert / http://www.charttec.de}
{Please enter a valid for a Pivot Point in the form}
{C1 Day of Pivot}
{C1 Month of Pivot}
{C3 Year of Pivot}
{Input: Trendshift: number of bars on the right side of the chart NOT used for calculation}
{output:}
{outsideUP=True; indicates a LOW above the UpperLine}
{outsideDOWN=True; indicates a HIGH below the LowerLine}
{Standard Error Channel from a Pivot Point to the last day - Trendshift days}
C1:=Input("Day ",1,31,23);
C2:=Input("Month ",1,12,7);
C3:=Input("Year ",1900,2100,2004);
d1:=c2*10000 + c1* 100 + c3;
Now:=Month()*10000+DayOfMonth()*100 + Year();
Trendlaenge:=LastValue(BarsSince(d1=now));
TrendShift:=Input("Verschiebung/Shift",0,50,0);
TrendStart:=LastValue(Ref(LinearReg(C,Trendlaenge),-TrendShift)- Ref(LinRegSlope(C,Trendlaenge),-TrendShift)*Trendlaenge);
TrendZiel:=LastValue(Ref(LinearReg(C,Trendlaenge),-TrendShift)+TrendShift*Ref(LinRegSlope(C,Trendlaenge),-TrendShift));
TrendDevi:=LastValue(2*Ref(STE(C,Trendlaenge),-TrendShift));
TrendDeltaVertical:= TrendZiel - TrendStart;
TrendDeltaHorizontal:=Trendlaenge+TrendShift;
TrendDeltaPerBar:= TrendDeltaVertical / TrendDeltaHorizontal;
TrendBarNoStart:= LastValue(
Cum(1) - TrendDeltaHorizontal);
Trend:= If(Cum(1) < TrendBarNoStart,
BarsSince(Cum(1) >= TrendBarNoStart),
TrendStart +
(TrendDeltaPerBar * (Cum(1) - TrendBarNoStart)));
CenterLine:=Trend;
Upperline:=Trend+TrendDevi;
LowerLine:=Trend-TrendDevi;
outsideUP:=If(L>(Trend+TrendDevi),true,0);
outsideDOWN:=If(H<(Trend-TrendDevi),true,0);
CenterLine;
UpperLine;
LowerLine;
{end}
---
The following TradeStation code seams to do the trick:
______________________________________________________________________________
{This Indicator plots Linear Regression Line Provided By: Omega Research, Inc. (c) Copyright 1999
Modified By: Clyde Lee (c) 2000,include parallel lines.
Add start date, start-end date
Definition.
********************************************************************}
inputs: Length(60),
{This is set to difference in Start & End dates if both are specified and is ignored
then}
{if set to zero and begin (but not end) date is }
{specified then length is from begin date to}
{last bar on chart}
{NOTE: If length is specified and begin/end date}
{and time are set to zero then trendline and the}
{channel lines if specified are calculated (and}
{in real time updated) from the last bar on the}
{chart backwards for length specified.}
BegDate(0), {YYYMMDD-if specified fixes begin of compute}
BegTime(0), {Set to zero to ignore time }
EndDate(0), {YYYMMDD-if specified fixes end of compute}
EndTime(0), {Set to zero to ignore time}
ColSizMd(6.1), {x.y x=color y=line size (0-6) for mid line }
{Black=1, Blue=2, Cyan=3, Green=4,}
{Magenta=5, Red=6, Yellow=7, White=8,}
{DarkBlue=9}
{DarkCyan=10, DarkGreen=11, DarkMagenta=12,}
{DarkRed=13, DarkBrown=14, DarkGray=15,} {LightGray=16}
{You can use: red+. 1 (red color, size=1)}
{if you do this DO NOT FORGET THE DECIMAL B4 LINE}
ExtRight(True), {Set false for no extension to mid/channel lines }
ChanWide(2), {Multiplier of StdDev(c,Length) to set width }
ColSizCh(2.1); {x.y x=color y=line size for channel lines }
variables:
LRV(0), {Current linear regression value} LRVAgo(0),
{Linear regression value at begin of lines}
TLLRV(0),TLLRV1(0),TLLRV2(0), {TL ID's for mid and channel lines} Flag(0),
{basically the mode of operation} ChanStdD(0),
{Use initial standard deviation computation}
UseLength(Iff(BegDate>0,0,Length)), UseEndDate(EndDate),
UseEndTime(EndTime), UseBeginDate(BegDate),
UseBeginTime(BegTime), UseColor(ColSizMd-1),
BeginBar(0);Variables: MidColor(IntPortion(ColSizMd)),
MidSize (IntPortion((ColSizMd-MidColor)*10)),
ChnColor(IntPortion(ColSizCh)), ChnSize
(IntPortion((ColSizCh-ChnColor)*10));
If UseBeginDate>0 then begin
{If begin date then find out and set BeginBar variable} If
Date>=BegDate and Time>=BegTime and BeginBar=0 then
begin BeginBar=CurrentBar; End Else if
BeginBar>0 then begin {Begin date detected so now look
for end date and set when found} If EndDate>0 or
lastbaronchart then begin if (Date>=EndDate
and Time>=EndTime) or LastBarOnChart then
begin
UseLength=CurrentBar-BeginBar;
UseEndDate=Date;
UseEndTime=Time;
UseBeginDate=0;
end else if date<EndDate then
UseLength=0; End Else If
CurrentBar=BeginBar+Length then begin {If
length specified & no end date just set
end}
UseLength=Length;
UseEndDate=Date;
UseEndTime=Time;
UseBeginDate=0; End; End;End;
{Once we have a good length then proceed to
compute/draw lines}If UseLength>0 then begin
if LastBarOnChart and EndDate=0 and Flag=0 then
begin Flag=1 ; end ; if
Date=UseEndDate and (Time=UseEndTime or UseEndTime=0) and Flag=0 then
begin Flag=2 ; end ; if
Flag=1 or Flag=2 then begin
LRV
=LinearRegValue(Close,UseLength,0) ;
Value1=LinearRegSlope(Close,UseLength) ;
LRVAgo=LRV-(UseLength-1)*Value1;
If Flag[1]=0 then
begin {If this is first time to draw then we must define the trendlines}
TLLRV=TL_New(Date[UseLength-1],Time[UseLength-1],LRVAgo,Date,Time,LRV)
; TL_SetColor (TLLRV,MidColor)
; TL_SetSize
(TLLRV,MidSize); TL_SetExtLeft(TLLRV,false)
;
Plot1(LRV,"ell");
{SetPlotColor(1,UseColor);} If ChanWide>0
then begin {Setup channel lines if
specified}
ChanStdD=StdDev(c,UseLength)*ChanWide;
TLLRV1=TL_New(Date[UseLength-1],Time[UseLength-1],LRVAgo+ChanStdD,Date,Time,LRV+ChanStdD)
;
TLLRV2=TL_New(Date[UseLength-1],Time[UseLength-1],LRVAgo-ChanStdD,Date,Time,LRV-ChanStdD)
; End;
End; if Flag=1 then
begin {If not first time and we are moving
lines then just update trendlines}
TL_SetBegin(TLLRV,Date[UseLength-1],Time[UseLength-1],LRVAgo)
; TL_SetEnd (TLLRV,Date,Time,LRV)
;
Plot1(LRV,"ell"); {Move start/end of channel
lines if specified} If ChanWide>0 then
begin
TL_SetBegin(TLLRV1,Date[UseLength-1],Time[UseLength-1],LRVAgo+ChanStdD)
; TL_SetEnd
(TLLRV1, Date, Time, LRV+ChanStdD) ;
TL_SetBegin(TLLRV2,Date[UseLength-1],Time[UseLength-1],LRVAgo-ChanStdD)
; TL_SetEnd
(TLLRV2, Date, Time, LRV-ChanStdD);
End; end;
if Flag=2
then Flag=3 ;
{Set colors, extensions,
width of line for median line} TL_SetColor
(TLLRV,MidColor) ; TL_SetSize
(TLLRV,MidSize); TL_SetExtLeft(TLLRV,false)
; if ExtRight
then TL_SetExtRight(TLLRV,true)
else TL_SetExtRight(TLLRV,false) ; If
ChanWide>0 then begin {Set colors,
extensions, width of line for channel lines}
TL_SetColor (TLLRV1,ChnColor) ;
TL_SetColor (TLLRV2,ChnColor) ;
TL_SetSize (TLLRV1,ChnSize);
TL_SetSize (TLLRV2,ChnSize);
TL_SetExtLeft(TLLRV1,false) ;
TL_SetExtLeft(TLLRV2,false) ; if ExtRight then
begin
TL_SetExtRight(TLLRV1,true);
TL_SetExtRight(TLLRV2,true);
end else
begin TL_SetExtRight(TLLRV1,false)
; TL_SetExtRight(TLLRV2,false)
; end; End;
end ;
End; {End of loop waiting for end date if begin date specified}
{*** Copyright (c) 1991-2000 TradeStation. All rights reserved. ***}
_____________________________________________________________________________
Have fun.
Derek