//INDICATOR
// WORKING test 2.5 Pivot strategy INDICTOR
INDICATEUR = 0
INDICATEUR1 = 0
// Conditions to enter long positions
indicator1 = Average[200](close)
indicator2 = Average[50](close)
c1 = (indicator1 < indicator2)
indicator3 = close
indicator4 = Average[200](close)
c2 = (indicator3 CROSSES OVER indicator4)
//DEBUG SWITCHES 1=on 0=off
Rule1 = 1//PivotLong
Rule2 = 1//Sup1Long
Rule3 = 1//Sup2Long
Rule4 = 1//Sup3Long
Rule5 = 1//Res1Long
Rule6 = 1//Res2Long
Rule7 = 1//Res2Long
Rule11 = 1//PivotShort
Rule21 = 1//Sup1Short
Rule31 = 1//Sup2Short
Rule41 = 1//Sup3Short
Rule51 = 1//Res1Short
Rule61 = 1//Res2Short
Rule71 = 1//Res3Short
//Pivot support and resistans line definition LONG
Pivot1Long = (DHigh(1) + DLow(1) + DClose(1))/3
S1DLong = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DHigh(1)
S2DLong = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))
S3DLong = DHigh(1)+2*(((DHigh(1) + DLow(1) + DClose(1))/3)-DLow(1))
R1DLong = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DLow(1)
R2DLong = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))
R3DLong = DHigh(1)+2*((DHigh(1) + DLow(1) + DClose(1))/3-DLow(1))
c3PvD = (close[1] crosses under Pivot1Long)
c3S1D=(close[1] crosses under S1DLong)
c3S2D=(close[1] crosses under S2DLong)
c3S3D=(close[1] crosses under S3DLong)
c3R1D=(close[1] crosses under R1DLong)
c3R2D=(close[1] crosses under R2DLong)
c3R3D=(close[1] crosses under R3DLong)
c33= 1//close[1]<close
PivotLong = c1 AND c2 and c33 AND c3PvD and Rule1
Sup1Long = c1 AND c2 and c33 AND c3S1D and Rule2
Sup2Long = c1 AND c2 and c33 AND c3S2D and Rule3
Sup3Long = c1 AND c2 and c33 AND c3S3D and Rule4
Res1Long = c1 AND c2 and c33 AND c3R1D and Rule5
Res2Long = c1 AND c2 and c33 AND c3R2D and Rule6
Res3Long = c1 AND c2 and c33 AND c3R3D and Rule7
If PivotLong or Sup1Long or Sup2Long or Sup3Long or Res1Long or Res2Long or Res3Long then
INDICATEUR =1
else
INDICATEUR=0
Endif
//REM**************************************************
// Conditions to enter short positions
indicator8 = Average[200](close)
indicator9 = Average[50](close)
c5 = (indicator8 > indicator9)
indicator10 = close
indicator11 = Average[200](close)
c6 = (indicator10 CROSSES UNDER indicator11)
//Pivot support and resistans line definition SHORT
Pivot1short = (DHigh(1) + DLow(1) + DClose(1))/3
S1DShort = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DHigh(1)
S2DShort = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))
S3DShort = DHigh(1)+2*(((DHigh(1) + DLow(1) + DClose(1))/3)-DLow(1))
R1DShort = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DLow(1)
R2DShort = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))
R3DShort = DHigh(1)+2*((DHigh(1) + DLow(1) + DClose(1))/3-DLow(1))
c7PvD = (low[1] CROSSES over Pivot1Short)
c7S1D= (low[1] CROSSES over S1DShort)
c7S2D=(low[1] CROSSES over S2DShort)
c7S3D=(low[1] CROSSES over S3DShort)
c7R1D= (low[1] CROSSES over R1DShort)
c7R2D= (low[1] CROSSES over R2DShort)
c7R3D= (low[1] CROSSES over R3DShort)
c77= 1//close[1]>close
PivotShort = c5 AND c6 AND c77 and c7PvD and Rule11
Sup1Short = c5 AND c6 AND c77 and c7S1D and Rule21
Sup2Short = c5 AND c6 AND c77 and c7S2D and Rule31
Sup3Short = c5 AND c6 AND c77 and c7S3D and Rule41
Res1Short = c5 AND c6 AND c77 and c7R1D and Rule51
Res2Short = c5 AND c6 AND c77 and c7R2D and Rule61
Res3Short = c5 AND c6 AND c77 and c7R3D and Rule71
IF PivotShort or Sup1Short or Sup2Short or Sup3Short or Res1Short or Res2Short or Res3Short then
INDICATEUR1 =-1
else
INDICATEUR1=0
ENDIF
Return INDICATEUR1 COLOURED(255,0,0), INDICATEUR COLOURED(0,0,255)