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

RE: [amibroker] Breaking out of a loop...



PureBytes Links

Trading Reference Links




Jason,
 
The point is I don't understand the code 
properly.
 
Herbert
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Jason 
  Hart 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, January 26, 2004 7:50 
  PM
  Subject: Re: [amibroker] Pivots, Pivots, 
  Pivots........
  
  Herbert,
   
  That's strange, it works fine on my end.  Did some of the 
  commentary run over into the code?  If I get errors when I copy 
  and paste it is usually b/c the comments run over onto the next line and 
  Amibroker interprets it is part of the code.  Try fixing the the 
  spacing.  What I do is apply the code from IB and then the 
  error message tells me exactly where the problem lies.
   
  Jason Herbert Elstein 
  <herty@xxxxxxxxxxxxxxxx> wrote:
  <BLOCKQUOTE class=replbq 
  >
    
    

    Jason,
     
    I copied the code, but there are two errors. 
    The first appeared like an extra curly brace, when I removed this I get 
    another error at the end; which probably shows something is wrong before 
    that. I'll appreciate your corrections. I do use pivots that's why i'm 
    interested.
     
    TIA
     
    Herbert
    <BLOCKQUOTE 
    >
      ----- Original Message ----- 
      <DIV 
      >From: 
      Jason 
      Hart 
      To: <A 
      title=amibroker@xxxxxxxxxxxxxxx 
      href="">amibroker@xxxxxxxxxxxxxxx 
      
      Sent: Monday, January 26, 2004 3:57 
      PM
      Subject: RE: [amibroker] Pivots, 
      Pivots, Pivots........
      
      Mark,
       
      Try this - I can't remember where I found it but it may be what you 
      are looking for
       
      Jason
       
      
      /* **********************************
      Code to automatically identify pivots
      ********************************** */<FONT 
      size=1>
      // -- what will be our lookback range for the hh and 
      ll?
      nBars = Param<FONT 
      size=1>("Number of bars"<FONT 
      size=1>, 12, 
      5, <FONT 
      color=#ff00ff size=1>40);<FONT 
      color=#008000 size=1>
      // -- Title.
      Title = Name<FONT 
      size=1>() + " (" + 
      StrLeft(<FONT 
      color=#0000ff size=1>FullName(), <FONT 
      color=#ff00ff size=1>15) + <FONT color=#ff00ff 
      size=1>") O: " + Open + <FONT 
      color=#ff00ff size=1>", 
      H: " + High + "<FONT 
      size=1>, L: " + Low + 
      ", C: " + 
      Close;
      // -- Plot basic candle chart
      PlotOHLC(Open, High, Low, 
      Close, 
      "BIdx = " + 
      BarIndex() + 
      "\n" + 
      "O = " + O + 
      "\n"+<FONT 
      color=#ff00ff size=1>"H = "+ H + <FONT 
      color=#ff00ff size=1>"\n"+<FONT color=#ff00ff 
      size=1>"L = " + L 
      + "\n"<FONT 
      size=1>+"C ",
      colorBlack, styleCandle); 
      GraphXSpace=7<FONT 
      size=1>;
      // -- Create 0-initialized arrays the size of barcount<FONT 
      size=1>
      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<FONT 
size=1>;
      lastLPIdx = 0<FONT 
size=1>;
      lastHPH = 0;
      lastLPL = 0;
      curPivBarIdx = 0<FONT 
      size=1>;
      // -- looking back from the current bar, how many bars 
      // back were the hhv and llv values of the previous 
      // n bars, etc.?
      aHHVBars = HHVBars<FONT 
      size=1>(H, nBars);
      aLLVBars = LLVBars<FONT 
      size=1>(L, nBars);
      aHHV = HHV<FONT 
      size=1>(H, nBars);
      aLLV = LLV<FONT 
      size=1>(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<FONT 
      size=1>("barvisible"<FONT 
      size=1>);
      nLastVisBar = LastValue<FONT 
      size=1>(Highest<FONT 
      size=1>(IIf<FONT 
      size=1>(aVisBars, BarIndex<FONT 
      size=1>(), 0<FONT 
      size=1>)));
      _TRACE("Last 
      visible bar: " + nLastVisBar);<FONT 
      color=#008000 size=1>
      // -- Initialize value of curTrend
      curBar = (BarCount-<FONT color=#ff00ff 
      size=1>1);
      curTrend = ""<FONT 
      size=1>;
      if (aLLVBars[curBar] < 
      aHHVBars[curBar]) {
      curTrend = "D"<FONT 
      size=1>;
      }
      else {
      curTrend = "U"<FONT 
      size=1>;
      }
      // -- Loop through bars. Search for 
      // entirely array-based approach
      // in future version
      for (i=<FONT color=#ff00ff 
      size=1>0; i<<FONT color=#ff00ff 
      size=1>120; i++) {
      curBar = (BarCount - <FONT color=#ff00ff 
      size=1>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"<FONT 
      size=1>;
      // -- Capture pivot 
      information
      curPivBarIdx = curBar - aLLVBars[curBar];
      aLPivs[curPivBarIdx] = 1<FONT 
      size=1>;
      aLPivLows[nLPivs] = L[curPivBarIdx];
      aLPivIdxs[nLPivs] = curPivBarIdx;
      nLPivs++;
      }
      // -- or current trend is 
      up
      } else 
      {
      if 
      (curTrend == "D") 
      {
      curTrend = "U"<FONT 
      size=1>;
      curPivBarIdx = curBar - aHHVBars[curBar];
      aHPivs[curPivBarIdx] = 1<FONT 
      size=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<FONT 
      size=1>
      // -- Start at last bar
      curBar = (BarCount-<FONT color=#ff00ff 
      size=1>1);
      candIdx = 0;
      candPrc = 0;
      lastLPIdx = aLPivIdxs[0<FONT 
      size=1>];
      lastLPL = aLPivLows[0<FONT 
      size=1>];
      lastHPIdx = aHPivIdxs[0<FONT 
      size=1>];
      lastHPH = aHPivHighs[0<FONT 
      size=1>];
      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<FONT 
      size=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+<FONT color=#ff00ff 
      size=1>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<FONT 
      size=1>;
      // ...and then rearrange elements in 
      the 
      // pivot information 
      arrays
      for 
      (j=0; j<nLPivs; 
      j++) {
      aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+<FONT color=#ff00ff 
      size=1>1)];
      aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+<FONT color=#ff00ff 
      size=1>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<FONT 
      color=#0000ff size=1>
      PlotShapes(
      IIf(aHPivs==<FONT color=#ff00ff 
      size=1>1, shapeDownArrow, shapeNone), 
      colorRed, 0<FONT 
      size=1>,
      High, Offset=-15<FONT 
      size=1>);
      PlotShapes(
      IIf(aLPivs==<FONT color=#ff00ff 
      size=1>1, shapeUpArrow , shapeNone), 
      colorGreen, 0<FONT 
      size=1>, 
      Low, Offset=-15<FONT 
      size=1>);Graham 
      <gkavanagh@xxxxxxxxxxxxx> wrote:
      <BLOCKQUOTE class=replbq 
      >Yes, 
        I thought there was something in the AFL library (AB or yahoo 
        site),and also in past emails, check the email history for last 
        year.Cheers,Graham<A 
        href="">http://www.golala.com/forums/?mforum=asxsharetrading<A 
        href="">http://groups.msn.com/fmsaustralia 
        -----Original Message-----From: mleonsprint 
        [mailto:mleonsprint@xxxxxxxxx] Sent: Monday, 26 January 2004 1:26 
        PMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] Pivots, 
        Pivots, Pivots........Does anyone have any formula's for 
        plotting past pivots on the chart?  Or any idea's of doing 
        so?  I have been trying and comming up empty 
        handed.....Thanks for your helpMarkSend BUG 
        REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
        suggest@xxxxxxxxxxxxx-----------------------------------------Post 
        AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web 
        page: <A 
        href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
        group FAQ at:<A 
        href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        Yahoo! Groups LinksTo visit your group on the web, go 
        to:<A 
        href="">http://groups.yahoo.com/group/amibroker/To 
        unsubscribe from this group, send an email 
        to:amibroker-unsubscribe@xxxxxxxxxxxxxxxYour use of Yahoo! 
        Groups is subject to:  <A 
        href="">http://docs.yahoo.com/info/terms/ 
        Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
        SUGGESTIONS to 
        suggest@xxxxxxxxxxxxx-----------------------------------------Post 
        AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web 
        page: <A 
        href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
        group FAQ at: <A 
        href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        
        
        Yahoo! Groups Links
        
          To visit your group on the web, go to:<A 
          href="">http://groups.yahoo.com/group/amibroker/  

          To unsubscribe from this group, send an email to:<A 
          href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

          Your use of Yahoo! Groups is subject to the <A 
          href="">Yahoo! Terms of Service. 
          
      
      
      Do you Yahoo!?Yahoo! SiteBuilder - Free web site building tool. <A 
      href="">Try 
      it! Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
      SUGGESTIONS to 
      suggest@xxxxxxxxxxxxx-----------------------------------------Post 
      AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
      <A 
      href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
      group FAQ at: <A 
      href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
      
      
      Yahoo! Groups Links
      
        To visit your group on the web, go to:<A 
        href="">http://groups.yahoo.com/group/amibroker/  

        To unsubscribe from this group, send an email to:<A 
        href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

        Your use of Yahoo! Groups is subject to the <A 
        href="">Yahoo! Terms of Service. 
        Send BUG REPORTS to 
    bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    
    
    Yahoo! Groups Links
    
      To visit your group on the web, go to:<A 
      href="">http://groups.yahoo.com/group/amibroker/  

      To unsubscribe from this group, send an email to:<A 
      href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

      Your use of Yahoo! Groups is subject to the <A 
      href="">Yahoo! Terms of Service. 
    
  
  
  Do you Yahoo!?Yahoo! SiteBuilder - Free web site building tool. <A 
  href="">Try 
  it! Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
  SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  
  
  Yahoo! Groups Links
  
    To visit your group on the web, go to:<A 
    href="">http://groups.yahoo.com/group/amibroker/  

    To unsubscribe from this group, send an email to:<A 
    href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

    Your use of Yahoo! Groups is subject to the <A 
    href="">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








Yahoo! Groups Sponsor


  ADVERTISEMENT 









Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.