커뮤니티

청산 수식 문의드립니다.

프로필 이미지
고르면상한가
2021-04-06 18:34:46
823
글번호 147759
답변완료
안녕하세요. 트레일링 청산과 관련하여 아래와 같이 구현해보려고 합니다. - 포지션 진입후 40틱 목표가 이후부터 특정(%)or(Tick) 이하로 떨어질경우 청산 단, 목표가 40틱 이후 60틱, 80틱, 120틱, 150틱, 200틱, 250틱, 300틱 단위로 목표수익을 달성할 경우 한단계식 40부터 300까지 청산 기준값이 바뀌는것을 구현해보려고 합니다. 즉 40틱 달성시부터 트레일링시작, 만약 40틱이후 수익이60틱을 갱신한 경우 목표가의 기준이 40에서 60으로 바뀌는 형태입니다. 그렇게 40틱에서 300틱가지 순차적으로 트레일링 기준값을 올려가는 것을 알려주시면 감사하겠습니다. 감사합니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-04-07 14:06:05

안녕하세요 예스스탁입니다. 1. 틱 input : 수익1(40),수익2(60),수익3(80),수익4(120),수익5(150),수익6(200),수익7(250),수익8(300); input : 감소1(10),감소2(20),감소3(30),감소4(40),감소5(50),감소6(60),감소7(70),감소8(80); var : BH(0),SL(0); if MarketPosition == 1 Then { BH = Highest(H,BarsSinceEntry); if BH >= EntryPrice+PriceScale*수익1 and BH < EntryPrice+PriceScale*수익2 Then ExitLong("bx1",AtStop,BH-PriceScale*감소1); if BH >= EntryPrice+PriceScale*수익2 and BH < EntryPrice+PriceScale*수익3 Then ExitLong("bx2",AtStop,BH-PriceScale*감소2); if BH >= EntryPrice+PriceScale*수익3 and BH < EntryPrice+PriceScale*수익4 Then ExitLong("bx3",AtStop,BH-PriceScale*감소3); if BH >= EntryPrice+PriceScale*수익4 and BH < EntryPrice+PriceScale*수익5 Then ExitLong("bx4",AtStop,BH-PriceScale*감소4); if BH >= EntryPrice+PriceScale*수익5 and BH < EntryPrice+PriceScale*수익6 Then ExitLong("bx5",AtStop,BH-PriceScale*감소5); if BH >= EntryPrice+PriceScale*수익6 and BH < EntryPrice+PriceScale*수익7 Then ExitLong("bx6",AtStop,BH-PriceScale*감소6); if BH >= EntryPrice+PriceScale*수익7 and BH < EntryPrice+PriceScale*수익8 Then ExitLong("bx7",AtStop,BH-PriceScale*감소7); if BH >= EntryPrice+PriceScale*수익8 Then ExitLong("bx8",AtStop,BH-PriceScale*감소8); } if MarketPosition == 1 Then { SL = Highest(H,BarsSinceEntry); if SL <= EntryPrice-PriceScale*수익1 and SL > EntryPrice-PriceScale*수익2 Then ExitShort("sx1",AtStop,SL+PriceScale*감소1); if SL <= EntryPrice-PriceScale*수익2 and SL > EntryPrice-PriceScale*수익3 Then ExitShort("sx2",AtStop,SL+PriceScale*감소2); if SL <= EntryPrice-PriceScale*수익3 and SL > EntryPrice-PriceScale*수익4 Then ExitShort("sx3",AtStop,SL+PriceScale*감소3); if SL <= EntryPrice-PriceScale*수익4 and SL > EntryPrice-PriceScale*수익5 Then ExitShort("sx4",AtStop,SL+PriceScale*감소4); if SL <= EntryPrice-PriceScale*수익5 and SL > EntryPrice-PriceScale*수익6 Then ExitShort("sx5",AtStop,SL+PriceScale*감소5); if SL <= EntryPrice-PriceScale*수익6 and SL > EntryPrice-PriceScale*수익7 Then ExitShort("sx6",AtStop,SL+PriceScale*감소6); if SL <= EntryPrice-PriceScale*수익7 and SL > EntryPrice-PriceScale*수익8 Then ExitShort("sx7",AtStop,SL+PriceScale*감소7); if SL <= EntryPrice-PriceScale*수익8 Then ExitShort("sx8",AtStop,SL+PriceScale*감소8); } 2.% input : 수익1(40),수익2(60),수익3(80),수익4(120),수익5(150),수익6(200),수익7(250),수익8(300); input : 감소1(2),감소2(4),감소3(6),감소4(8),감소5(10),감소6(12),감소7(14),감소8(16); var : BH(0),SL(0); if MarketPosition == 1 Then { BH = Highest(H,BarsSinceEntry); if BH >= EntryPrice+PriceScale*수익1 and BH < EntryPrice+PriceScale*수익2 Then ExitLong("bx1",AtStop,BH*(1-감소1/100)); if BH >= EntryPrice+PriceScale*수익2 and BH < EntryPrice+PriceScale*수익3 Then ExitLong("bx2",AtStop,BH*(1-감소2/100)); if BH >= EntryPrice+PriceScale*수익3 and BH < EntryPrice+PriceScale*수익4 Then ExitLong("bx3",AtStop,BH*(1-감소3/100)); if BH >= EntryPrice+PriceScale*수익4 and BH < EntryPrice+PriceScale*수익5 Then ExitLong("bx4",AtStop,BH*(1-감소4/100)); if BH >= EntryPrice+PriceScale*수익5 and BH < EntryPrice+PriceScale*수익6 Then ExitLong("bx5",AtStop,BH*(1-감소5/100)); if BH >= EntryPrice+PriceScale*수익6 and BH < EntryPrice+PriceScale*수익7 Then ExitLong("bx6",AtStop,BH*(1-감소6/100)); if BH >= EntryPrice+PriceScale*수익7 and BH < EntryPrice+PriceScale*수익8 Then ExitLong("bx7",AtStop,BH*(1-감소7/100)); if BH >= EntryPrice+PriceScale*수익8 Then ExitLong("bx8",AtStop,BH*(1-감소8/100)); } if MarketPosition == -1 Then { SL = Lowest(L,BarsSinceEntry); if SL <= EntryPrice-PriceScale*수익1 and SL > EntryPrice-PriceScale*수익2 Then ExitShort("sx1",AtStop,SL*(1+감소1/100)); if SL <= EntryPrice-PriceScale*수익2 and SL > EntryPrice-PriceScale*수익3 Then ExitShort("sx2",AtStop,SL*(1+감소2/100)); if SL <= EntryPrice-PriceScale*수익3 and SL > EntryPrice-PriceScale*수익4 Then ExitShort("sx3",AtStop,SL*(1+감소3/100)); if SL <= EntryPrice-PriceScale*수익4 and SL > EntryPrice-PriceScale*수익5 Then ExitShort("sx4",AtStop,SL*(1+감소4/100)); if SL <= EntryPrice-PriceScale*수익5 and SL > EntryPrice-PriceScale*수익6 Then ExitShort("sx5",AtStop,SL*(1+감소5/100)); if SL <= EntryPrice-PriceScale*수익6 and SL > EntryPrice-PriceScale*수익7 Then ExitShort("sx6",AtStop,SL*(1+감소6/100)); if SL <= EntryPrice-PriceScale*수익7 and SL > EntryPrice-PriceScale*수익8 Then ExitShort("sx7",AtStop,SL*(1+감소7/100)); if SL <= EntryPrice-PriceScale*수익8 Then ExitShort("sx8",AtStop,SL*(1+감소8/100)); } 즐거운 하루되세요 > 고르면상한가 님이 쓴 글입니다. > 제목 : 청산 수식 문의드립니다. > 안녕하세요. 트레일링 청산과 관련하여 아래와 같이 구현해보려고 합니다. - 포지션 진입후 40틱 목표가 이후부터 특정(%)or(Tick) 이하로 떨어질경우 청산 단, 목표가 40틱 이후 60틱, 80틱, 120틱, 150틱, 200틱, 250틱, 300틱 단위로 목표수익을 달성할 경우 한단계식 40부터 300까지 청산 기준값이 바뀌는것을 구현해보려고 합니다. 즉 40틱 달성시부터 트레일링시작, 만약 40틱이후 수익이60틱을 갱신한 경우 목표가의 기준이 40에서 60으로 바뀌는 형태입니다. 그렇게 40틱에서 300틱가지 순차적으로 트레일링 기준값을 올려가는 것을 알려주시면 감사하겠습니다. 감사합니다.