커뮤니티
30분봉 진입 후 120분봉 청산 수식 요청건
2019-04-18 19:13:17
233
글번호 127965
아래수식은 파라볼릭 30분봉,60분봉이 모두 매수 신호일때 특정 조건(엔벨로프/거래량)에 부합할때 매수 진입하고 ( 매도는 반대)
30분봉에 특정조건에의해 청산하는 입니다...
제가 구현하고 싶어하는것은 .....
일단 챠트챵을 종목추가를 통해 3개의 분봉을 설정한후 ( 30분 /60분 / 120분봉)
진입은 기존과 동일
청산을 기존 30분봉기준이 아니라 120분봉기준으로 설정할수 있게 수식 부탁드려요~~
======================================================================
Input : af(0.02), maxAF(0.2);
Input : P1(30400),P2(39000);
Input : Period(20), Percent1(0.8),Percent2(0.7);
Input : 음봉틱수1(1),음봉틱수2(0);
Input : 청산양봉틱수1(6),청산양봉틱수2(7);
Input : M1(0),M2(0);
input : 즉시익절1(75),즉시손절1(75),봉완성손절1(65);
input : 즉시익절2(70),즉시손절2(85),봉완성손절2(45);
Var : S1(0,data1),S2(0,data2); # 30분봉:S1 60분봉:S2
var : center(0,data1),UPline(0,data1),DNline(0,data1); # 엔벨로프
var : T(0,data1);
center = data1(ma(C, Period));
UPline = data1(EnvelopeUp(Period, Percent1));
Dnline = data1(EnvelopeDown(Period, Percent2));
S1 = data1(CSar(af,maxAF));
S2 = data2(CSar(af,maxAF));
if data1(crossup(c,S1)) Then
T = 1;
if data1(CrossDown(c,S1)) Then
T = -1;
if T == 1 and data1(C>upline and V >= P1) and data2(C > S2) Then
{
T = 3;
buy("매수",AtLimit,C-PriceScale*음봉틱수1);
}
if T == -1 and data1(C<dnline and V >= P2) and data2(C < S2) Then
{
T = -3;
sell("매도",AtLimit,C+PriceScale*음봉틱수2);
}
if MarketPosition == 1 then
{
ExitLong("즉시익절1",AtLimit,EntryPrice+PriceScale*즉시익절1);
if BarsSinceEntry >= M1 and c[1]>c[2] Then
ExitLong("봉완성익절1",AtLimit,C+PriceScale*청산양봉틱수1);
ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1);
if c <= EntryPrice-PriceScale*봉완성손절1 Then
ExitLong("봉완성손절1");
}
if MarketPosition == -1 then
{
ExitShort("즉시익절2",AtLimit,EntryPrice-PriceScale*즉시익절2);
if BarsSinceEntry >= M2 and c[1]<c[2] Then
ExitShort("봉완성익절2",AtLimit,C-PriceScale*청산양봉틱수2);
ExitShort("즉시손절2",AtStop,EntryPrice+PriceScale*즉시손절2);
if c >= EntryPrice+PriceScale*봉완성손절2 Then
ExitShort("봉완성손절2");
}
답변 1
예스스탁 예스스탁 답변
2019-04-22 10:43:38
> 이형지 님이 쓴 글입니다.
> 제목 : 30분봉 진입 후 120분봉 청산 수식 요청건
> 아래수식은 파라볼릭 30분봉,60분봉이 모두 매수 신호일때 특정 조건(엔벨로프/거래량)에 부합할때 매수 진입하고 ( 매도는 반대)
30분봉에 특정조건에의해 청산하는 입니다...
제가 구현하고 싶어하는것은 .....
일단 챠트챵을 종목추가를 통해 3개의 분봉을 설정한후 ( 30분 /60분 / 120분봉)
진입은 기존과 동일
청산을 기존 30분봉기준이 아니라 120분봉기준으로 설정할수 있게 수식 부탁드려요~~
======================================================================
Input : af(0.02), maxAF(0.2);
Input : P1(30400),P2(39000);
Input : Period(20), Percent1(0.8),Percent2(0.7);
Input : 음봉틱수1(1),음봉틱수2(0);
Input : 청산양봉틱수1(6),청산양봉틱수2(7);
Input : M1(0),M2(0);
input : 즉시익절1(75),즉시손절1(75),봉완성손절1(65);
input : 즉시익절2(70),즉시손절2(85),봉완성손절2(45);
Var : S1(0,data1),S2(0,data2); # 30분봉:S1 60분봉:S2
var : center(0,data1),UPline(0,data1),DNline(0,data1); # 엔벨로프
var : T(0,data1);
center = data1(ma(C, Period));
UPline = data1(EnvelopeUp(Period, Percent1));
Dnline = data1(EnvelopeDown(Period, Percent2));
S1 = data1(CSar(af,maxAF));
S2 = data2(CSar(af,maxAF));
if data1(crossup(c,S1)) Then
T = 1;
if data1(CrossDown(c,S1)) Then
T = -1;
if T == 1 and data1(C>upline and V >= P1) and data2(C > S2) Then
{
T = 3;
buy("매수",AtLimit,C-PriceScale*음봉틱수1);
}
if T == -1 and data1(C<dnline and V >= P2) and data2(C < S2) Then
{
T = -3;
sell("매도",AtLimit,C+PriceScale*음봉틱수2);
}
if MarketPosition == 1 then
{
ExitLong("즉시익절1",AtLimit,EntryPrice+PriceScale*즉시익절1);
if BarsSinceEntry >= M1 and c[1]>c[2] Then
ExitLong("봉완성익절1",AtLimit,C+PriceScale*청산양봉틱수1);
ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1);
if c <= EntryPrice-PriceScale*봉완성손절1 Then
ExitLong("봉완성손절1");
}
if MarketPosition == -1 then
{
ExitShort("즉시익절2",AtLimit,EntryPrice-PriceScale*즉시익절2);
if BarsSinceEntry >= M2 and c[1]<c[2] Then
ExitShort("봉완성익절2",AtLimit,C-PriceScale*청산양봉틱수2);
ExitShort("즉시손절2",AtStop,EntryPrice+PriceScale*즉시손절2);
if c >= EntryPrice+PriceScale*봉완성손절2 Then
ExitShort("봉완성손절2");
}