COCO研究院

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

AmiBroker不適合當沖

[複製鏈接]
發表於 10-5-25 12:03 | 顯示全部樓層
本帖最後由 baokyo 於 10-5-25 12:04 PM 編輯

我也遇到同樣的問題~~板大
我想他說的問題應該是說假如是當下的K棒為接近KD死亡交叉,瞬間跌下死亡交叉,但是後來又有大量
買進拉了長紅棒在當根內 ,硬是把死亡交叉給拉回非死亡交叉, 請問各位是怎麼解決這個問題的阿?
在程式中 總不能單子下了 又反悔吧@@"
發表於 10-5-25 12:30 | 顯示全部樓層
回復 14# TrendRover


    我回的是他第一篇文,您懂嗎?
發表於 10-5-25 12:40 | 顯示全部樓層
本帖最後由 good88 於 10-5-25 12:44 PM 編輯

如果要讓買賣訊好看的程式,下面程式碼不錯用!(盤後看簡直天下無敵)

_SECTION_BEGIN("ShenbaKumar  pivots");
/* **********************************
Code to automatically identify pivots
By Kumaresan Selvaraj
********************************** */
// -- what will be our lookback range for the hh and ll?
farback = Param("How Far back to go", 100, 50, 5000, 10);
nBars = Param("Number of bars", 12, 5, 40);
// -- Title.

Title = Name() + " (" + StrLeft(FullName(), 15) + ") O: " + Open + ", H: "
+ High + ", L: " + Low + ", C: " + Close;
// -- Plot basic candle chart
PlotOHLC(Open, High, Low, Close,
"BIdx = " + BarIndex() +
"\n" + "O = " + O + "\n" + "H = " + H + "\n" + "L = " + L
+ "\n" + "C ", colorBlack, styleCandle);

GraphXSpace = 7;
// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
// -- More for future use, not necessary for basic plotting
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;
// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);
// -- Would like to set this up so pivots are calculated back from
// last visible bar to make it easy to "go back" and see the pivots
// this code would find. However, the first instance of
// _Trace output will show a value of 0
aVisBars = Status("barvisible");
nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
_TRACE("Last visible bar: " + nLastVisBar);
// -- Initialize value of curTrend
curBar = (BarCount - 1);
curTrend = "";

if (aLLVBars[curBar] < aHHVBars[curBar])
{
  curTrend = "D";
}
else
{
  curTrend = "U";
}
// -- Loop through bars. Search for
// entirely array-based approach
// in future version
for (i = 0; i < farback; i++)
{
  curBar = (BarCount - 1) - i;
  // -- Have we identified a pivot? If trend is down...
  if (aLLVBars[curBar] < aHHVBars[curBar])
  {
    // ... and had been up, this is a trend change
    if (curTrend == "U")
    {
      curTrend = "D";
      // -- Capture pivot information
      curPivBarIdx = curBar - aLLVBars[curBar];
      aLPivs[curPivBarIdx] = 1;
      aLPivLows[nLPivs] = L[curPivBarIdx];
      aLPivIdxs[nLPivs] = curPivBarIdx;
      nLPivs++;
    }
    // -- or current trend is up
  }
  else
  {
    if (curTrend == "D")
    {
      curTrend = "U";
      curPivBarIdx = curBar - aHHVBars[curBar];
      aHPivs[curPivBarIdx] = 1;
      aHPivHighs[nHPivs] = H[curPivBarIdx];
      aHPivIdxs[nHPivs] = curPivBarIdx;
      nHPivs++;
    }
    // -- If curTrend is up...else...
  }
  // -- loop through bars
}
// -- Basic attempt to add a pivot this logic may have missed
// -- OK, now I want to look at last two pivots. If the most
// recent low pivot is after the last high, I could
// still have a high pivot that I didn't catch
// -- Start at last bar
curBar = (BarCount - 1);
candIdx = 0;
candPrc = 0;
lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx)
{
  // -- Bar and price info for candidate pivot
  candIdx = curBar - aHHVBars[curBar];
  candPrc = aHHV[curBar];
  if (
  lastHPH < candPrc AND
  candIdx > lastLPIdx AND
  candIdx < curBar)
  {
    // -- OK, we'll add this as a pivot...
    aHPivs[candIdx] = 1;
    // ...and then rearrange elements in the
    // pivot information arrays
    for (j = 0; j < nHPivs; j++)
    {
      aHPivHighs[nHPivs - j] = aHPivHighs[nHPivs -
      (j + 1)];
      aHPivIdxs[nHPivs - j] = aHPivIdxs[nHPivs - (j + 1)];
    }
    aHPivHighs[0] = candPrc;
    aHPivIdxs[0] = candIdx;
    nHPivs++;
  }
}
else
{
  // -- Bar and price info for candidate pivot
  candIdx = curBar - aLLVBars[curBar];
  candPrc = aLLV[curBar];
  if (lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar)
  {
    // -- OK, we'll add this as a pivot...
    aLPivs[candIdx] = 1;
    // ...and then rearrange elements in the
    // pivot information arrays
    for (j = 0; j < nLPivs; j++)
    {
      aLPivLows[nLPivs - j] = aLPivLows[nLPivs - (j + 1)];
      aLPivIdxs[nLPivs - j] = aLPivIdxs[nLPivs - (j + 1)];
    }
    aLPivLows[0] = candPrc;
    aLPivIdxs[0] = candIdx;
    nLPivs++;
  }
}
// -- Dump inventory of high pivots for debugging
/*
for (k=0; k<nHPivs; k++) {
_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)
+ ", " + aHPivHighs[k]);
}
*/
// -- OK, let's plot the pivots using arrows
PlotShapes(IIf(aHPivs == 1, shapeDownArrow, shapeNone), colorRed, 0, High, Offset =  - 15);
PlotShapes(IIf(aLPivs == 1, shapeUpArrow, shapeNone), colorGreen, 0, Low, Offset =  - 15);
_SECTION_END();
發表於 10-5-25 14:05 | 顯示全部樓層
回復 17# good88


    網路時差,   Sorry!
