커뮤니티
감사합니다.
2015-06-03 22:40:25
106
글번호 86768
어제 알려주신대로 하니 OpenPP문제는 감쪽같이 해결됬습니다^^
그걸 응용해서 골드일때 매수, 데드일때 매도로 리버스전략을 만들어봤는데 아무리해봐도 데이터가 틀립니다.
수정부탁드리오며, 다시금 감사합니다.
===========================================================
Input : 수량(1);
Var : MP(0),BuySellEntryPrice(0),OpenPP(0),NP(0);
If MP == 0 Then{
If CrossUp(Ma(C,5),Ma(C,20)) Then{
MP = 1;
BuySellEntryPrice = C;
}
If CrossDown(Ma(C,5),Ma(C,20)) Then{
MP = -1;
BuySellEntryPrice = C;
}
}
If MP == 1 Then{
OpenPP = (C-BuySellEntryPrice)*수량;
If CrossDown(Ma(C,5),Ma(C,20)) Then{
MP = 0;
NP = NP+OpenPP;
OpenPP = 0;
}
}
If MP == -1 Then {
OpenPP = (BuySellEntryPrice-C)*수량;
If CrossUp(Ma(C,5),Ma(C,20)) Then{
MP = 0;
NP = NP+OpenPP;
OpenPP = 0;
}
}
MessageLog("시가,%.4f,종가,%.4f,MP,%.0f,NP,%.4f,OpenPP,%.4f",open,close,MP,NP,OpenPP);
답변 1
예스스탁 예스스탁 답변
2015-06-04 11:14:06
안녕하세요
예스스탁입니다.
기존에 작성하신 수식이 MP가
골드와 데드시 바로 1이나 -1로 변경이 되지 않았습니다.
식을 수정했습니다.
아래와 같이 작성하시면
이평 골드/데드시 손익과 누적손익이 출력됩니다.
Input : 수량(1);
Var : MP(0),BuySellEntryPrice(0),OpenPP(0),NP(0);
var : ma1(0),ma2(0);
ma1 = ma(C,5);
ma2 = ma(c,20);
If MP <= 0 and CrossUp(Ma1,Ma2) Then{
if MP == -1 Then{
NP = NP+(BuySellEntryPrice-C)*수량;
}
BuySellEntryPrice = C;
MP = 1;
}
If MP >= 0 and CrossDown(Ma1,Ma2) Then{
if MP == 1 Then{
NP = NP+(C-BuySellEntryPrice)*수량;
}
BuySellEntryPrice = C;
MP = -1;
}
If MP == 1 Then{
OpenPP = (C-BuySellEntryPrice)*수량;
}
If MP == -1 Then {
OpenPP = (BuySellEntryPrice-C)*수량;
}
plot1(OpenPP);
plot2(NP);
#MessageLog("시가,%.4f,종가,%.4f,MP,%.0f,NP,%.4f,OpenPP,%.4f",open,close,MP,NP,OpenPP);
즐거운 하루되세요
> 9단 님이 쓴 글입니다.
> 제목 : 감사합니다.
> 어제 알려주신대로 하니 OpenPP문제는 감쪽같이 해결됬습니다^^
그걸 응용해서 골드일때 매수, 데드일때 매도로 리버스전략을 만들어봤는데 아무리해봐도 데이터가 틀립니다.
수정부탁드리오며, 다시금 감사합니다.
===========================================================
Input : 수량(1);
Var : MP(0),BuySellEntryPrice(0),OpenPP(0),NP(0);
If MP == 0 Then{
If CrossUp(Ma(C,5),Ma(C,20)) Then{
MP = 1;
BuySellEntryPrice = C;
}
If CrossDown(Ma(C,5),Ma(C,20)) Then{
MP = -1;
BuySellEntryPrice = C;
}
}
If MP == 1 Then{
OpenPP = (C-BuySellEntryPrice)*수량;
If CrossDown(Ma(C,5),Ma(C,20)) Then{
MP = 0;
NP = NP+OpenPP;
OpenPP = 0;
}
}
If MP == -1 Then {
OpenPP = (BuySellEntryPrice-C)*수량;
If CrossUp(Ma(C,5),Ma(C,20)) Then{
MP = 0;
NP = NP+OpenPP;
OpenPP = 0;
}
}
MessageLog("시가,%.4f,종가,%.4f,MP,%.0f,NP,%.4f,OpenPP,%.4f",open,close,MP,NP,OpenPP);
다음글
이전글