#공통 지표
특정시점에 콜과 풋을 동시 주문(매수/매도)을 가정하고
합산손익을 그리는 지표입니다.
차트에 콜과 풋이 적용되어 있어야 합니다.
기본종목으로 콜을, 참조종목으로 풋을 추가한 후에
아래 지표를 적용하시면 됩니다.
차트왼쪽 상단의 종목선택 버튼 중
왼쪽버튼은 기본종목, 오른쪽은 참조종목을 추가하는 버튼입니다.
//data1 콜
//data2 풋
input : 콜주문(1);//콜주문방향(1은 매수, -1은 매도)
input : 콜수량(1);//콜주문수량
input : 풋주문(1);//풋주문방향(1은 매수,-1은 매도)
input : 풋수량(1);//풋주문수량
input : 진입시간(84500),청산시간(154500);
var : Tcond(False),CallEntryPrice(0),PutEntryPrice(0);
var : CallPL(0),PutPL(0),sumPL(0),MaxProfit(0),MaxLoss(0);
if Bdate != Bdate[1] Then
{
CallEntryPrice = Nan;
PutEntryPrice = Nan;
MaxProfit = Nan;
MaxLoss = Nan;
}
if (sdate != sDate[1] and sTime >= 청산시간) or
(sdate == sDate[1] and sTime >= 청산시간 and sTime[1] < 청산시간) Then
{
Tcond = False;
}
if (sdate != sDate[1] and sTime >= 진입시간) or
(sdate == sDate[1] and sTime >= 진입시간 and sTime[1] < 진입시간) Then
{
Tcond = true;
CallEntryPrice = Data1(c);
PutEntryPrice = Data2(c);
MaxProfit = Nan;
MaxLoss = Nan;
}
if Tcond == true then
{
if 콜주문 == 1 Then
CallPL = ((data1(C)-CallEntryPrice)*콜수량)*BigPointValue;
Else
CallPL = ((CallEntryPrice-data1(C))*콜수량)*BigPointValue;
if 풋주문 == 1 Then
PutPL = ((data2(c)-PutEntryPrice)*풋수량)*BigPointValue;
Else
PutPL = ((PutEntryPrice-data2(c))*풋수량)*BigPointValue;
sumPL = CallPL+PutPL;
if IsNan(MaxProfit) == true Then
MaxProfit = sumPL;
Else
{
if sumPL > MaxProfit Then
MaxProfit = sumPL;
}
if IsNan(MaxLoss) == true Then
MaxLoss = sumPL;
Else
{
if sumPL < MaxLoss Then
MaxLoss = sumPL;
}
Plot1(sumPL,"양합손익");
Plot2(MaxProfit,"최고손익");
Plot3(MaxLoss,"최저손익");
}
Else
{
NoPlot(1);
NoPlot(2);
NoPlot(3);
NoPlot(4);
}
JavaScript
복사
