(程式碼) Pivots ID



[LegacyColorValue = TRUE];

{ *****************************************************************************************
   
Study : Pivots ID


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


Inputs: TrailBar(4);
Vars: Pivot(0), Support1(0), Support2(0), Support3(0), 
Resistance1(0), Resistance2(0), Resistance3(0),
NoLongTradeToday(False), NoShortTradeToday(False);

{ Calculate Pivots at the begining of the day }
If ( Date <> Date[1] ) then Begin
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;
End;

If ( Date next bar = Date ) or ( ( time > Sess1StartTime ) and ( time < Sess1EndTime ) ) then Begin
{ Placement of Short orders }
If Low > Support3 then Begin
SellShort next bar at  Support3 stop;
SellShort next bar at Support2 stop;
End;
{ Placement of long orders }
If High < Resistance3 then begin
Buy next bar at Resistance2 stop;
Buy next bar at Resistance3 stop;
End;
End;

{ Trailing Stop }
Sell next bar at Lowest( Low , TrailBar ) Stop;
BuytoCover next bar at Highest( High , Trailbar ) Stop;