예스스탁
예스스탁 답변
2023-09-05 10:18:46
안녕하세요
예스스탁입니다.
1
이전 문의하신 내용과 구조는 같습니다.
다만 수식에 이름확인 함수가 최종 1개의 진입만 구별이 가능하므로
2가지 조건이 동시 충족시에는 합산수량으로 진입하게 하셔야 합니다.
지지와 저항은 직전 저점/고점 돌파/이탈로 작성해 드립니다.
해당 부분은 사용자분께서 조건지정해 수정하셔야 합니다.
input : P1(10),P2(30),P3(100),P(50);
Input : n1(2), n2(1), 익절(5), 손절(7);
Var: myAtr(0);
var : mav1(0),mav2(0),mav3(0);
var : b2(0),b3(0),b4(0),b5(0),b6(0);
var : s2(0),s3(0),s4(0),s5(0),s6(0);
Var: 매수조건(false), 매도조건(false), Long1(false), Long2(false), Short1(false), Short2(false);
var : vol(0),hh(0),ll(0);
mav1 = ma(C,P1);
mav2 = ma(C,P2);
mav3 = ma(C,P3);
myAtr = Atr(P);
매수조건 = mav1 > mav2 and mav2 > mav3;
매도조건 = mav1 < mav2 and mav2 < mav3;
if SwingHigh(1,h,3,3,7) != -1 Then
hh = h[3];
if Swinglow(1,L,3,3,7) != -1 Then
ll = L[3];
Long1 = min(C,O)-L >= abs(C-O)*3;
Long2 = CrossUp(c,ll);
Short1 = H-max(C,O) >= abs(C-O)*3;
Short1 = CrossDown(c,ll);
if MarketPosition <= 0 and 매수조건 == true and 매수조건[1] == False Then
Buy("b1",OnClose,Def,n1);
if MarketPosition >= 0 and 매도조건 == true and 매도조건[1] == False Then
Sell("s1",OnClose,Def,n1);
if MarketPosition == 1 Then
{
if long1 == true or long2 == true Then
{
vol = 0;
if long1 == true Then
vol = vol+n1;
if long2 == true Then
vol = vol+n2;
if MaxEntries == 1 Then
Buy("b2",OnClose,Def,vol);
if MaxEntries == 1 Then
Buy("b3",OnClose,Def,vol);
if MaxEntries == 1 Then
Buy("b4",OnClose,Def,vol);
if MaxEntries == 1 Then
Buy("b5",OnClose,Def,vol);
if MaxEntries == 1 Then
Buy("b6",OnClose,Def,vol);
}
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "b2" Then
b2 = LatestEntryPrice(0);
if LatestEntryName(0) == "b3" Then
b3 = LatestEntryPrice(0);
if LatestEntryName(0) == "b4" Then
b4 = LatestEntryPrice(0);
if LatestEntryName(0) == "b5" Then
b5 = LatestEntryPrice(0);
if LatestEntryName(0) == "b6" Then
b6 = LatestEntryPrice(0);
}
if b2 > 0 Then
{
ExitLong("bp2",AtLimit,b2+myAtr*익절,"b2");
ExitLong("bl2",AtStop,b2-myAtr*손절,"b2");
}
if b3 > 0 Then
{
ExitLong("bp3",AtLimit,b3+myAtr*익절,"b3");
ExitLong("bl3",AtStop,b3-myAtr*손절,"b3");
}
if b4 > 0 Then
{
ExitLong("bp4",AtLimit,b4+myAtr*익절,"b4");
ExitLong("bl4",AtStop,b4-myAtr*손절,"b4");
}
if b5 > 0 Then
{
ExitLong("bp5",AtLimit,b5+myAtr*익절,"b5");
ExitLong("bl5",AtStop,b5-myAtr*손절,"b5");
}
if b6 > 0 Then
{
ExitLong("bp6",AtLimit,b6+myAtr*익절,"b6");
ExitLong("bl6",AtStop,b6-myAtr*손절,"b6");
}
}
Else
{
b2 = 0;
b3 = 0;
b4 = 0;
b5 = 0;
b6 = 0;
}
if MarketPosition == -1 Then
{
if short1 == true or short2 == true Then
{
vol = 0;
if short1 == true Then
vol = vol+n1;
if short2 == true Then
vol = vol+n2;
if MaxEntries == 1 Then
Sell("s2",OnClose,Def,vol);
if MaxEntries == 2 Then
Sell("s3",OnClose,Def,vol);
if MaxEntries == 3 Then
Sell("s4",OnClose,Def,vol);
if MaxEntries == 4 Then
Sell("s5",OnClose,Def,vol);
if MaxEntries == 5 Then
Sell("s6",OnClose,Def,vol);
}
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "s2" Then
s2 = LatestEntryPrice(0);
if LatestEntryName(0) == "s3" Then
s3 = LatestEntryPrice(0);
if LatestEntryName(0) == "s4" Then
s4 = LatestEntryPrice(0);
if LatestEntryName(0) == "s5" Then
s5 = LatestEntryPrice(0);
if LatestEntryName(0) == "s6" Then
s6 = LatestEntryPrice(0);
}
if s2 > 0 Then
{
ExitShort("sp2",AtLimit,s2-myAtr*익절,"s2");
ExitShort("sl2",AtStop,s2+myAtr*손절,"s2");
}
if s3 > 0 Then
{
ExitShort("sp3",AtLimit,s3-myAtr*익절,"s3");
ExitShort("sl3",AtStop,s3+myAtr*손절,"s3");
}
if s4 > 0 Then
{
ExitShort("sp4",AtLimit,s4-myAtr*익절,"s4");
ExitShort("sl4",AtStop,s4+myAtr*손절,"s4");
}
if s5 > 0 Then
{
ExitShort("sp5",AtLimit,s5-myAtr*익절,"s5");
ExitShort("sl5",AtStop,s5+myAtr*손절,"s5");
}
if s6 > 0 Then
{
ExitShort("sp6",AtLimit,s6-myAtr*익절,"s6");
ExitShort("sl6",AtStop,s6+myAtr*손절,"s6");
}
}
Else
{
s2 = 0;
s3 = 0;
s4 = 0;
s5 = 0;
s6 = 0;
}
2
input : P1(10),P2(30),P3(100),P(50);
Input : n1(2), n2(1), 익절(5), 손절(7);
Var: myAtr(0);
var : mav1(0),mav2(0),mav3(0);
Var: 매수조건(false), 매도조건(false), Long1(false), Long2(false), Short1(false), Short2(false);
mav1 = ma(C,P1);
mav2 = ma(C,P2);
mav3 = ma(C,P3);
myAtr = Atr(P);
매수조건 = mav1 > mav2 and mav2 > mav3;
매도조건 = mav1 < mav2 and mav2 < mav3;
if MarketPosition == 0 and 매수조건 == true and 매수조건[1] == False Then
Buy("b1",OnClose,Def,n1);
if MarketPosition == 0 and 매도조건 == true and 매도조건[1] == False Then
Sell("s1",OnClose,Def,n1);
if MarketPosition == 1 Then
{
ExitLong("bp",AtLimit,EntryPrice+myAtr*익절);
ExitLong("bl",AtStop,EntryPrice-myAtr*손절);
}
if MarketPosition == -1 Then
{
ExitShort("sp",AtLimit,EntryPrice-myAtr*익절);
ExitShort("sl",AtStop,EntryPrice+myAtr*손절);
}
즐거운 하루되세요
> 에구머니 님이 쓴 글입니다.
> 제목 : 수식 문의
> 안녕하세요?
수식 문의 드립니다.
감사합니다.