안녕하세요
예스스탁입니다.
input : Period(20),dv(2);
var : i(0),B(0),Bi(0),S(0),Si(0);
var : BBup(0),BBmd(0),BBdn(0);
BBup = BollBandUp(Period,dv);
BBmd = ma(c,Period);
BBdn = BollBandDown(Period,dv);
if MarketPosition <= 0 Then
{
if CountIf(MarketPosition<=0,4)== 4 and
C[3]<O[3] and
CountIf(C>O and C>C[1],3) == 3 Then
{
B = 1;
Bi = Index;
}
if CountIf(MarketPosition<=0,5)== 5 and
C[4]<O[4] and C[3]>O[3] and C>O and CountIf(C>O,4) == 3 Then
{
var1 = O[4];
var2 = 0;
Condition1 = False;
For i = 3 downto 0
{
if C[i] < O[i] and C[i] < var1 Then
Condition1 = true;
if C[i] > O[i] Then
{
if var2 > 0 and C[i] < var2 Then
Condition1 = true;
var2 = C[i];
}
}
if Condition1 == False Then
{
B = 1;
Bi = Index;
}
}
if B == 1 and CountIf(C<BBdn+PriceScale*20,3) == 3 Then
B = 0;
if B == 1 and C > O and C > bbdn+PriceScale*20 Then
{
if C[1] > O[1] and C[1] > BBdn[1]+PriceScale*20 Then
{
B = 2;
Buy("b1");
}
if C[1] < O[1] and C[2] > O[2] and C[2] > BBdn[2]+PriceScale*20 Then
{
B = 2;
Buy("b2");
}
}
if B == 1 and Index > bi Then
{
if C > O and C[1] < O[1] and C > O[1] Then
{
B = 2;
Buy("b3");
}
if CountIf(C>O and C > C[1],2) == 2 Then
{
B = 2;
Buy("b4");
}
}
}
if MarketPosition == 1 Then
{
B = 0;
ExitLong("bx1",AtStop,L[즐BarsSinceEntry]);
if c > O and C > C[BarsSinceEntry] Then
ExitLong("bx2");
}
if MarketPosition >= 0 Then
{
if CountIf(MarketPosition>=0,4)== 4 and
C[3]>O[3] and
CountIf(C<O and C<C[1],3) == 3 Then
{
S = 1;
Si = Index;
}
if CountIf(MarketPosition>=0,5)== 5 and
C[4]>O[4] and C[3]<O[3] and C<O and CountIf(C<O,4) == 3 Then
{
var3 = O[4];
var4 = 0;
Condition2 = False;
For i = 3 downto 0
{
if C[i] > O[i] and C[i] > var3 Then
Condition2 = true;
if C[i] < O[i] Then
{
if var4 > 0 and C[i] > var4 Then
Condition2 = true;
var4 = C[i];
}
}
if Condition2 == False Then
{
S = 1;
Si = Index;
}
}
if S == 1 and CountIf(C>BBup-PriceScale*20,3) == 3 Then
S = 0;
if S == 1 and C < O and C < bbup-PriceScale*20 Then
{
if C[1] < O[1] and C[1] < BBup[1]-PriceScale*20 Then
{
S = 2;
Sell("s1");
}
if C[1] > O[1] and C[2] < O[2] and C[2] < BBup[2]-PriceScale*20 Then
{
S = 2;
Sell("s2");
}
}
if S == 1 and Index > Si Then
{
if C < O and C[1] > O[1] and C < O[1] Then
{
S = 2;
Sell("s3");
}
if CountIf(C<O and C<C[1],2) == 2 Then
{
S = 2;
Sell("s4");
}
}
}
if MarketPosition == -1 Then
{
S = 0;
ExitShort("sx1",AtStop,H[BarsSinceEntry]);
if C < O and C < C[BarsSinceEntry] Then
ExitShort("sx2");
}
즐거운 하루되세요