程式碼分析.10

2021/12/31閱讀時間約 3 分鐘
這篇的程式碼是利用開盤價、收盤價來判斷多空趨勢,閱讀後能夠修改的地方很多,是一篇激發靈感的好文章唷 !
Inputs:OpenLen(0),CloseLen(0);
Vars:Histogram(0),BuyPrice(0),SellPrice(0),LongExitPrice(0),ShortExitPrice(0);
Vars:MP(0),StopPrice(0);
Histogram = xAverage(Close,CloseLen)-xAverage(Open,OpenLen);
If Histogram Cross Over 0 then begin
BuyPrice = High+Average(TrueRange,10)*0.5;
LongExitPrice = Low[1]-Average(TrueRange,10)[1]*0.5;
End;
If Histogram Cross Under 0 then begin
SellPrice = Low-Average(TrueRange,10)*0.5;
ShortExitPrice = High[1]+Average(TrueRange,10)[1]*0.5;
End;
If MRO(Histogram Cross Over 0,10,1)>-1 and Histogram>0 then Buy next bar at BuyPrice Stop;
If MRO(Histogram Cross Under 0,10,1)>-1 and Histogram<0 then SellShort next bar at SellPrice Stop;
If Histogram cross under 0 then Sell this bar at Close;
If Histogram cross over 0 then BuyToCover this bar at Close;
Sell next bar at LongExitPrice stop;
BuyToCover next bar at ShortExitPrice stop;
MP=MarketPosition;
If MP=1 and MP[1]=0 then StopPrice=Low-Average(Range,4);
If MP=-1 and MP[1]=0 then StopPrice=High+Average(Range,4);
If MP=1 then begin
Sell next bar at StopPrice Stop;
StopPrice = StopPrice+(Low-StopPrice)/3;
End;
If MP=-1 then begin
BuyToCover next bar at StopPrice Stop;
StopPrice = StopPrice-(StopPrice-High)/3;
End;
為什麼會看到廣告
Piemann
Piemann
Piemann 只是一位中年大叔 !
留言0
查看全部
發表第一個留言支持創作者!