(程式碼) Pivots System


[LegacyColorValue = TRUE];

{ *****************************************************************************************
 
Study : Pivots System


*******************************************************************************************}





Input: ProfitPt(0), TrailBar(4);
Vars: Pivot(0), Support1(0), Support2(0), Support3(0),
Resistance1(0), Resistance2(0), Resistance3(0),
BearMarket(false) , BullMarket(false);

{ Calculation of Pivot, support and resistance points }
Pivot = ( Low + High + Close ) / 3;

Resistance1 = ( Pivot * 2 ) - Low;
Resistance2 = Pivot + Range;
Resistance3 = Resistance1 + Range;

Support1 = ( Pivot * 2 ) - High;
Support2 = Pivot - Range;
Support3 = Support1 - Range;

{ Determination of market character }
BullMarket = Average( Close , 4 ) > Average( Close , 9 ) AND Average( Close , 9 ) > Average( Close , 18 );
BearMarket = Average( Close , 4 ) < Average( Close , 9 ) AND Average( Close , 9 ) < Average( Close , 18 );

{ Placement of long orders }
If BullMarket then Begin
Buy ("Bull R2") next bar at Resistance2 stop;
Buy ("Bull R3") next bar at Resistance3 stop;
end;
{ Placement of short orders }
If bearmarket then begin
SellShort ("Bear S2") next bar at Support2 stop;
SellShort ("Bear S3") next bar at Support3 stop;
end;

{ Exit at first Profitable Open }
If MarketPosition = 1 and Open next bar > EntryPrice + ProfitPt + Commission * CurrentContracts / BigPointValue then
Sell ("Long Profit")next bar at Open;
If MarketPosition = -1 and Open next bar < EntryPrice - ProfitPt - Commission * CurrentContracts / BigPointValue then
BuytoCover ("Short Profit") next bar at Open;

{ Exit with trailing stops }
Sell next bar Lowest( Low , TrailBar ) Stop;
BuytoCover next bar Highest( High , TrailBar ) Stop;