예스스탁
예스스탁 답변
2023-10-10 11:23:02
안녕하세요
예스스탁입니다.
buy,sell진입함수는 4번째 매개변수가 수량입니다.
올려주신 식에서 첫진입은 수량이 1이고, 추가진입은 2개로 되어 있습니다.
각각 외부변수 처리해 드립니다.
원하시는 수량으로 지정하시기 바랍니다.
Input: 전환틱수(20),첫진입수량(1),추가진입수량(2);
Var : j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분("");
var : TL1(0),TX1(0);
Array:고[10,6](0),저[10,6](0);
HH = H;
LL = L;
If Bdate != Bdate[1] Then
{
고[1,1] = HH;
고[1,2] = 0;
고[1,3] = sDate;
고[1,4] = sTime;
고[1,5] = 0;
저[1,1] = LL;
저[1,2] = 0;
저[1,3] = sDate;
저[1,4] = sTime;
저[1,5] = 0;
}
else
{
hiBar = hiBar + 1;
loBar = loBar + 1;
}
If HH[hiBar] < HH Then hiBar = 0;
If LL[loBar] > LL Then loBar = 0;
Condition1 = 저[1,1]+PriceScale*전환틱수 < HH and hiBar == 0;
Condition2 = 고[1,1]-PriceScale*전환틱수 > LL and loBar == 0;
처리구분 = "";
If Condition1 and Condition2 Then // 고점과 저점 조건 동시 만족
{
If 최종꼭지점 == "저점" Then
{
If 저[1,1] > LL Then 처리구분 = "저점처리";
Else 처리구분 = "고점처리";
}
Else If 최종꼭지점 == "고점" Then
{
If 고[1,1] < HH Then 처리구분 = "고점처리";
Else 처리구분 = "저점처리";
}
}
Else If Condition1 Then 처리구분 = "고점처리";
Else If Condition2 Then 처리구분 = "저점처리";
If 처리구분 == "고점처리" Then
{
If 최종꼭지점 == "저점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 5
{
고[j,jj] = 고[j-1,jj];
}
}
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
고[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL1 = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,RED);
TX1 = Text_New(고[1,3],고[1,4],고[1,1],NumToStr(고[1,1],2)+NewLine+"+"+NumToStr(고[1,5],2));
Text_SetColor(TX1,RED);
Text_SetStyle(TX1,2,1);
}
Else If 고[1,1] < HH[hiBar] Then // 1번 고점보다 높은 고가 출현
{
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
고[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
Text_SetLocation(TX1,고[1,3],고[1,4],고[1,1]);
Text_SetString(TX1,NumToStr(고[1,1],2)+NewLine+"+"+NumToStr(고[1,5],2));
}
최종꼭지점 = "고점";
}
If 처리구분 == "저점처리" Then
{
If 최종꼭지점 == "고점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 5
{
저[j,jj] = 저[j-1,jj];
}
}
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
저[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL1 = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,BLUE);
TX1 = Text_New(저[1,3],저[1,4],저[1,1],NumToStr(저[1,1],2)+"-"+NewLine+NumToStr(저[1,5],2));
Text_SetColor(TX1,Blue);
Text_SetStyle(TX1,2,0);
}
Else If 저[1,1] > LL[loBar] Then
{
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
저[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
Text_SetLocation(TX1,저[1,3],저[1,4],저[1,1]);
Text_SetString(TX1,NumToStr(저[1,1],2)+NewLine+"-"+NumToStr(저[1,5],2));
}
최종꼭지점 = "저점";
}
if MarketPosition >= 0 and 고[2,3] == sDate and 고[2,5] > 0 and NextBarSdate == sDate Then
Sell("s1",AtLimit,고[2,1]+고[2,5],첫진입수량);
if MarketPosition == -1 Then
{
Sell("s2",AtLimit,EntryPrice+고[2,5][BarsSinceEntry],추가진입수량);
if MaxEntries == 1 Then
ExitShort("sx1",AtLimit,고[2,1][BarsSinceEntry]);
Else
ExitShort("sx2",AtLimit,EntryPrice);
}
if MarketPosition >= 0 and 저[2,3] == sDate and 저[2,5] > 0 and NextBarSdate == sDate Then
Buy("b1",AtLimit,저[2,1]-저[2,5],첫진입수량);
if MarketPosition == 1 Then
{
Buy("b2",AtLimit,EntryPrice-저[2,5][BarsSinceEntry],추가진입수량);
if MaxEntries == 1 Then
Exitlong("bx1",AtLimit,저[2,1][BarsSinceEntry]);
Else
ExitLong("bx2",AtLimit,EntryPrice);
}
즐거운 하루되세요
> 매운포도 님이 쓴 글입니다.
> 제목 : 수정부탁드립니다
> 아래 수식에서 수량을 수정하고싶습니다
어디서해야하는지를몰라서요^^::
예제)10개로수정한다고 예를들어서수정한다고 하였을때입니다
Input: 전환틱수(20);
Var : j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분("");
var : TL1(0),TX1(0);
Array:고[10,6](0),저[10,6](0);
HH = H;
LL = L;
If Bdate != Bdate[1] Then
{
고[1,1] = HH;
고[1,2] = 0;
고[1,3] = sDate;
고[1,4] = sTime;
고[1,5] = 0;
저[1,1] = LL;
저[1,2] = 0;
저[1,3] = sDate;
저[1,4] = sTime;
저[1,5] = 0;
}
else
{
hiBar = hiBar + 1;
loBar = loBar + 1;
}
If HH[hiBar] < HH Then hiBar = 0;
If LL[loBar] > LL Then loBar = 0;
Condition1 = 저[1,1]+PriceScale*전환틱수 < HH and hiBar == 0;
Condition2 = 고[1,1]-PriceScale*전환틱수 > LL and loBar == 0;
처리구분 = "";
If Condition1 and Condition2 Then // 고점과 저점 조건 동시 만족
{
If 최종꼭지점 == "저점" Then
{
If 저[1,1] > LL Then 처리구분 = "저점처리";
Else 처리구분 = "고점처리";
}
Else If 최종꼭지점 == "고점" Then
{
If 고[1,1] < HH Then 처리구분 = "고점처리";
Else 처리구분 = "저점처리";
}
}
Else If Condition1 Then 처리구분 = "고점처리";
Else If Condition2 Then 처리구분 = "저점처리";
If 처리구분 == "고점처리" Then
{
If 최종꼭지점 == "저점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 5
{
고[j,jj] = 고[j-1,jj];
}
}
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
고[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL1 = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,RED);
TX1 = Text_New(고[1,3],고[1,4],고[1,1],NumToStr(고[1,1],2)+NewLine+"+"+NumToStr(고[1,5],2));
Text_SetColor(TX1,RED);
Text_SetStyle(TX1,2,1);
}
Else If 고[1,1] < HH[hiBar] Then // 1번 고점보다 높은 고가 출현
{
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
고[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
Text_SetLocation(TX1,고[1,3],고[1,4],고[1,1]);
Text_SetString(TX1,NumToStr(고[1,1],2)+NewLine+"+"+NumToStr(고[1,5],2));
}
최종꼭지점 = "고점";
}
If 처리구분 == "저점처리" Then
{
If 최종꼭지점 == "고점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 5
{
저[j,jj] = 저[j-1,jj];
}
}
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
저[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL1 = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,BLUE);
TX1 = Text_New(저[1,3],저[1,4],저[1,1],NumToStr(저[1,1],2)+"-"+NewLine+NumToStr(저[1,5],2));
Text_SetColor(TX1,Blue);
Text_SetStyle(TX1,2,0);
}
Else If 저[1,1] > LL[loBar] Then
{
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
저[1,5] = abs(고[1,1]-저[1,1]);
hiBar = -1;
loBar = -1;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
Text_SetLocation(TX1,저[1,3],저[1,4],저[1,1]);
Text_SetString(TX1,NumToStr(저[1,1],2)+NewLine+"-"+NumToStr(저[1,5],2));
}
최종꼭지점 = "저점";
}
if MarketPosition >= 0 and 고[2,3] == sDate and 고[2,5] > 0 and NextBarSdate == sDate Then
Sell("s1",AtLimit,고[2,1]+고[2,5],1);
if MarketPosition == -1 Then
{
Sell("s2",AtLimit,EntryPrice+고[2,5][BarsSinceEntry],2);
if MaxEntries == 1 Then
ExitShort("sx1",AtLimit,고[2,1][BarsSinceEntry]);
Else
ExitShort("sx2",AtLimit,EntryPrice);
}
if MarketPosition >= 0 and 저[2,3] == sDate and 저[2,5] > 0 and NextBarSdate == sDate Then
Buy("b1",AtLimit,저[2,1]-저[2,5],1);
if MarketPosition == 1 Then
{
Buy("b2",AtLimit,EntryPrice-저[2,5][BarsSinceEntry],2);
if MaxEntries == 1 Then
Exitlong("bx1",AtLimit,저[2,1][BarsSinceEntry]);
Else
ExitLong("bx2",AtLimit,EntryPrice);
}