커뮤니티
trailing stop 2
2018-09-14 14:28:00
191
글번호 122071
buy 포지션 트레일링스탑을 이용하여
sell포지션 수식을 작성해보았습니다.
아래 sell수식이 맞는지요?
if MarketPosition == -1 then
{
ExitShort("sl1",AtStop,EntryPrice+PriceScale*dn손절);
ExitShort("sp1",Atlimit,EntryPrice-PriceScale*dn익절);
if stime >= dnTR1시작 and stime <= dnTR1종료 then
ExitShort("sdntr1",AtStop,highest(h,BarsSinceEntry)+PriceScale*dnTR1);
if stime >= dnTR2시작 and stime <= dnTR2종료 then
ExitShort("sdntr2",AtStop,highest(h,BarsSinceEntry)+PriceScale*dnTR2);
}
**************************************************************************************
if MarketPosition == 1 then
{
ExitLong("bl1",AtStop,EntryPrice-PriceScale*up손절);
ExitLong("bp1",Atlimit,EntryPrice+PriceScale*up익절);
if stime >= upTR1시작 and stime <= upTR1종료 then
ExitLong("buptr1",AtStop,highest(h,BarsSinceEntry)-PriceScale*upTR1);
if stime >= upTR2시작 and stime <= upTR2종료 then
ExitLong("buptr2",AtStop,highest(h,BarsSinceEntry)-PriceScale*upTR2);
}
답변 1
예스스탁 예스스탁 답변
2018-09-14 14:43:38
안녕하세요
예스스탁입니다.
손절과 익절은 맞습니다.
트레일링스탑의 경우에는 매포지션의 경우 최고 수익지점이 진입이후 최저가이므로
highest(h,BarsSinceEntry)를 Lowest(L,BarsSinceEntry)로
변경해 주시고 지정한 값+몇틱으로 지정해 주셔야 합니다.
if MarketPosition == -1 then
{
ExitShort("sl1",AtStop,EntryPrice+PriceScale*dn손절);
ExitShort("sp1",Atlimit,EntryPrice-PriceScale*dn익절);
if stime >= dnTR1시작 and stime <= dnTR1종료 then
ExitShort("sdntr1",AtStop,Lowest(L,BarsSinceEntry)+PriceScale*dnTR1);
if stime >= dnTR2시작 and stime <= dnTR2종료 then
ExitShort("sdntr2",AtStop,Lowest(L,BarsSinceEntry)+PriceScale*dnTR2);
}
즐거운 하루되세요
> 목마와숙녀 님이 쓴 글입니다.
> 제목 : trailing stop 2
> buy 포지션 트레일링스탑을 이용하여
sell포지션 수식을 작성해보았습니다.
아래 sell수식이 맞는지요?
if MarketPosition == -1 then
{
ExitShort("sl1",AtStop,EntryPrice+PriceScale*dn손절);
ExitShort("sp1",Atlimit,EntryPrice-PriceScale*dn익절);
if stime >= dnTR1시작 and stime <= dnTR1종료 then
ExitShort("sdntr1",AtStop,highest(h,BarsSinceEntry)+PriceScale*dnTR1);
if stime >= dnTR2시작 and stime <= dnTR2종료 then
ExitShort("sdntr2",AtStop,highest(h,BarsSinceEntry)+PriceScale*dnTR2);
}
**************************************************************************************
if MarketPosition == 1 then
{
ExitLong("bl1",AtStop,EntryPrice-PriceScale*up손절);
ExitLong("bp1",Atlimit,EntryPrice+PriceScale*up익절);
if stime >= upTR1시작 and stime <= upTR1종료 then
ExitLong("buptr1",AtStop,highest(h,BarsSinceEntry)-PriceScale*upTR1);
if stime >= upTR2시작 and stime <= upTR2종료 then
ExitLong("buptr2",AtStop,highest(h,BarsSinceEntry)-PriceScale*upTR2);
}