예스스탁
예스스탁 답변
2022-05-23 14:02:07
안녕하세요
예스스탁입니다.
1
crossup(A,B)이나 crossdown(A,B)함수는 풀어서 작성하면 아래와 같습니다.
crossup = A > B and A[1] <= B[1]
crossdown = A < B and A[1] >= B[1]
2개의 값의 현재봉 상태와 전봉상태를 비교해서 조건을 체크합니다.
예를 들어 BC2[6]을 예로 들면 BC1[6]이 true인 상태에서
LL[5]를 고가가 상향돌파하면 true입니다.
LL값이 1시8분봉에 변경이 되는데
1시7분봉은 고가는 11732.50, LL[5]는 11953로 고가는 LL[5] 작고
1시8분봉은 고가는 11727.75, LL[5]는 11713로 고가는 LL[5] 보다 커지게 되어
crossup = A > B and A[1] <= B[1] 조건에 충족됩니다.
해당 부분을 해결하시려면 중간에 값이 변경될수도 있으므로
현재봉의 LL값과 현재봉고가와 전봉고가 상태를 비교하게 아래와 같이 풀어 작성하셔야 합니다.
if H > LL[i+1] and H < LL[i+1] Then BC1[i] = true;
if BC1[i] == true && H > LL[i-1] and L < LL[i-1] Then BC2[i] = true;
if (L < LL[i] and L > LL[i]&& BC1[i] == true && BC2[i] == true) or (H > LL[i-2] and L < LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b06", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL06-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL06-2", AtStop, LL[i+1]);
}
2
가격라인이 조정이 있으면 각 상태를 저장하는 변수가 일괄적으로 false로 초기화하는 내용이 필요해 보입니다.
첨부하신 그림에 있는 B06신호도 BC1조건이 값 변경전 발생해서 true가 유지되고 있는 상태입니다.
if H > LL[1] Then
{
LL[5] = LL[1];
For i = 0 to 9
{
BC1[i] = False;
BC2[i] = False;
SC1[i] = False;
SC2[i] = False;
}
}
if L < LL[9] Then
{
LL[5] = LL[9];
For i = 0 to 9
{
BC1[i] = False;
BC2[i] = False;
SC1[i] = False;
SC2[i] = False;
}
}
3
배열을 0~9번까지 사용하시면 총 10개공간입니다.
array : LL[10](0);
과 같이 사이즈는 10이 되어야 합니다.
랭귀지에서 내부적으로 여분을 1개 더 생성하게 되어 있어 현재는 문제가 없지만
정확히는 갯수만큼 지정해 주셔야 합니다.
즐거운 하루되세요
> jshwang2 님이 쓴 글입니다.
> 제목 : 수식문의드립니다
> 안녕하세요~
수식에서 해결안되는 부분이 있어 질문드립니다
(수식은 하단 첨부)
첨부한 수식과 같이 9개 선에서의 매수, 매도를 감시하도록 셋팅해놓고
가격이 제일위, 제일아래 선을 돌파하면 9개 선을 상/하향 조정해 감시하도록 만들었습니다
수식상 처음에 설정한 LL[5] 값이 11953이었고, 이때의 LL[9] == 11713이었습니다
첨부한 사진상의 세로선으로 표시한 01:08에 가격이 11713을 crossdown해 수식대로 LL[5] == 11713을 바뀌고, 다른 선들도 다시 셋팅되었습니다
그런데 01:09의 봉에서 갑자기 BC1[5], BC1[6], BC2[6]이 TRUE로 바뀌었고 (이전엔 전부 FALSE)
LL[6]에서 매수가 체결되었습니다
BC1[5]는 LL[6]을 crossup 할때
BC1[6]은 LL[7]을 crossup 할때
BC2[6]은 BC1[6] == true 이면서 LL[5]를 crossup 할때
발생하는데, 첨부한 사진에도 보이듯 이런 이벤트가 발생한적이 없습니다
정리하면
01:08 => LL[5] = LL[9]로 업데이트 & BC1[5], BC1[6], BC2[6] 모두 false
01:09 => BC1[5], BC1[6], BC2[6] 모두 true로 바뀜
01:10 => b06 체결
이렇게 되었는데 원인을 찾지 못하겠습니다
한번 살펴봐주시면 감사하겠습니다
-----------------------------------------------------------
input : Distance(60), TM(11200), TT(10000);
var : i(0);
array : LL[9](11953), BC1[9](False), BC2[9](false), SC1[9](False), SC2[9](False);
if TM > sTime && sTime > TT Then
{
MessageLog("L2-1 %.2f, L3-1 %.2f, L4-1 %.2f, L5-1 %.2f, L9-1 %.2f", LL[2] , LL[3], LL[4], LL[5], LL[9]);
MessageLog("SC1[1] %s, SC1[2] %s, SC1[3] %s, SC1[4] %s, SC1[5] %s, SC1[6] %s, SC1[7] %s, SC1[8] %S, SC1[9] %s", SC1[1], SC1[2], SC1[3], SC1[4], SC1[5], SC1[6], SC1[7], SC1[8], SC1[9]);
MessageLog("SC2[1] %s, SC2[2] %s, SC2[3] %s, SC2[4] %s, SC2[5] %s, SC2[6] %s, SC2[7] %s, SC2[8] %S, SC2[9] %s", SC2[1], SC2[2], SC2[3], SC2[4], SC2[5], SC2[6], SC2[7], SC2[8], SC2[9]);
MessageLog("BC1[1] %s, BC1[2] %s, BC1[3] %s, BC1[4] %s, BC1[5] %s, BC1[6] %s, BC1[7] %s, BC1[8] %S, BC1[9] %s", BC1[1], BC1[2], BC1[3], BC1[4], BC1[5], BC1[6], BC1[7], BC1[8], BC1[9]);
MessageLog("BC2[1] %s, BC2[2] %s, BC2[3] %s, BC2[4] %s, BC2[5] %s, BC2[6] %s, BC2[7] %s, BC2[8] %S, BC2[9] %s", BC2[1], BC2[2], BC2[3], BC2[4], BC2[5], BC2[6], BC2[7], BC2[8], BC2[9]);
MessageLog("SC1 %s, SC2 %s, BC1 %s, BC2 %s, p %.2f", SC1[3], SC2[3], BC1[5], BC2[5], MarketPosition);
if H > LL[1] Then
{
LL[5] = LL[1];
}
if L < LL[9] Then
{
LL[5] = LL[9];
}
For i = 0 to 4 {LL[4-i] = LL[5-i] + distance;}
For i = 5 to 9 {LL[i+1] = LL[i] - distance;}
MessageLog("L2-2 %.2f, L3-2 %.2f, L4-2 %.2f, L5-2 %.2f, L9-2 %.2f", LL[2] , LL[3], LL[4], LL[5], LL[9]);
MessageLog("SC1[1] %s, SC1[2] %s, SC1[3] %s, SC1[4] %s, SC1[5] %s, SC1[6] %s, SC1[7] %s, SC1[8] %S, SC1[9] %s", SC1[1], SC1[2], SC1[3], SC1[4], SC1[5], SC1[6], SC1[7], SC1[8], SC1[9]);
MessageLog("SC2[1] %s, SC2[2] %s, SC2[3] %s, SC2[4] %s, SC2[5] %s, SC2[6] %s, SC2[7] %s, SC2[8] %S, SC2[9] %s", SC2[1], SC2[2], SC2[3], SC2[4], SC2[5], SC2[6], SC2[7], SC2[8], SC2[9]);
MessageLog("BC1[1] %s, BC1[2] %s, BC1[3] %s, BC1[4] %s, BC1[5] %s, BC1[6] %s, BC1[7] %s, BC1[8] %S, BC1[9] %s", BC1[1], BC1[2], BC1[3], BC1[4], BC1[5], BC1[6], BC1[7], BC1[8], BC1[9]);
MessageLog("BC2[1] %s, BC2[2] %s, BC2[3] %s, BC2[4] %s, BC2[5] %s, BC2[6] %s, BC2[7] %s, BC2[8] %S, BC2[9] %s", BC2[1], BC2[2], BC2[3], BC2[4], BC2[5], BC2[6], BC2[7], BC2[8], BC2[9]);
MessageLog("SC1 %s, SC2 %s, BC1 %s, BC2 %s, p %.2f", SC1[3], SC2[3], BC1[5], BC2[5], MarketPosition);
For i = 1 to 1
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b01", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2)Then
{
ExitLong("exitL01-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL01-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s01", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS1-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS1-2", AtStop, LL[i-1]);
}
}
For i = 2 to 2
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b02", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL2-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL2-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s02", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS2-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS2-2", AtStop, LL[i-1]);
}
}
For i = 3 to 3
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b03", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL3-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL3-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s03", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS3-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS3-2", AtStop, LL[i-1]);
}
}
For i = 4 to 4
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i]) && H[1] > LL[i] && BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b04", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL4-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL4-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s04", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS4-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS4-2", AtStop, LL[i-1]);
}
}
For i = 5 to 5
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) or CrossDown(C, LL[i+2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b05", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL05-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL05-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s05", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS5-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS5-2", AtStop, LL[i-1]);
}
}
For i = 6 to 6
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b06", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL06-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL06-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s06", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS6-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS6-2", AtStop, LL[i-1]);
}
}
For i = 7 to 7
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b07", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL07-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL07-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s07", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS7-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS7-2", AtStop, LL[i-1]);
}
}
For i = 8 to 8
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if (CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true) or CrossUp(H, LL[i-2]) Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b08", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL08-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL08-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) or CrossDown(L, LL[i+2]) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s08", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS8-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS8-2", AtStop, LL[i-1]);
}
}
For i = 9 to 9
{
if CrossUp(H, LL[i+1]) Then BC1[i] = true;
if BC1[i] == true && CrossUp(H, LL[i-1]) Then BC2[i] = true;
if CrossDown(L, LL[i])&& BC1[i] == true && BC2[i] == true Then
{
BC1[i] = False;
BC2[i] = False;
}
if MarketPosition == 0 && BC1[i] == true && BC2[i] == true Then Buy("b09", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitLong("exitL09-1", AtLimit, (LL[i]+LL[i-1])/2);
ExitLong("exitL09-2", AtStop, LL[i+1]);
}
if CrossDown(L, LL[i-1]) Then SC1[i] = true;
if SC1[i] == true && CrossDown(L, LL[i+1]) Then SC2[i] = true;
if (CrossUp(H, LL[i])&& SC1[i] == true && SC2[i] == true) Then
{
SC1[i] = False;
SC2[i] = False;
}
if MarketPosition == 0 && SC1[i] == true && SC2[i] == true Then Sell("s09", AtLimit, LL[i]);
if (EntryPrice <= (LL[i]+LL[i-1])/2 && EntryPrice >= (LL[i]+LL[i+1])/2) Then
{
ExitShort("exitS9-1", AtLimit, (LL[i]+LL[i+1])/2);
ExitShort("exitS9-2", AtStop, LL[i-1]);
}
}
}