COCO研究院

 找回密碼
 註冊
搜索
查看: 2660|回復: 7

[教學] 請教各位if出現K線A然後下條K線是B then 買入的寫法

[複製鏈接]
發表於 17-4-20 06:03 | 顯示全部樓層 |閱讀模式
各位大大,想請教if出現K線A然後下條K線是B  then 買入的寫法

發表於 17-4-20 09:42 | 顯示全部樓層
請善用[n]

ex1:
c[2] ==> 表示2根K棒前的收盤價

ex2:(以空頭吞噬為例)

if c<o and c[1]>o[1] and
     (o>=c[1] and c<o[1]) or (o>c[1] and c<=o[1]) then
     sell next bar market;
 樓主| 發表於 17-4-20 14:37 | 顯示全部樓層
如果第一根K線是if sgb and close>0 then  plotpb(h,l,"x",rgb(153,153,153))然後下一根K線是if sgb and close>1 then  plotpb(h,l,"x",rgb(153,153,153))應該怎樣寫
發表於 17-4-20 19:36 | 顯示全部樓層
假設是要根據 Close > n 的方式來畫 K棒,由於先使用了 Close > 0 , 因此下一根 Close > 1 的條件都不會被執行, 可以改成

if sgb then begin
   if  close > 1  then plotpb(h,l,"x",rgb(153,153,153))  { 處理大於 1的狀況 }
       else if close > 0 then plotpb(h,l,"x",rgb(153,153,153))  ; { 處理 0~ 1 間的狀況 }
end ;
 樓主| 發表於 17-4-20 23:25 | 顯示全部樓層
因為用了太多THEN,所以最後想請問怎樣加THEN BUY("BUY") next bar at market;?
發表於 17-4-21 10:35 | 顯示全部樓層
var:conditionA(false),conditionB(false);

conditionA=close>close[1];
conditionB=close[1]>close[2];

if conditionA and conditionB then
        buy next bar at market;
發表於 17-4-21 11:37 來自手機 | 顯示全部樓層
把plotpb這裡換成買賣指令即可
發表於 17-4-26 14:30 | 顯示全部樓層
如果第一根K線是if sgb  then  plotpb(h,l,"x",rgb(153,153,153))然後下一根K線是if sgc  then  plotpb(h,l,"x",rgb(153,153,153))應該怎樣寫
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-4-30 03:22

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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