커뮤니티
익절수식 추가
2018-05-09 09:09:24
214
글번호 118754
아래는 buy와 sell 2가지 수식이며 손절과 trailing stop을 사용합니다.
input에서 익절 수식을 추가바랍니다.
항상 고맙습니다.
***************************************
1)buy 수식
input : b1(11),b2(13),진입시간(090000);
input : 손절1(20),TR1(20);
input : 손절2(20),TR2(20);
var : T1(0),entry(0),HH(0),EL(0);
if Bdate != Bdate[1] Then
T1 = TotalTrades;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 and stime >= 진입시간 and
C <= DayHigh-PriceScale*b1 and C[1] > DayHigh-PriceScale*b1 Then
buy("b1");
if TotalTrades > TotalTrades[1] Then
HH = H;
if H > HH Then
HH = H;
if MarketPosition == 0 and entry == 1 and stime >= 진입시간 and C <= HH-PriceScale*b2 and C[1] > HH-PriceScale*b2 Then
buy("b2");
if MarketPosition == 1 then
{
if IsEntryName("b1") == true then
{
ExitLong("bl1",AtStop,EntryPrice-PriceScale*손절1);
ExitLong("btr1",AtStop,highest(h,BarsSinceEntry)-PriceScale*TR1);
}
if IsEntryName("b2") == true then
{
ExitLong("bl2",AtStop,EntryPrice-PriceScale*손절2);
ExitLong("btr2",AtStop,highest(h,BarsSinceEntry)-PriceScale*TR2);
}
}
2) sell 수식
input : s1(20),s2(20),진입시간(090000);
input : 손절1(20),TR1(20);
input : 손절2(20),TR2(20);
var : T1(0),entry(0),LL(0),EH(0);
if Bdate != Bdate[1] Then
T1 = TotalTrades;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 and stime >= 진입시간 and C >= daylow+PriceScale*s1 and C[1] < daylow+PriceScale*s1 Then
sell("s1");
if TotalTrades > TotalTrades[1] Then
LL = L;
if L < LL Then
LL = L;
if MarketPosition == 0 and entry == 1 and stime >= 진입시간 and C >= LL+PriceScale*s2 and C[1] < LL+PriceScale*s2 Then
sell("s2");
if MarketPosition == -1 then
{
if IsEntryName("s1") == true then
{
ExitShort("sl1",AtStop,EntryPrice+PriceScale*손절1);
ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PriceScale*TR1);
}
if IsEntryName("s2") == true then
{
ExitShort("sl2",AtStop,EntryPrice+PriceScale*손절2);
ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PriceScale*TR2);
}
}
답변 1
예스스탁 예스스탁 답변
2018-05-10 11:39:40
안녕하세요
예스스탁입니다.
1.buy
input : b1(11),b2(13),진입시간(090000);
input : 손절1(20),TR1(20),익절1(20);
input : 손절2(20),TR2(20),익절2(20);
var : T1(0),entry(0),HH(0),EL(0);
if Bdate != Bdate[1] Then
T1 = TotalTrades;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 and stime >= 진입시간 and
C <= DayHigh-PriceScale*b1 and C[1] > DayHigh-PriceScale*b1 Then
buy("b1");
if TotalTrades > TotalTrades[1] Then
HH = H;
if H > HH Then
HH = H;
if MarketPosition == 0 and entry == 1 and stime >= 진입시간 and C <= HH-PriceScale*b2 and C[1] > HH-PriceScale*b2 Then
buy("b2");
if MarketPosition == 1 then
{
if IsEntryName("b1") == true then
{
ExitLong("bl1",AtStop,EntryPrice-PriceScale*손절1);
ExitLong("bp1",Atlimit,EntryPrice+PriceScale*익절1);
ExitLong("btr1",AtStop,highest(h,BarsSinceEntry)-PriceScale*TR1);
}
if IsEntryName("b2") == true then
{
ExitLong("bl2",AtStop,EntryPrice-PriceScale*손절2);
ExitLong("bp2",Atlimit,EntryPrice+PriceScale*익절2);
ExitLong("btr2",AtStop,highest(h,BarsSinceEntry)-PriceScale*TR2);
}
}
2.sell
input : s1(20),s2(20),진입시간(090000);
input : 손절1(20),TR1(20),익절1(20);
input : 손절2(20),TR2(20),익절2(20);
var : T1(0),entry(0),LL(0),EH(0);
if Bdate != Bdate[1] Then
T1 = TotalTrades;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 and stime >= 진입시간 and C >= daylow+PriceScale*s1 and C[1] < daylow+PriceScale*s1 Then
sell("s1");
if TotalTrades > TotalTrades[1] Then
LL = L;
if L < LL Then
LL = L;
if MarketPosition == 0 and entry == 1 and stime >= 진입시간 and C >= LL+PriceScale*s2 and C[1] < LL+PriceScale*s2 Then
sell("s2");
if MarketPosition == -1 then
{
if IsEntryName("s1") == true then
{
ExitShort("sl1",AtStop,EntryPrice+PriceScale*손절1);
ExitShort("sp1",AtLimit,EntryPrice-PriceScale*익절1);
ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PriceScale*TR1);
}
if IsEntryName("s2") == true then
{
ExitShort("sl2",AtStop,EntryPrice+PriceScale*손절2);
ExitShort("sp2",AtLimit,EntryPrice-PriceScale*익절2);
ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PriceScale*TR2);
}
}
즐거운 하루되세요
> 좌오비우오비 님이 쓴 글입니다.
> 제목 : 익절수식 추가
> 아래는 buy와 sell 2가지 수식이며 손절과 trailing stop을 사용합니다.
input에서 익절 수식을 추가바랍니다.
항상 고맙습니다.
***************************************
1)buy 수식
input : b1(11),b2(13),진입시간(090000);
input : 손절1(20),TR1(20);
input : 손절2(20),TR2(20);
var : T1(0),entry(0),HH(0),EL(0);
if Bdate != Bdate[1] Then
T1 = TotalTrades;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 and stime >= 진입시간 and
C <= DayHigh-PriceScale*b1 and C[1] > DayHigh-PriceScale*b1 Then
buy("b1");
if TotalTrades > TotalTrades[1] Then
HH = H;
if H > HH Then
HH = H;
if MarketPosition == 0 and entry == 1 and stime >= 진입시간 and C <= HH-PriceScale*b2 and C[1] > HH-PriceScale*b2 Then
buy("b2");
if MarketPosition == 1 then
{
if IsEntryName("b1") == true then
{
ExitLong("bl1",AtStop,EntryPrice-PriceScale*손절1);
ExitLong("btr1",AtStop,highest(h,BarsSinceEntry)-PriceScale*TR1);
}
if IsEntryName("b2") == true then
{
ExitLong("bl2",AtStop,EntryPrice-PriceScale*손절2);
ExitLong("btr2",AtStop,highest(h,BarsSinceEntry)-PriceScale*TR2);
}
}
2) sell 수식
input : s1(20),s2(20),진입시간(090000);
input : 손절1(20),TR1(20);
input : 손절2(20),TR2(20);
var : T1(0),entry(0),LL(0),EH(0);
if Bdate != Bdate[1] Then
T1 = TotalTrades;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 and stime >= 진입시간 and C >= daylow+PriceScale*s1 and C[1] < daylow+PriceScale*s1 Then
sell("s1");
if TotalTrades > TotalTrades[1] Then
LL = L;
if L < LL Then
LL = L;
if MarketPosition == 0 and entry == 1 and stime >= 진입시간 and C >= LL+PriceScale*s2 and C[1] < LL+PriceScale*s2 Then
sell("s2");
if MarketPosition == -1 then
{
if IsEntryName("s1") == true then
{
ExitShort("sl1",AtStop,EntryPrice+PriceScale*손절1);
ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PriceScale*TR1);
}
if IsEntryName("s2") == true then
{
ExitShort("sl2",AtStop,EntryPrice+PriceScale*손절2);
ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PriceScale*TR2);
}
}
다음글
이전글