settotalBar(100);
variable:BBI(0),intrabarPersist _entry(0),intrabarPersist _priceentry(0),intrabarPersist _pricequitw(0),intrabarPersist _pricequitl(0);
BBI=(average(close,3)+average(close,6)+average(close,12)+average(close,24))/4;
condition1=getfield("close","tick")<=BBI+3 and getfield("close","tick")>=BBI-3;//多單進場
condition2=_entry=1 and getfield("close","tick")>=_pricequitw;//多單賺出場
condition3=_entry=1 and getfield("close","tick")<=_pricequitl;//多單賠出場
_entry=0;
_priceentry=0;
_pricequitw=0;
_pricequitl=0;
plot1(BBI,"BBI",checkbox:=1);
if condition1 and _entry=0 then begin
_entry=1;
_priceentry=getfield("close","tick");
_pricequitw=_priceentry+3;
_pricequitl=_priceentry-3;
plot2(_priceentry,"B",checkbox:=1);
if condition2 then begin
_entry=0;
plot3(_pricequitw,"W",checkbox:=1);noplot(4);noplot(5);
end;
if condition3 then begin
_entry=0;
plot4(_pricequitl,"L",checkbox:=1);noplot(3);noplot(5);
end;
if not condition2 and not condition3 then begin
_entry=1;
plot5(_priceentry,"K",checkbox:=1);noplot(3);noplot(4);
end;
end;
我想寫一個盤中觀察的指標,以BBI均線附近3點以內買進一口,買進時在k棒下方出現”B”符號,當盤中tick價格往上達3點獲利離場就在K棒上方出現”$”符號,當盤中tick價格往下達3點停損離場就在K棒上方出現”X”符號,而如果此根K棒時間過去沒觸及獲利停損,就k棒上方出現”閃電”符號,然後在往後的k棒若能獲利出場就在上方出現”$”符號,若停損出場就在上方出現”X”符號,過程中一律是一口出場後才進下一口,請問如何寫才能達成這樣的盤中觀察指標?附上影片可見程式跑得不如預期

8 評論