커뮤니티

수식 부탁드립니다

프로필 이미지
네온0609
2026-03-26 16:28:14
173
글번호 231288
답변완료

수고하십니다

chatgpt에서 예스랭귀지로 만들어 달라고 했는데 잘안되네요

수식변경가능한지요


Input : 익절1(200), 익절2(400), 손절(200);

Inputs: FastLen(7), MedLen(2);

Input : k(94), k1(23);

Input : Period(7);


Vars: value(0);

Vars: FastAvg(0), MedAvg(0);


Vars: TrailPrice(0), StopPrice(0), Target1(0), Target2(0);

Vars: TrailTick(80);

Vars: Exit1Done(False);


// ------------------------

// 지표

// ------------------------

value = CCI(Period);

FastAvg = MA(Close, FastLen);

MedAvg = MA(Close, MedLen);


// ------------------------

// 진입

// ------------------------

if MarketPosition = 0 then

begin

Exit1Done = False;


if FastAvg > MedAvg and CrossUp(value, -k) then

Buy("Long") 2 contracts next bar at market;


if FastAvg < MedAvg and CrossDown(value, k1) then

SellShort("Short") 2 contracts next bar at market;

end;


// ========================

// 🔴 Long 포지션

// ========================

if MarketPosition = 1 then

begin


// 초기 설정

if BarsSinceEntry = 0 then

begin

TrailPrice = Close - TrailTick;

StopPrice = EntryPrice - 손절;


Target1 = EntryPrice + 익절1;

Target2 = EntryPrice + 익절2;

end;


// 트레일링

TrailPrice = MaxList(TrailPrice, High - TrailTick);


// 브레이크이븐

if Close >= EntryPrice + 100 then

StopPrice = EntryPrice;


// ------------------------

// 1차 익절 (절반 청산)

// ------------------------

if Exit1Done = False and Close >= Target1 then

begin

Sell("HalfExit") 1 contracts next bar at market;

Exit1Done = True;

end;


// ------------------------

// 최종 청산

// ------------------------

Value1 = MaxList(StopPrice, TrailPrice);


if Close >= Target2 then

Sell("FinalExit") next bar at market


else if Close <= Value1 then

Sell("StopExit") next bar at market;


end;


// ========================

// 🔵 Short 포지션

// ========================

if MarketPosition = -1 then

begin


if BarsSinceEntry = 0 then

begin

TrailPrice = Close + TrailTick;

StopPrice = EntryPrice + 손절;


Target1 = EntryPrice - 익절1;

Target2 = EntryPrice - 익절2;

end;


TrailPrice = MinList(TrailPrice, Low + TrailTick);


if Close <= EntryPrice - 100 then

StopPrice = EntryPrice;


if Exit1Done = False and Close <= Target1 then

begin

BuyToCover("HalfExit") 1 contracts next bar at market;

Exit1Done = True;

end;


Value1 = MinList(StopPrice, TrailPrice);


if Close <= Target2 then

BuyToCover("FinalExit") next bar at market


else if Close >= Value1 then

BuyToCover("StopExit") next bar at market;


end;


시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2026-03-27 10:44:58

안녕하세요 예스스탁입니다. Input : 익절1(200), 익절2(400), 손절(200); Inputs: FastLen(7), MedLen(2); Input : k(94), k1(23); Input : Period(7); Vars: value(0); Vars: FastAvg(0), MedAvg(0); Vars: TrailPrice(0), StopPrice(0), Target1(0), Target2(0); Vars: TrailTick(80); Vars: Exit1Done(False); // ------------------------ // 지표 // ------------------------ value = CCI(Period); FastAvg = MA(Close, FastLen); MedAvg = MA(Close, MedLen); // ------------------------ // 진입 // ------------------------ if MarketPosition == 0 then begin Exit1Done = False; if FastAvg > MedAvg and CrossUp(value, -k) then Buy("Long",AtMarket, DEF,2); if FastAvg < MedAvg and CrossDown(value, k1) then Sell("Short",AtMarket,Def, 2); end; // ======================== // ?? Long 포지션 // ======================== if MarketPosition == 1 then begin // 초기 설정 if BarsSinceEntry == 0 then begin TrailPrice = Close - TrailTick; StopPrice = EntryPrice - 손절; Target1 = EntryPrice + 익절1; Target2 = EntryPrice + 익절2; end; // 트레일링 TrailPrice = MaxList(TrailPrice, High - TrailTick); // 브레이크이븐 if Close >= EntryPrice + 100 then StopPrice = EntryPrice; // ------------------------ // 1차 익절 (절반 청산) // ------------------------ if Exit1Done == False and Close >= Target1 then begin ExitLong("bHalfExit",AtMarket,Def,"",1,1); Exit1Done = True; end; // ------------------------ // 최종 청산 // ------------------------ Value1 = MaxList(StopPrice, TrailPrice); if Close >= Target2 then ExitLong("bFinalExit",AtMarket); else if Close <= Value1 then ExitLong("bStopExit",AtMarket); end; // ======================== // ?? Short 포지션 // ======================== if MarketPosition == -1 then begin if BarsSinceEntry == 0 then begin TrailPrice = Close + TrailTick; StopPrice = EntryPrice + 손절; Target1 = EntryPrice - 익절1; Target2 = EntryPrice - 익절2; end; TrailPrice = MinList(TrailPrice, Low + TrailTick); if Close <= EntryPrice - 100 then StopPrice = EntryPrice; if Exit1Done == False and Close <= Target1 then begin ExitShort("sHalfExit",AtMarket,Def,"",1,1); Exit1Done = True; end; Value1 = MinList(StopPrice, TrailPrice); if Close <= Target2 then ExitShort("sFinalExit",AtMarket); else if Close >= Value1 then ExitShort("sStopExit",AtMarket); end; 즐거운 하루되세요