umoz
0
All posts from umoz
  umoz in umoz,

Уровни поддержки и сопротивления - исследование и торговля с помощью программы MetaStock

Индикатор <R Level 1>: 

pds := 5 ;
B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 )))) ;
Condition := Ref( Z, -pds) = HHV( Z, 2 * pds + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1);
s1 := ValueWhen( 1, Condition, Ref( Z, -pds) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;
L1 := If( s1 >= s2 AND s1 >= s3 AND s1 >= s4 AND s1 >= s5 AND s1 >= s6, s1,
If( s2 >= s1 AND s2 >= s3 AND s2 >= s4 AND s2 >= s5 AND s2 >= s6, s2,
If( s3 >= s2 AND s3 >= s1 AND s3 >= s4 AND s3 >= s5 AND s3 >= s6, s3,
If( s4 >= s2 AND s4 >= s3 AND s4 >= s1 AND s4 >= s5 AND s4 >= s6, s4,
If( s5 >= s2 AND s5 >= s3 AND s5 >= s4 AND s5 >= s1 AND s5 >= s6, s5,
If( s6 >= s2 AND s6 >= s3 AND s6 >= s4 AND s6 >= s5 AND s6 >= s1, s6, 0 ) ) ) ) ) ) ;
L1

Индикатор <R Level 6>:

pds := 5 ;
B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 )))) ;
Condition := Ref( Z, -pds) = HHV( Z, 2 * pds + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1);
s1 := ValueWhen( 1, Condition, Ref( Z, -pds) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;
L6 := If( s1 <= s2 AND s1 <= s3 AND s1 <= s4 AND s1 <= s5 AND s1 <= s6, s1,
If( s2 <= s1 AND s2 <= s3 AND s2 <= s4 AND s2 <= s5 AND s2 <= s6, s2,
If( s3 <= s2 AND s3 <= s1 AND s3 <= s4 AND s3 <= s5 AND s3 <= s6, s3,
If( s4 <= s2 AND s4 <= s3 AND s4 <= s1 AND s4 <= s5 AND s4 <= s6, s4,
If( s5 <= s2 AND s5 <= s3 AND s5 <= s4 AND s5 <= s1 AND s5 <= s6, s5,
If( s6 <= s2 AND s6 <= s3 AND s6 <= s4 AND s6 <= s5 AND s6 <= s1, s6, 0 ) ) ) ) ) ) ;
L6



Индикатор <R Level 2>:

pds := 5 ;
B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 )))) ;
Condition := Ref( Z, -pds) = HHV( Z, 2 * pds + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1);
s1 := ValueWhen( 1, Condition, Ref( Z, -pds) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;

L1 := FmlVar( "<R Level 1>", "L1" ) ;
L6 := FmlVar( "<R Level 6>", "L6") ;
ss1 := If( s1 <> L1 AND s1 <> L6, s1, L6) ;
ss2 := If( s2 <> L1 AND s2 <> L6, s2, L6) ;
ss3 := If( s3 <> L1 AND s3 <> L6, s3, L6) ;
ss4 := If( s4 <> L1 AND s4 <> L6, s4, L6) ;
ss5 := If( s5 <> L1 AND s5 <> L6, s5, L6) ;
ss6 := If( s6 <> L1 AND s6 <> L6, s6, L6) ;
L2 := If( ss1 >= ss2 AND ss1 >= ss3 AND ss1 >= ss4 AND ss1 >= ss5 AND ss1 >= ss6 AND ss1 < L1, ss1,
If( ss2 >= ss1 AND ss2 >= ss3 AND ss2 >= ss4 AND ss2 >= ss5 AND ss2 >= ss6 AND ss2 < L1, ss2,
If( ss3 >= ss2 AND ss3 >= ss1 AND ss3 >= ss4 AND ss3 >= ss5 AND ss3 >= ss6 AND ss3 < L1, ss3,
If( ss4 >= ss2 AND ss4 >= ss3 AND ss4 >= ss1 AND ss4 >= ss5 AND ss4 >= ss6 AND ss4 < L1, ss4,
If( ss5 >= ss2 AND ss5 >= ss3 AND ss5 >= ss4 AND ss5 >= ss1 AND ss5 >= ss6 AND ss5 < L1, ss5,
If( ss6 >= ss2 AND ss6 >= ss3 AND ss6 >= ss4 AND ss6 >= ss5 AND ss6 >= ss1 AND ss6 < L1, ss6, 0 ) ) ) ) ) ) ;
L2

Индикатор <R Level 5>:

pds := 5 ;
B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 )))) ;
Condition := Ref( Z, -pds) = HHV( Z, 2 * pds + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1);
s1 := ValueWhen( 1, Condition, Ref( Z, -pds) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;

L1 := FmlVar( "<R Level 1>", "L1") ;
L6 := FmlVar( "<R Level 6>", "L6") ;
ss1 := If( s1 <> L1 AND s1 <> L6, s1, L1) ;
ss2 := If( s2 <> L1 AND s2 <> L6, s2, L1) ;
ss3 := If( s3 <> L1 AND s3 <> L6, s3, L1) ;
ss4 := If( s4 <> L1 AND s4 <> L6, s4, L1) ;
ss5 := If( s5 <> L1 AND s5 <> L6, s5, L1) ;
ss6 := If( s6 <> L1 AND s6 <> L6, s6, L1) ;
L5 := If( ss1 <= ss2 AND ss1 <= ss3 AND ss1 <= ss4 AND ss1 <= ss5 AND ss1 <= ss6 AND s1 < L1 AND ss1 <> L6, ss1,
If( ss2 <= ss1 AND ss2 <= ss3 AND ss2 <= ss4 AND ss2 <= ss5 AND ss2 <= ss6 AND s2 < L1 AND ss2 <> L6, ss2,
If( ss3 <= ss2 AND ss3 <= ss1 AND ss3 <= ss4 AND ss3 <= ss5 AND ss3 <= ss6 AND s3 < L1 AND ss3 <> L6, ss3,
If( ss4 <= ss2 AND ss4 <= ss3 AND ss4 <= ss1 AND ss4 <= ss5 AND ss4 <= ss6 AND s4 < L1 AND ss4 <> L6, ss4,
If( ss5 <= ss2 AND ss5 <= ss3 AND ss5 <= ss4 AND ss5 <= ss1 AND ss5 <= ss6 AND s5 < L1 AND ss5 <> L6, ss5,
If( ss6 <= ss2 AND ss6 <= ss3 AND ss6 <= ss4 AND ss6 <= ss5 AND ss6 <= ss1 AND s6 < L1 AND ss6 <> L6, ss6, L6 ) ) ) ) ) ) ;
L5

Индикатор <R Level 3>:

pds := 5 ;
B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 )))) ;
Condition := Ref( Z, -pds) = HHV( Z, 2 * pds + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1);
s1 := ValueWhen( 1, Condition, Ref( Z, -pds) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;

L1 := FmlVar( "<R Level 1>", "L1") ;
L2 := FmlVar( "<R Level 2>", "L2") ;
L5 := FmlVar( "<R Level 5>", "L5") ;
L6 := FmlVar( "<R Level 6>", "L6") ;
sss1 := If( s1 <> L1 AND s1 <> L2 AND s1 <> L5 AND s1 <> L6, s1, L6) ;
sss2 := If( s2 <> L1 AND s2 <> L2 AND s2 <> L5 AND s2 <> L6, s2, L6) ;
sss3 := If( s3 <> L1 AND s3 <> L2 AND s3 <> L5 AND s3 <> L6, s3, L6) ;
sss4 := If( s4 <> L1 AND s4 <> L2 AND s4 <> L5 AND s4 <> L6, s4, L6) ;
sss5 := If( s5 <> L1 AND s5 <> L2 AND s5 <> L5 AND s5 <> L6, s5, L6) ;
sss6 := If( s6 <> L1 AND s6 <> L2 AND s6 <> L5 AND s6 <> L6, s6, L6) ;
L3 := If( sss1 >= sss2 AND sss1 >= sss3 AND sss1 >= sss4 AND sss1 >= sss5 AND sss1 >= sss6 AND sss1 < L2, sss1,
If( sss2 >= sss1 AND sss2 >= sss3 AND sss2 >= sss4 AND sss2 >= sss5 AND sss2 >= sss6 AND sss2 < L2, sss2,
If( sss3 >= sss2 AND sss3 >= sss1 AND sss3 >= sss4 AND sss3 >= sss5 AND sss3 >= sss6 AND sss3 < L2, sss3,
If( sss4 >= sss2 AND sss4 >= sss3 AND sss4 >= sss1 AND sss4 >= sss5 AND sss4 >= sss6 AND sss4 < L2, sss4,
If( sss5 >= sss2 AND sss5 >= sss3 AND sss5 >= sss4 AND sss5 >= sss1 AND sss5 >= sss6 AND sss5 < L2, sss5,
If( sss6 >= sss2 AND sss6 >= sss3 AND sss6 >= sss4 AND sss6 >= sss5 AND sss6 >= sss1 AND sss6 < L2, sss6, 0) ) ) ) ) ) ;
L3



Индикатор <R Level 4>:

pds := 5 ;
B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 )))) ;
Condition := Ref( Z, -pds) = HHV( Z, 2 * pds + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1);
s1 := ValueWhen( 1, Condition, Ref( Z, -pds) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;

L1 := FmlVar( "<R Level 1>", "L1") ;
L2 := FmlVar( "<R Level 2>", "L2") ;
L3 := FmlVar( "<R Level 3>", "L3") ;
L5 := FmlVar( "<R Level 5>", "L5") ;
L6 := FmlVar( "<R Level 6>", "L6") ;
L4 := If( s1 <> L1 AND s1 <> L2 AND s1 <> L3 AND s1 <> L5 AND s1 <> L6, s1,
If( s2 <> L1 AND s2 <> L2 AND s2 <> L3 AND s2 <> L5 AND s2 <> L6, s2,
If( s3 <> L1 AND s3 <> L2 AND s3 <> L3 AND s3 <> L5 AND s3 <> L6, s3,
If( s4 <> L1 AND s4 <> L2 AND s4 <> L3 AND s4 <> L5 AND s4 <> L6, s4,
If( s5 <> L1 AND s5 <> L2 AND s5 <> L3 AND s5 <> L5 AND s5 <> L6, s5,
If( s6 <> L1 AND s6 <> L2 AND s6 <> L3 AND s6 <> L5 AND s6 <> L6, s6, L6 ) ) ) ) ) ) ;
L4



Индикатор <R Level nearest>

B := 3 ;
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0 ) ) ) ) ;
L1 := FmlVar( "<R Level 1>", "L1") ;
L2 := FmlVar( "<R Level 2>", "L2") ;
L3 := FmlVar( "<R Level 3>", "L3") ;
L4 := FmlVar( "<R Level 4>", "L4") ;
L5 := FmlVar( "<R Level 5>", "L5") ;
L6 := FmlVar( "<R Level 6>", "L6") ;
NR := If( L6 > Z, L6, If( L5 > Z, L5, If( L4 > Z, L4, If( L3 > Z, L3, If( L2 > Z, L2, If( L1 > Z, L1, L1 ) ) ) ) ) ) ;
NR



