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

COCO研究院

 找回密碼
 註冊
搜索
查看: 17970|回復: 11

請教簡單的畫圖

[複製鏈接]
發表於 13-7-30 18:49 | 顯示全部樓層 |閱讀模式
本帖最後由 altubers 於 13-7-30 18:52 編輯

請問想在ab的圖上
當紅k時,畫一個向上的arrow
當黑k時,畫一個向下的arrow
就理解上 加了這行code...

IIf( Close > Open ,PlotShapes(shapeUpArrow,colorRed,0,High,10) , PlotShapes(shapeDownArrow,colorBlue,0,Low,10 ));


但為何出現了如圖的清況呢?

plotshapes

plotshapes


謝謝
也有用簡單的if else .. 但出來也是跟著點選的kbar 跑
發表於 13-7-30 20:23 | 顯示全部樓層
用法錯誤....
參考 http://www.amibroker.com/guide/afl/iif.html

Please note that IIF is a function - so the result of evaluation is returned by that function and should be assigned to some variable. IIf always evaluates both TRUE_PART and FALSE_PART, even though it returns only one of them. Because of this, you should watch for undesirable side effects. The following example shows one common error made with IIF function: IIF( condition, result = 7, result = 9 ); // THIS IS WRONG Correct usage is: result = IIF( condition, 7, 9 ); /* 7 or 9 is *returned* and assigned to a variable depending on condition */
發表於 13-7-30 20:46 | 顯示全部樓層
所以可行的做法如下

PlotShapes ( IIf( Close > Open, shapeUpArrow, shapeDownArrow), IIf( Close > Open, colorRed, colorGreen),0, IIf( Close > Open, Low-1,High+1));
 樓主| 發表於 13-7-30 20:54 | 顯示全部樓層
謝謝,我在試試…
發表於 13-7-30 21:27 | 顯示全部樓層
看妳的附圖 你要的好像是這樣

PlotShapes ( IIf( Close > Open, shapeUpArrow, shapeDownArrow), IIf( Close > Open, colorRed, colorGreen),0, IIf( Close > Open, HIGH+12,low-12));
 樓主| 發表於 13-7-30 21:35 | 顯示全部樓層
感謝moneymaker
我剛也有試出來了

  1. PlotShapes( IIf( C < O,shapeUpArrow ,shapeDownArrow ) ,IIf( C < O,colorRed ,colorGreen ),0,IIf( C < O,H ,L ) ,10) ;
複製代碼

只是在於我要應用的地方是
先求出特定的Direction方向後 劃出arrow... 就失敗了…
  1. PlotShapes(IIf(  Direction =="R",shapeUpArrow,shapeDownArrow) ,IIf(  Direction =="R",colorRed ,colorGreen ),0,IIf(  Direction =="R",H ,L ),10);
複製代碼
感覺上c<o是k bar的欄位…  direction會是運算完的常數
反成了這樣子
cocoin.png

努力破解中~~


 樓主| 發表於 13-7-30 21:39 | 顯示全部樓層
太感謝moneymaker大了…
一開始那只是我在測試的… 原本想說應該是一樣的東西
但發現沒想的那麼簡單了
發表於 13-7-30 21:40 | 顯示全部樓層
貼全文來看看....
 樓主| 發表於 13-7-30 22:00 | 顯示全部樓層
本帖最後由 altubers 於 13-7-30 22:03 編輯
  1. function getNum(_value){
  2.         biString = NumToStr(_value);         
  3.         return  StrToNum(biString );
  4. }

  5. function getDirection(){     
  6.     MAD  =  getNum( MA(C,10) < MA(C,30));
  7.     VAD  =  getNum(  MA(V,10) < MA(V,30));
  8.      //printf(" MAD  :"+MAD  +" VAD  :"+VAD  +"\n");
  9.     Direction  =   "N";
  10.     if(MAD  ==VAD   ) Direction  =   "R"; else Direction  =   "G";

  11.     //printf(" Direction  :"+Direction  +"\n");
  12.     PlotShapes(IIf(  Direction =="R",shapeUpArrow,shapeDownArrow) ,IIf(  Direction =="R",colorRed ,colorGreen ),0,IIf(  Direction =="R",H ,L ),10);      
  13. }
複製代碼
目前測試是拿ma 和mv來計算…arrow到是隨著點到的k bar而改變

在寫的時後還有另一個問題就是
  1. MSD =MA(C,10) < MA(C,30)
複製代碼
這時後 If(MSD) 確會是錯的... MA(C,10) < MA(C,30) 不是 bool 還真不習慣~~
發表於 13-7-30 22:24 | 顯示全部樓層
altubers 發表於 13-7-30 22:00
目前測試是拿ma 和mv來計算…arrow到是隨著點到的k bar而改變

在寫的時後還有另一個問題就是

可以用下列寫法改看看
  1. _DirectionR = ( Close > Open );
  2. _DirectionG = NOT( _DirectionR );
  3. _ArrowPosY = IIf( _DirectionR , Low, High );
  4. _ArrowColor = IIf( _DirectionR , colorRed, colorGreen );

  5. PlotShapes( shapeUpArrow * _DirectionR + shapeDownArrow * _DirectionG
  6.     , _ArrowColor
  7.     , 0
  8.     , _ArrowPosY
  9.     , -20
  10. );
複製代碼


發表於 13-7-30 23:26 | 顯示全部樓層
MAD =  MA(C,10) - MA(C,30);
VAD =  MA(V,10) - MA(V,30);
  Direction = IIf ( (MAD>0 AND VAD>0) OR ( MAD<0 AND VAD<0), 1, -1 );
  PlotShapes ( IIf(  Direction>0 AND C>O, shapeUpArrow, shapeDownArrow), IIf( Direction>0 AND C>O , colorRed, colorGreen),0, IIf(  Direction>0 AND C>O,  Low-12,High+12));

評分

參與人數 2金錢 +4 收起 理由
altubers + 2 按一個讚
enochyu + 2 熱心 ~ 讚啦

查看全部評分

發表於 18-4-12 10:40 | 顯示全部樓層
感謝各位大大的啟發與技巧分享.
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-3-29 08:28

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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