hi Bernard,

I have adjusted your idea a little. Also Amibroker came with some enhancements 
in the mean time.  Have a look.  Also for Bill (wavemechanic) who says this can 
be easily done with arrays only maybe he can give an example that works. I will 
think about an array solution later as well. 

Like you asked the trigger is when C is lower than some area defined by the 
Bbands. Then if within a wiat period the price breaks through a certain defined 
thershold it will buy. Else it will do nothing as illustrated in the chart.

About your questions. Best have a look at the adjusted code and see if you 
understand this better. If you have other intersting ideas let me know and I 
will try to code it.

rgds, Ed




  ----- Original Message ----- 
  From: bernardedmond01 
  To: [email protected] 
  Sent: Friday, June 15, 2007 5:51 AM
  Subject: [amibroker] Looping - our previous discussion


  Ed
  You assisted me with the following code (your code) on March 23rd. 
  The background to our discussion was that I wanted to understand how 
  to hold for a number of periods.
  I wondered if I could ask you a couple of questions on your code (at 
  end):

  SetBarsRequired(10000,10000); 

  triggerPercentage = 1.03; 
  waitPeriod = 15; 

  Setup = C < BBandBot(C,20,2); 

  for (i = 0; i < BarCount - waitPeriod; i++) { 

  if (Setup[ i ]) { 

  for (j = i + 1; j < i + waitPeriod; j++) { 

  Setup[ j ] = 0; 

  } 

  i = j; 

  } 

  } 

  1. Is it correct to refer to the j loop as being "nested" in the i 
  loop? I'm wondering whether the j loop completes its internal loop 
  for the 15 or so bars and then re-enters the i loop at the end or 
  whether both i and j loops run the 15 or so times?

  2. "i<BarCount-waitperiod" - can you explain how the code translates 
  that please? I thought that would have meant you terminate once the 
  current bar is less than the total number of bars less 15, whereas 
  it seems to me an you terminate at 15.

  3. You mentioned when we previously discussed this issue that Setup 
  has a "1" wherever C < BBandBot. Is that why in other codes, 
  sometimes the values of an array are set to 0 before a loop (to 
  remove any previous arrays triggered)?

  Thanks for your assistance,
  Bernard



   

Attachment: bernard3.afl
Description: Binary data

<<attachment: bern.png>>

Reply via email to