커뮤니티
수정부탁드립니다.
2015-06-17 19:27:30
111
글번호 87343
아래 지표식에서 주석처리한 MP >= 0의 방법이 아닌 MP == 0, MP > 0, MP < 0 으로 나누어 작성하고 싶습니다. 리버셜이외의 전략에도 사용가능하게
부탁드립니다.
=======================================================
Input : 수량(1),봉갯수(10);
Var : MP(0),BuySellEntryPrice(0),OpenPP(0),NP(0);
var : Hst(0),Lst(0),idx(-1);
Hst = Highest(H,봉갯수);
Lst = Lowest(L,봉갯수);
If MP == 1 Then{
OpenPP = (C-BuySellEntryPrice)*수량;
}
If MP == -1 Then {
OpenPP = (BuySellEntryPrice-C)*수량;
}
If MP == 0 Then {
OpenPP = 0;
}
//If MP <= 0 and Hst[1] < H and index > idx Then{
idx = index;
if MP == -1 Then{
NP = NP+OpenPP;
}
BuySellEntryPrice = C;
MP = 1;
}
//If MP >= 0 and Lst[1] > L and index > idx Then{
idx = index;
if MP == 1 Then{
NP = NP+OpenPP;
}
BuySellEntryPrice = C;
MP = -1;
}
//plot1(OpenPP);
//plot2(NP);
MessageLog("시가,%.4f,종가,%.4f,MP,%.0f,NP,%.4f,OpenPP,%.4f",open,close,MP,NP,OpenPP);
====================================================================
Input: 봉갯수(10);
If MarketPosition == 0 Then{
If Highest(H,봉갯수)[1] < H Then
{
Buy();
}
If Lowest(L,봉갯수)[1] > L Then
{
Sell();
}
}
If MarketPosition > 0 Then{
If Lowest(L,봉갯수)[1] > L Then Sell();
}
If MarketPosition < 0 Then
{
If Highest(H,봉갯수)[1] < H Then Buy();
}
답변 1
예스스탁 예스스탁 답변
2015-06-18 11:38:48
안녕하세요
예스스탁입니다.
MP == 0은 포지션이 없을때 진입이므로
청산식이 별도로 존재를 해야 합니다.
만약 기존진입외에 별도의 청산이 있다면
MP가 0이 되는 청산조건을 추가하셔야 합니다.
아래 주석 참고하시기 바랍니다.
Input : 수량(1),봉갯수(10);
Var : MP(0),BuySellEntryPrice(0),OpenPP(0),NP(0);
var : Hst(0),Lst(0),idx(-1);
Hst = Highest(H,봉갯수);
Lst = Lowest(L,봉갯수);
If MP == 1 Then{
OpenPP = (C-BuySellEntryPrice)*수량;
}
If MP == -1 Then {
OpenPP = (BuySellEntryPrice-C)*수량;
}
If MP == 0 Then {
OpenPP = 0;
}
#MP가 0일때 매수조건 만족
If MP == 0 and Hst[1] < H and index > idx Then{
idx = index;
BuySellEntryPrice = C;
MP = 1;
}
#MP가 -1일때 매수조건 만족(리버스)
If MP < 0 and Hst[1] < H and index > idx Then{
idx = index;
if MP == -1 Then{
NP = NP+OpenPP;
}
BuySellEntryPrice = C;
MP = 1;
}
#MP가 1일때 매수청산조건 만족
If MP < 0 and 매도청산조건 and index > idx Then{
idx = index;
NP = NP+OpenPP;
MP = 0;
}
#MP가 0일때 매도조건 만족
If MP == 0 and Lst[1] > L and index > idx Then{
idx = index;
BuySellEntryPrice = C;
MP = -1;
}
#MP가 1일때 매도조건 만족(리버스)
If MP > 0 and Lst[1] > L and index > idx Then{
idx = index;
if MP == 1 Then{
NP = NP+OpenPP;
}
BuySellEntryPrice = C;
MP = -1;
}
#MP가 1일때 매수청산조건 만족
If MP > 0 and 매수청산조건 and index > idx Then{
idx = index;
NP = NP+OpenPP;
MP = 0;
}
//plot1(OpenPP);
//plot2(NP);
MessageLog("시가,%.4f,종가,%.4f,MP,%.0f,NP,%.4f,OpenPP,%.4f",open,close,MP,NP,OpenPP);
즐거운 하루되세요
> 9단 님이 쓴 글입니다.
> 제목 : 수정부탁드립니다.
> 아래 지표식에서 주석처리한 MP >= 0의 방법이 아닌 MP == 0, MP > 0, MP < 0 으로 나누어 작성하고 싶습니다. 리버셜이외의 전략에도 사용가능하게
부탁드립니다.
=======================================================
Input : 수량(1),봉갯수(10);
Var : MP(0),BuySellEntryPrice(0),OpenPP(0),NP(0);
var : Hst(0),Lst(0),idx(-1);
Hst = Highest(H,봉갯수);
Lst = Lowest(L,봉갯수);
If MP == 1 Then{
OpenPP = (C-BuySellEntryPrice)*수량;
}
If MP == -1 Then {
OpenPP = (BuySellEntryPrice-C)*수량;
}
If MP == 0 Then {
OpenPP = 0;
}
//If MP <= 0 and Hst[1] < H and index > idx Then{
idx = index;
if MP == -1 Then{
NP = NP+OpenPP;
}
BuySellEntryPrice = C;
MP = 1;
}
//If MP >= 0 and Lst[1] > L and index > idx Then{
idx = index;
if MP == 1 Then{
NP = NP+OpenPP;
}
BuySellEntryPrice = C;
MP = -1;
}
//plot1(OpenPP);
//plot2(NP);
MessageLog("시가,%.4f,종가,%.4f,MP,%.0f,NP,%.4f,OpenPP,%.4f",open,close,MP,NP,OpenPP);
====================================================================
Input: 봉갯수(10);
If MarketPosition == 0 Then{
If Highest(H,봉갯수)[1] < H Then
{
Buy();
}
If Lowest(L,봉갯수)[1] > L Then
{
Sell();
}
}
If MarketPosition > 0 Then{
If Lowest(L,봉갯수)[1] > L Then Sell();
}
If MarketPosition < 0 Then
{
If Highest(H,봉갯수)[1] < H Then Buy();
}