ksa2005
عضو نشط
- التسجيل
- 24 سبتمبر 2004
- المشاركات
- 328
(2)ترند فلتر
Var Bar,C,C1,C2,C3,S,S1,S2: integer;
Var useWeekly: boolean;
HideVolume;
// Set TRUE to restore weekly mode
useWeekly := false;
if useWeekly then
begin
SetScaleWeekly;
C := DailyFromWeekly ( #Close );
S := DailyFromWeekly( SmaSeries( #Close, 39 ) );
SetPrimarySeries( '^DJI' );
C1 := DailyFromWeekly ( #Close );
S1 := DailyFromWeekly( SmaSeries( #Close, 39 ) );
SetPrimarySeries( '^DJU' );
C2 := DailyFromWeekly ( #Close );
S2 := DailyFromWeekly( SmaSeries( #Close, 39 ) );
RestorePrimarySeries;
end
else
begin
C := #Close;
S := SmaSeries( #Close, 39*5 );
SetPrimarySeries( '^DJI' );
C1 := #Close;
S1 := SmaSeries( #Close, 39*5 );
SetPrimarySeries( '^DJU' );
C2 := #Close;
S2 := SmaSeries( #Close, 39*5 );
RestorePrimarySeries;
end;
SynchAll;
for Bar := 39*5 to BarCount - 1 do
begin
//Buy filter
if MarketPosition <> 1 then
begin
if (GetSeriesValue(Bar, C) > GetSeriesValue(Bar, S)) then
if ((GetSeriesValue( Bar, c1) > GetSeriesValue(Bar, S1)) or
(GetSeriesValue( Bar, c2) > GetSeriesValue(Bar, S2))) then
begin
SetBackgroundColor( Bar, #BlueBkg );
if MarketPosition = -1 then CoverAtMarket( Bar+1, LastPosition, '' );
BuyAtMarket( Bar+1, '' );
end;
end;
//Short filter
if MarketPosition <> -1 then
begin
if (GetSeriesValue(Bar, C) < GetSeriesValue(Bar, S)) then
if ((GetSeriesValue( Bar, c1) < GetSeriesValue(Bar, S1)) or
(GetSeriesValue( Bar, c2) < GetSeriesValue(Bar, S2))) then
begin
SetBackgroundColor( Bar, #RedBkg );
if MarketPosition = 1 then SellAtMarket( Bar+1, LastPosition, '' );
ShortAtMarket( Bar+1, '' );
end;
end;
end;
PlotSeries( S, 0, #Gray, #Thick );
var Pane1: integer;
Pane1 := CreatePane( 75, true, true );
PlotSeries( c1, Pane1, #Blue, #Thin );
PlotSeries( s1, Pane1, #Red, #Thin );
DrawLabel( 'DOW 30', Pane1 );
var Pane2: integer;
Pane2 := CreatePane( 75, true, true );
PlotSeries( c2, Pane2, #Blue, #Thin );
PlotSeries( s2, Pane2, #Red, #Thin );
DrawLabel( 'DOW 15 UTILITIES', Pane2 );
Var Bar,C,C1,C2,C3,S,S1,S2: integer;
Var useWeekly: boolean;
HideVolume;
// Set TRUE to restore weekly mode
useWeekly := false;
if useWeekly then
begin
SetScaleWeekly;
C := DailyFromWeekly ( #Close );
S := DailyFromWeekly( SmaSeries( #Close, 39 ) );
SetPrimarySeries( '^DJI' );
C1 := DailyFromWeekly ( #Close );
S1 := DailyFromWeekly( SmaSeries( #Close, 39 ) );
SetPrimarySeries( '^DJU' );
C2 := DailyFromWeekly ( #Close );
S2 := DailyFromWeekly( SmaSeries( #Close, 39 ) );
RestorePrimarySeries;
end
else
begin
C := #Close;
S := SmaSeries( #Close, 39*5 );
SetPrimarySeries( '^DJI' );
C1 := #Close;
S1 := SmaSeries( #Close, 39*5 );
SetPrimarySeries( '^DJU' );
C2 := #Close;
S2 := SmaSeries( #Close, 39*5 );
RestorePrimarySeries;
end;
SynchAll;
for Bar := 39*5 to BarCount - 1 do
begin
//Buy filter
if MarketPosition <> 1 then
begin
if (GetSeriesValue(Bar, C) > GetSeriesValue(Bar, S)) then
if ((GetSeriesValue( Bar, c1) > GetSeriesValue(Bar, S1)) or
(GetSeriesValue( Bar, c2) > GetSeriesValue(Bar, S2))) then
begin
SetBackgroundColor( Bar, #BlueBkg );
if MarketPosition = -1 then CoverAtMarket( Bar+1, LastPosition, '' );
BuyAtMarket( Bar+1, '' );
end;
end;
//Short filter
if MarketPosition <> -1 then
begin
if (GetSeriesValue(Bar, C) < GetSeriesValue(Bar, S)) then
if ((GetSeriesValue( Bar, c1) < GetSeriesValue(Bar, S1)) or
(GetSeriesValue( Bar, c2) < GetSeriesValue(Bar, S2))) then
begin
SetBackgroundColor( Bar, #RedBkg );
if MarketPosition = 1 then SellAtMarket( Bar+1, LastPosition, '' );
ShortAtMarket( Bar+1, '' );
end;
end;
end;
PlotSeries( S, 0, #Gray, #Thick );
var Pane1: integer;
Pane1 := CreatePane( 75, true, true );
PlotSeries( c1, Pane1, #Blue, #Thin );
PlotSeries( s1, Pane1, #Red, #Thin );
DrawLabel( 'DOW 30', Pane1 );
var Pane2: integer;
Pane2 := CreatePane( 75, true, true );
PlotSeries( c2, Pane2, #Blue, #Thin );
PlotSeries( s2, Pane2, #Red, #Thin );
DrawLabel( 'DOW 15 UTILITIES', Pane2 );