커뮤니티
수식문의
2011-12-15 01:21:39
325
글번호 45788
아래 수식은 역마틴방식의 계약수 변경인데요... 1주씩 계약수 변경하는게 아니고 1000주단위로 변경되게 수식 변환 부탁드립니다.
input: P1(5), P2(20),maxcont(10);
vars: mafast(0), maslow(0), ncontr(0),XCommission(0),XSlippage(0);
mafast = average(close, P1);
maslow = average(close, P2);
XCommission = c*(ExitCommission/100); #%설정
XSlippage = ExitSlippage; #Pt설정
if crossup(mafast,maslow) then {
if MarketPosition == -1 then {
exitshort();
if (PositionProfit-(XCommission+XSlippage)*CurrentContracts) > 0 then
ncontr = ncontr+1;
else
ncontr = 1;
}
if MarketPosition != 1 then {
Buy("B", onclose,def,iff(max(1,ncontr)<10,max(1,ncontr),10));
}
}
if CrossDown(mafast,maslow) then {
if MarketPosition == 1 then {
exitlong();
if (PositionProfit-(XCommission+XSlippage)*CurrentContracts) > 0 then
ncontr = ncontr+1;
else
ncontr = 1;
}
if MarketPosition != -1 then {
Sell("S", onclose,def,iff(max(1,ncontr)<10,max(1,ncontr),10));
}
}
답변 1
예스스탁 예스스탁 답변
2011-12-15 11:46:37
안녕하세요
예스스탁입니다.
input: P1(5), P2(20),최대누적수량(100000);
vars: mafast(0), maslow(0), ncontr(0),XCommission(0),XSlippage(0);
mafast = average(close, P1);
maslow = average(close, P2);
XCommission = c*(ExitCommission/100); #%설정
XSlippage = ExitSlippage; #Pt설정
if crossup(mafast,maslow) then {
if MarketPosition == -1 then {
exitshort();
if (PositionProfit-(XCommission+XSlippage)*CurrentContracts) > 0 then
ncontr = ncontr+1000;
else
ncontr = 1000;
}
if MarketPosition != 1 then {
Buy("B", onclose,def,iff(max(1000,ncontr)<최대누적수량,max(1000,ncontr),최대누적수량));
}
}
if CrossDown(mafast,maslow) then {
if MarketPosition == 1 then {
exitlong();
if (PositionProfit-(XCommission+XSlippage)*CurrentContracts) > 0 then
ncontr = ncontr+1000;
else
ncontr = 1000;
}
if MarketPosition != -1 then {
Sell("S", onclose,def,iff(max(1000,ncontr)<최대누적수량,max(1000,ncontr),최대누적수량));
}
}
즐거운 하루되세요
> 무명 님이 쓴 글입니다.
> 제목 : 수식문의
> 아래 수식은 역마틴방식의 계약수 변경인데요... 1주씩 계약수 변경하는게 아니고 1000주단위로 변경되게 수식 변환 부탁드립니다.
input: P1(5), P2(20),maxcont(10);
vars: mafast(0), maslow(0), ncontr(0),XCommission(0),XSlippage(0);
mafast = average(close, P1);
maslow = average(close, P2);
XCommission = c*(ExitCommission/100); #%설정
XSlippage = ExitSlippage; #Pt설정
if crossup(mafast,maslow) then {
if MarketPosition == -1 then {
exitshort();
if (PositionProfit-(XCommission+XSlippage)*CurrentContracts) > 0 then
ncontr = ncontr+1;
else
ncontr = 1;
}
if MarketPosition != 1 then {
Buy("B", onclose,def,iff(max(1,ncontr)<10,max(1,ncontr),10));
}
}
if CrossDown(mafast,maslow) then {
if MarketPosition == 1 then {
exitlong();
if (PositionProfit-(XCommission+XSlippage)*CurrentContracts) > 0 then
ncontr = ncontr+1;
else
ncontr = 1;
}
if MarketPosition != -1 then {
Sell("S", onclose,def,iff(max(1,ncontr)<10,max(1,ncontr),10));
}
}
다음글
이전글