[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] optimizing trades based on a foreign CCI not working as expected



PureBytes Links

Trading Reference Links

Dave,

CCI uses AVERAGE price (Avg) (not close, high, low, etc).

One would need to write either:

Avg = ( Foreign("!VIX", "H") + Foreign("!VIX", "L") + Foreign("!VIX", "C") ) / 3; // overwrite Avg !!
cc = CCI(period);

or write:

cc = CCIa(  ( Foreign("!VIX", "H") + Foreign("!VIX", "L") + Foreign("!VIX", "C") ) / 3, period );


Hope this helps.

Best regards,
Tomasz Janeczko
amibroker.com
  ----- Original Message -----
  From: Dave Merrill
  To: amibroker@xxxxxxxxxxxxxxx
  Sent: Tuesday, September 02, 2003 7:10 AM
  Subject: RE: [amibroker] optimizing trades based on a foreign CCI not working as expected


  um, it would appear that I'm asleep at the switch tonight. there's no need for the gyrations with the price arrays to use a
foreign ticker, because CCIa takes any array you want. I know this.

  I still don't understand why swapping out the price arrays doesn't work with the original price-based CCI, so if anyone has an
answer to that anyway, great.

  but I'm going to bed now, a little behind my brain, it seems.

  dave
    hi jayson, thanks for jumping in.

    aren't you supposed to put things back to the underlying stock after you calculate a function that works directly off the OHLVC
arrays? otherwise, anything else you do, graph price for example, will still be using the foreign infos. or maybe I don't
understand...

    there's an unrelated error in this code, but I don't think it explains the problem I asked about. the sign of the thresholds in
the buy and Sell assignments is reversed. without the foreign CCI, it should read:

    period = Optimize("period", 2, 1, 100, 1);
    threshold = Optimize("threshold", 25, -100, 100, 25);    //includes negative now
    Buy = Cross(cc, -threshold);    //sign changed
    Sell = Cross(threshold, cc);    //sign changed
    Short = Sell;
    Cover = Buy;

    but as I say, I don't think that's why the foreign one doesn't work like I expect. it *is* why performance wasn't what I
expected in most cases though (:-).

    dave
      you change the OHLCV back tot the underlying stock at the bottom of your code. try simply....

      period = Optimize("period", 2, 1, 100, 1);
      threshold = Optimize("threshold", 25, 0, 100, 25);

      O = Foreign("!VIX", "O");
      H = Foreign("!VIX", "H");
      L = Foreign("!VIX", "L");
      C = Foreign("!VIX", "C");
      V = Foreign("!VIX", "V");
      cc = CCI(period);

      Buy = Cross(cc, threshold);
      Sell = Cross(-threshold, cc);
      Short = Sell;
      Cover = Buy;
      ----------------



      Regards,
      Jayson
      -----Original Message-----
      From: Dave Merrill [mailto:dmerrill@xxxxxxx]
      Sent: Monday, September 01, 2003 11:26 PM
      To: AmiBroker
      Subject: [amibroker] optimizing trades based on a foreign CCI not working as expected


      can anyone tell me why these two tests give the same results for every index
      I tried?

      both versions go long and short based on a CCI, optimizing for best returns.
      version 1 uses the CCI of the issue under test, and version 2 uses the CCI
      of another index, I thought.

      but I get the same results no matter what foreign index I use, including
      contrarian ones like the VIX you see below.

      what am I missing?

      thanks,

      dave


      ----------------
      VERSION 1
      ----------------
      period = Optimize("period", 2, 1, 100, 1);
      threshold = Optimize("threshold", 25, 0, 100, 25);

      cc = CCI(period);

      Buy = Cross(cc, threshold);
      Sell = Cross(-threshold, cc);
      Short = Sell;
      Cover = Buy;


      ----------------
      VERSION 2
      ----------------
      period = Optimize("period", 2, 1, 100, 1);
      threshold = Optimize("threshold", 25, 0, 100, 25);

      saveO = O;
      saveH = H;
      saveL = L;
      saveC = C;
      saveV = V;
      O = Foreign("!VIX", "O");
      H = Foreign("!VIX", "H");
      L = Foreign("!VIX", "L");
      C = Foreign("!VIX", "C");
      V = Foreign("!VIX", "V");
      cc = CCI(period);
      O = saveO;
      H = saveH;
      L = saveL;
      C = saveC;
      V = saveV;

      Buy = Cross(cc, threshold);
      Sell = Cross(-threshold, cc);
      Short = Sell;
      Cover = Buy;
      ----------------


      Dave Merrill



      Send BUG REPORTS to bugs@xxxxxxxxxxxxx
      Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
      -----------------------------------------
      Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
      (Web page: http://groups.yahoo.com/group/amiquote/messages/)
      --------------------------------------------
      Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      Send BUG REPORTS to bugs@xxxxxxxxxxxxx
      Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
      -----------------------------------------
      Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
      (Web page: http://groups.yahoo.com/group/amiquote/messages/)
      --------------------------------------------
      Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



    Send BUG REPORTS to bugs@xxxxxxxxxxxxx
    Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
    -----------------------------------------
    Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
    (Web page: http://groups.yahoo.com/group/amiquote/messages/)
    --------------------------------------------
    Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html

    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        Yahoo! Groups Sponsor
              ADVERTISEMENT




  Send BUG REPORTS to bugs@xxxxxxxxxxxxx
  Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
  -----------------------------------------
  Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
  (Web page: http://groups.yahoo.com/group/amiquote/messages/)
  --------------------------------------------
  Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html

  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/