請選擇 進入手機版 | 繼續訪問電腦版

COCO研究院

 找回密碼
 註冊
搜索
123
返回列表 發新帖
樓主: eychang

[範例程式碼] 吊燈式追蹤停利( Chandelier trailing stop)

[複製鏈接]
發表於 19-10-5 16:06 | 顯示全部樓層
新手新手請多多指教,謝謝大大的分享 讓我多學一種出場方式
發表於 20-4-22 19:31 | 顯示全部樓層
學到新的出場方法,感謝
發表於 21-8-5 14:46 | 顯示全部樓層
謝謝大大的分享,
新手,有需要多參考各種的方法,多試一些出場方法
發表於 22-7-20 23:09 | 顯示全部樓層
大家好,我想把這個寫成一個指標疊加在價位上。
因為沒有下單指令,所以就虛擬一個初始...但一直不成功,想請教高手那裏出了問題???


inputs:

        len_latern(25),
        len_atr(50),
        coef(2);
       
vars:
       
        cond5(False),
        cond6(False),
        call_stop(H),
        put_stop(L),
        Pos_H(0),
        Pos_L(0),
        var1(0),
        var2(0),
        status(0);

        if CurrentBar = 1 then
        begin
                Pos_H = H ;
                Pos_L = L ;
                status = 0;
//                call_stop = Pos_H - 100;
//                put_stop = Pos_L + 100;
        end ;

       
        if status = 1 and H > Pos_H then  // Do the call
                Pos_H = H ;
               
        if status = -1 and L < Pos_L then // Do the put
                Pos_L = L ;


       
//        call_stop = highest(h,len_latern) - coef * AvgTrueRange(len_atr);  // Call stop line
//        put_stop = lowest(l,len_latern)  + coef * AvgTrueRange(len_atr);  // Put stop line

if currentbar > 100 then
begin
        call_stop = Pos_H - coef * AvgTrueRange(len_atr);  // Call stop line
        put_stop = Pos_L  + coef * AvgTrueRange(len_atr);  // Put stop line
end;       
        if  c cross below call_stop then begin
                status = -1;
                Pos_L = L ;
               
               
                end;
        if  h cross above put_stop then begin
                status = 1;
                Pos_H = H ;
               
                end ;

       

if status = 1 then
        plot1(call_stop,"",RED);
//        plot4(Pos_H,"",RED);
if status = -1 then
        Plot2(put_stop,"",GREEN);       
//        Plot3(Pos_L,"",GREEN);       
發表於 22-8-6 06:55 | 顯示全部樓層
最後有把指標寫出來,給有需要的人參考。

inputs:

        len_latern(25),
        len_atr(50),
        len(50),
        coef(2);
       
vars:
       
        cond5(False),
        cond6(False),
        call_stop(H),
        put_stop(L),
        Pos_H(0),
        Pos_L(0),
        var1(0),
        var2(0),
        status(0);

        if CurrentBar = 100 then
        begin
                Pos_H = H ;
                Pos_L = L ;
                status = 0;
//                call_stop = Pos_H - 100;
//                put_stop = Pos_L + 100;
        end ;
if currentbar = 100 then
begin
                Pos_H = H ;
                call_stop = Pos_H - coef * AvgTrueRange(len);  // Call stop line
                Pos_L = L ;
                put_stop = Pos_L  + coef * AvgTrueRange(len);  // Put stop line
end;


if currentbar > 100 then
begin

        if status = 1 and H > Pos_H then  // Do the call
        begin
                Pos_H = H ;
                call_stop = Pos_H - coef * AvgTrueRange(len);  // Call stop line

        end;       
        if status = -1 and L < Pos_L then // Do the put
        begin

                Pos_L = L ;
                put_stop = Pos_L  + coef * AvgTrueRange(len);  // Put stop line
        end;

       
//        call_stop = highest(h,len_latern) - coef * AvgTrueRange(len_atr);  // Call stop line
//        put_stop = lowest(l,len_latern)  + coef * AvgTrueRange(len_atr);  // Put stop line

       

        if  c cross below call_stop then begin
                status = -1;
                Pos_L = L ;
                put_stop = Pos_L  + coef * AvgTrueRange(len);  // Put stop line
                end;
        if  c cross above put_stop then begin
                status = 1;
                Pos_H = H ;
                call_stop = Pos_H - coef * AvgTrueRange(len);  // Call stop line               
                end ;
end;       
       

if status = 1 then begin
        plot1(call_stop,"",RED);
//        plot4(Pos_H,"",YELLOW);
        end;
if status = -1 then begin  
        Plot2(put_stop,"",GREEN);       
//        Plot3(Pos_L,"",BLUE);       
        end;

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-3-29 18:52

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook