All for whom want to be Richer.
沒有經過學習就直接去交易,就像是沒經過外科訓練就直接去開刀。
如果不知道怎麼交易獲利,應該先學習和思考成功交易者的作法。
站內的程式碼僅供Tradestation與Multicharts學習使用,不代表獲利保證,直接用於交易者請自己承擔盈虧責任。
(程式碼) Trend Lines Automatic - System
[LegacyColorValue = TRUE];
{ *****************************************************************************************
Study : Trend Lines Automatic - System
*******************************************************************************************}
Inputs: RHStren(6), RLStren(6), Trailbar(6);
Vars: RHTLRef(-1), RHTLRef2(-1), RHSet(-1), RHSet2(-1), RHArrayVal(0), RHColorVar(0), RLColorVar(0), BarsPast(0);
Vars: RLTLRef(-1), RLTLRef2(-1), RLSet(-1), RLSet2(-1),RLArrayVal(0), BuyPrice(0), PrevBuyPrice(0), SellShortPrice(0), PrevSellShortPrice(0);
Array: RHDate[10](0), RHTime[10](0), RHVal[10](0);
Array: RLDate[10](99999), RLTime[10](99999), RLVal[10](99999);
{ Find new Swing High bars and draw corresponding trend lines }
If SwingHighBar(1, High, RHStren, RHStren+1)=RHStren then begin
for Value1=9 downto 0 begin
RHDate[Value1+1]=RHDate[Value1];
RHTime[Value1+1]=RHTime[Value1];
RHVal[Value1+1]=RHVal[Value1];
end;
RHDate[0]=Date[RHStren];
RHTime[0]=Time[RHStren];
RHVal[0]=High[RHStren];
for Value22=1 to 10 begin
If RHVal[Value22]>RHVal[0] then begin
RHArrayVal=Value22;
Value22=11;
end;
End;
If Value22<>11 then begin
If RHSet>=0 then begin
RHSet2=TL_SetExtRight(RHTLRef, False);
TL_Delete(RHTLRef);
end;
RHTLRef=TL_New(RHDate[RHArrayVal], RHTime[RHArrayVal], RHVal[RHArrayVal], RHDate[0], RHTime[0], RHVal[0]);
RHSet=TL_SetExtRight(RHTLRef, True);
End;
End;
{ Find new Swing Low bars and draw corresponding trend lines }
If SwingLowBar(1, Low, RLStren, RLStren+1)=RLStren then begin
for Value1=9 downto 0 begin
RLDate[Value1+1]=RLDate[Value1];
RLTime[Value1+1]=RLTime[Value1];
RLVal[Value1+1]=RLVal[Value1];
end;
RLDate[0]=Date[RLStren];
RLTime[0]=Time[RLStren];
RLVal[0]=Low[RLStren];
for Value22=1 to 10 begin
If RLVal[Value22]<RLVal[0] then begin
RLArrayVal=Value22;
Value22=11;
end;
End;
If Value22<>11 then begin
If RLSet>=0 then begin
RLTLRef2=TL_SetEnd(RLTLRef, Date,Time,TL_GetValue(RLTLRef, date, time));
RLSet2=TL_SetExtRight(RLTLRef, False);
TL_Delete(RLTLRef);
end;
RLTLRef=TL_New(RLDate[RLArrayVal], RLTime[RLArrayVal], RLVal[RLArrayVal], RLDate[0], RLTime[0], RLVal[0]);
RLSet=TL_SetExtRight(RLTLRef, True);
End;
End;
{ Place orders to enter long positions }
If RHTLRef <> -1 then Begin
BuyPrice = TL_GetValue( RHTLRef , Date, Time );
PrevBuyPrice = TL_Getvalue( RHTLRef , Date[1] , Time[1] );
If Close Crosses Over BuyPrice AND absvalue( BuyPrice-PrevBuyPrice)>2 then
Buy next bar at Market;
End;
{ Place orders to enter short positions }
If RLTLRef <> -1 then Begin
SellShortPrice = TL_GetValue( RLTLRef , Date , Time );
PrevSellShortPrice = TL_Getvalue( RLTLRef , Date[1] , Time[1] );
If Close crosses under SellShortPrice AND absvalue( SellShortPrice-PrevSellShortPrice )>2 then
SellShort next bar at Market;
End;
{ Trailing protective stop orders }
Sell next bar at Lowest( Low , TrailBar ) Stop;
BuytoCover next bar at Highest( High , TrailBar ) Stop;