예스스탁
예스스탁 답변
2020-04-01 18:37:56
안녕하세요
예스스탁입니다.
식을 수정했습니다.
3번 진입 후 마지막 진입가격에서 20틱 손실시 청산되게 수정해 드립니다.
Input : af(0.02), maxAF(0.2);
input : StartTime(70000),EndTime(230000);
Var : value(0),Tcond(false),entry(0);
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
entry = 0;
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then
entry = entry+1;
value = sar(af,maxAF);
if tcond == true then
{
If MarketPosition <= 0 and crossup(c,value) and entry < 1 Then
{
Buy("b1");
}
If MarketPosition >= 0 and CrossDown(c,value) and entry < 1 Then
{
Sell("s1");
}
if MarketPosition == 1 then
{
ExitLong("bp",Atlimit,AvgEntryPrice+PriceScale*20);
if MaxEntries == 1 Then
Buy("b2",Atlimit,AvgEntryPrice-PriceScale*20);
if MaxEntries == 2 Then
Buy("b3",Atlimit,AvgEntryPrice-PriceScale*30);
if MaxEntries == 3 Then
ExitLong("bl",AtStop,LatestEntryPrice(0)-PriceScale*20);
}
if MarketPosition == -1 then
{
ExitShort("sp",Atlimit,AvgEntryPrice-PriceScale*20);
if MaxEntries == 1 Then
sell("s2",Atlimit,AvgEntryPrice+PriceScale*20);
if MaxEntries == 2 Then
sell("s3",Atlimit,AvgEntryPrice+PriceScale*30);
if MaxEntries == 3 Then
ExitShort("sl",AtStop,LatestEntryPrice(0)+PriceScale*20);
}
}
즐거운 하루되세요
> 디얼디어 님이 쓴 글입니다.
> 제목 : 수식수정좀 부탁드립니다.
> 수익청산은 제가 원하는데로 되는데 손절청산은 그림처럼 되네요
밑에 수식인데 수정좀 부탁드립니다.
Input : af(0.02), maxAF(0.2);
input : StartTime(70000),EndTime(230000);
Var : value(0),Tcond(false),entry(0);
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
entry = 0;
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then
entry = entry+1;
value = sar(af,maxAF);
if tcond == true then
{
If MarketPosition <= 0 and crossup(c,value) and entry < 1 Then
{
Buy("b1");
}
If MarketPosition >= 0 and CrossDown(c,value) and entry < 1 Then
{
Sell("s1");
}
if MarketPosition == 1 then
{
ExitLong("bp",Atlimit,AvgEntryPrice+PriceScale*20);
if MaxEntries == 1 Then
Buy("b2",Atlimit,AvgEntryPrice-PriceScale*20);
if MaxEntries == 2 Then
Buy("b3",Atlimit,AvgEntryPrice-PriceScale*30);
if MaxEntries == 3 Then
ExitShort("bl",Atlimit,AvgEntryPrice-PriceScale*20);
}
if MarketPosition == -1 then
{
ExitShort("sp",Atlimit,AvgEntryPrice-PriceScale*20);
if MaxEntries == 1 Then
sell("s2",Atlimit,AvgEntryPrice+PriceScale*20);
if MaxEntries == 2 Then
sell("s3",Atlimit,AvgEntryPrice+PriceScale*30);
if MaxEntries == 3 Then
ExitLong("sl",Atlimit,AvgEntryPrice+PriceScale*20);
}
}