這是我的策略,用在30分K
好幾次下了買單金到了停損價沒有賣出,一看停利單還在,但停損單被取消了,想請問高手原因??
// Created from 2023/10/17
// 30 min K ,
// QS_AVG_V00
// QS_AVG_V01 2023/10/21
inputs:
longon(0),
shorton(0),
longlen(38),
shortlen(38),
suplen( 114) ;
vars:
// AvgPrice(0); //Built-In Function Already
//shortlen(0),
stop_price(0),
stop_price_short(0),
MA1(0),
MA2(0),
MA3(0),
MA4(0),
MA5(0),
MA6(0),
MA_sup(0),
MA_short(0),
MA_long(0);
//shortlen = longlen;
MA1 = Average(C, 9);
MA2 = Average(C, 19);
MA3 = Average(C, 38);
MA4 = Average(C, 57);
MA5 = Average(C, 76);
MA6 = Average(C, 95);
MA_sup = Average(C, suplen );
MA_long = Average(C, longlen);
MA_short = Average(C, shortlen);
//MA6 = Average(C, 19*6);
condition1 = MA_long[1] > MA_long[2]; // Up Trend Status
condition2 = MA_short[1] < MA_short[2]; // Down Trend Status
condition3 = AvgPrice cross above MA_long; // Cross Above MA3 Timing
condition4 = AvgPrice cross below MA_short; // Cross Below MA3 Timing
condition5 = AvgPrice[1] < MA_long[1]; // Price Under Status
condition6 = AvgPrice[1] > MA_short[1]; // Price Higher Status
condition7 = C > MA_sup;//TRUE;//MA_sup[1] > MA_sup[2];//MA6[1] > MA6[2]; // Long Up Trend Status
condition8 = C < MA_sup;//TRUE;//MA_sup[1] < MA_sup[2];//MA6[1] < MA6[2]; // Long Down Trend Status
if longon = 1 then
begin
if condition1 and condition5 and condition3 and condition7 then
begin
buy next bar market;
//buy next bar at highest(H , 3) stop;
//stop_price = lowest( L , 3);
end;
if marketposition=1 and barssinceentry=1 then stop_price = lowest( L , 3);
if marketposition > 0 then
begin
sell next bar at stop_price stop;
sell next bar at entryprice +300 limit;
end;
end;
// short
if shorton = 1 then
begin
if condition2 and condition6 and condition4 and condition8 then
begin
sellshort next bar market;
//buy next bar at highest(H , 3) stop;
stop_price_short = highest( H , 3);
end;
if marketposition < 0 then
begin
buytocover next bar at stop_price_short stop;
buytocover next bar at entryprice -300 limit;
end;
end;
if marketposition[1]=1 and marketposition=0 then stop_price=99999 ;
if marketposition[1]=-1 and marketposition=0 then stop_price_short=0 ;
//if marketposition>0 then sell next bar at entryprice* (1-N1/100) stop ;
//if marketposition<0 then buytocover next bar at entryprice* (1+N2/100) stop ;
// moving profit stop
{inputs: nProfit(100),nPercentage(10);
if marketposition <> 0 then begin
value1 = (maxpositionprofit / currentcontracts /bigpointvalue);
if value1 >= nProfit then begin
sell("BX-PercenTrailing") next bar avgentryprice + value1 - value1*nPercentage/100 stop;
buytocover("SX-PercentTrailing") next bar avgentryprice -value1 + value1*nPercentage/100 stop;
end;
end;
}
if (DAYofMonth(Date)>14 and DAYofMonth(Date)<22 and DAYofWeek(Date)=3) then setexitonclose;
|