請教如何把的指標模式程式改為,警示模式的程式

  •   417 
  • 最後發表   Zack  2016 八月 25
Zack 發文於   2016/08/24

請教如何把下列指標模式的程式改為,警示模式的程式


variable: intrabarpersist position(0); // 目前position variable: intrabarpersist entry_price(0); // 最後一次進場的價格 //進場邏輯 // condition1 = close crosses above average(close, 20); // 出場邏輯 // condition2 = close crosses below average(close, 20); if position = 0 then begin if condition1 then begin position = 1; entry_price = close; print("(ENTRY) Date:", Date, " EntryPrice:", entry_price); plot1(low * 0.98, "entry"); end; end else begin if condition2 then begin position = 0; entry_price = 0; print("(EXIT) Date:", Date); plot2(high * 1.02, "exit"); end; end; Input: Period1(1); SetInputName(1, "EMA1");

XQ小幫手 發文於   2016/08/25

Hi Zack:

請將 plot1 與 plot2 註解,

並各別添加 ret = 1;

應該在警示腳本,就能編譯成功囉!

 

 

程式碼範例大致如下

...

//plot1(low * 0.98, "entry");

ret = 1;

...

//plot2(high * 1.02, "exit");

ret = 1;

...

 

完整的程式碼範例

variable: intrabarpersist position(0); // 目前position
variable: intrabarpersist entry_price(0); // 最後一次進場的價格

//進場邏輯
//
condition1 = close crosses above average(close, 20);
// 出場邏輯
//
condition2 = close crosses below average(close, 20);

if position = 0 then
begin
if condition1 then
    begin
        position = 1;
        entry_price = close;
        print("(ENTRY) Date:", Date, " EntryPrice:", entry_price);
        //plot1(low * 0.98, "entry");
        ret = 1;
    end;
end
    else
        begin
        if condition2 then
            begin
                position = 0;
                entry_price = 0;
                print("(EXIT) Date:", Date);
                //plot2(high * 1.02, "exit");
                ret = 1;
            end;
        end;

 

以上,提供給您參考,謝謝您。

 

 

 

 

 

  • 按讚來自於
  • mk1977tw
發表回覆
Close