답변완료
수식문의드립니다
안녕하세요~
수식에서 해결안되는 부분이 있어 질문드립니다
(수식은 하단 첨부)
첨부한 수식과 같이 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]);
}
}
}
2022-05-22
1073
글번호 159133
시스템