Торговая система на основе пробития уровней сопротивления:

Открытие длинных позиций:
Pds := opt1 ;
B := opt2 ; {от 1 до 5 c шагом 1}
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0)))) ;
Condition := Ref( Z, -pds) = HHV( Z, pds * 2 + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1) ;
s1 := ValueWhen( 1, Condition, Ref( Z, -pds)) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;
r.lev.osc := If( Z > s6, 1, 0) + If( Z > s5, 1, 0) + If( Z > s4, 1, 0) + If( Z > s3, 1, 0) + If( Z > s2, 1, 0) + If( Z > s1, 1, 0) ;
r.lev.osc - Ref( r.lev.osc, -opt3) >= opt4

Закрытие длинных позиций:
pds:=opt1;
B := opt2 ; {от 1 до 5 c шагом 1}
Z := If( B = 1, CLOSE, If( B = 2, OPEN, If( B = 3, HIGH, If( B = 4, LOW, 0)))) ;
Condition := Ref( Z, -pds) = HHV( Z, pds * 2 + 1) AND Ref( Z, -pds) <> Ref( Z, -pds - 1) ;
s1 := ValueWhen( 1, Condition, Ref( Z, -pds)) ;
s2 := ValueWhen( 2, Condition, Ref( Z, -pds)) ;
s3 := ValueWhen( 3, Condition, Ref( Z, -pds)) ;
s4 := ValueWhen( 4, Condition, Ref( Z, -pds)) ;
s5 := ValueWhen( 5, Condition, Ref( Z, -pds)) ;
s6 := ValueWhen( 6, Condition, Ref( Z, -pds)) ;
r.lev.osc := If( Z < s6, 1, 0) + If( Z < s5, 1, 0) + If(Z < s4, 1, 0) + If(Z < s3, 1, 0) + If( Z < s2, 1, 0) + If( Z < s1, 1, 0) ;
r.lev.osc - Ref( r.lev.osc, -opt5) >= opt6