我愛紅茶 該用戶已被刪除
發表於 10-5-25 19:29 | 顯示全部樓層
本帖最後由 我愛紅茶 於 10-5-25 07:30 PM 編輯

回復 18# good88


   RUN盤後~結果訊號都會延遲出來~會被巴到死感覺上是在摸頭猜底~而且訊號還會立刻就切換變消失
發表於 10-5-25 21:55 | 顯示全部樓層
假如是當下的K棒為接近KD死亡交叉,瞬間跌下死亡交叉,但是後來又有大量
買進拉了長紅棒在當根內 ,硬是把死亡交叉給拉回非死亡交叉



    如果是這個問題, 那就用前一個 KD 的值, 查一下 ref 指令的用法. 如果是回測, 也可以用 SetTradeDelays(1, 1, 1, 1) 讓訊號產生在下一根 K 棒. 試看看可不可以解決.
 樓主| 發表於 10-5-26 08:01 | 顯示全部樓層
本帖最後由 RLRAVYRNLCQYBCQ 於 10-5-26 08:12 AM 編輯

回復 21# sdnian


     ref 指令
     SetTradeDelays(1, 1, 1, 1)
     FLAG (用for( i = 0; i < BarCount; i++ )寫的)

    全部無效~
    用Bar replay 就可以確認

    我還遇過,明明已經過了五分鐘,前面已經成立的買賣訊號居然消失的~
    太短線的交易不能用

    BACK TEST看到的點位, 在 real time 那個買點(or賣點)你絕對買不到, 因為它會後來才出現給你看
 樓主| 發表於 10-5-26 08:23 | 顯示全部樓層
本帖最後由 RLRAVYRNLCQYBCQ 於 10-5-26 08:25 AM 編輯

回復 16# baokyo

只能做波段吧
發表於 10-5-26 09:25 | 顯示全部樓層
AB能不能做當沖,或作波段,要看你的操作邏輯和寫程式的功力,像我附上的程式碼,盤後看很棒,盤中大概就陣亡了...
如果回測不是很好的程式,可以修正就修,否則再找(寫)別的吧!
發表於 10-5-26 18:14 | 顯示全部樓層
回復 22# RLRAVYRNLCQYBCQ


    那我就真的不懂這帖說的問題在哪裡, 因為我自己使用就沒問題, 盤中訊號都能出現在我預期的點, 是真的能交易的點 (先不考慮滑價問題). 要注意的是, AFL 程式在線圖的狀態下就會一直執行. 但是某些指令在回測模式才有作用, 例如前面說的 SetTradeDelays. 在線圖模式下這個沒作用, 所以我用 ref 來判斷前一根K線的條件成立, 然後下一根K線出現時立刻交易.
發表於 10-6-12 14:38 | 顯示全部樓層
好複雜的感覺,努力學習中
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-5-6 22:20

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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