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

Re: [amibroker] Help with buy formula



PureBytes Links

Trading Reference Links

Graham,
What I am trying to do is to buy when condition1 is met and the Stocashtic K is going up from lower than 25 in the last X days. I am using 5 days now. 
I eliminated the condition1 and tried this code, but it still didn't signal a buy on 3/14. I have the chart at http://www.ethingamajigs.com/Chart.jpg

//Buy Signals

Condition1 = C > Dropline AND Ref(C,-1) < Ref(Dropline,-1);

Cond1=StochK() > Ref(StochK(),-1);

Cond2=MACD() > Ref(MACD(),-1);

Cond6=StochD()<25; 

Cond7=BarsSince(Cond6) <=7;



//Sell Signals

Condition10 = C < Increase AND Ref(C,-1) > Ref(Increase,-1);

Cond11=StochK() < Ref(StochK(),-1);

Cond12=MACD() < Ref(MACD(),-1);

Cond16=StochD()>75; 

Cond17=BarsSince(Cond16) <=7;

//Buy and Sell orders

Buy = Cond1 AND Cond7;

Sell = cond11 AND Cond17;

//Short and Cover conditions

Short = Sell;

Cover = Buy;

Thanks,

Tom

  ----- Original Message ----- 
  From: Graham 
  To: amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, December 11, 2006 5:04 PM
  Subject: Re: [amibroker] Help with buy formula


  This is an incorrect expression which could be open to misinterpretation 
  Cond1=StochK() - Ref(StochK(),-1) >1; 
  What it is saying is 
  StochK() - (Ref(StochK(),-1) >1) which breaks down to either StochK() - 1 or StochK() -0
  If StochK()==1 then it would return false, otherwise true
  Try this, although I do not quite understand the logic of this condition
  Cond1= ( StochK() - Ref(StochK(),-1) ) >1; which means current bar StochK is more than 1 unit above previous value
  Are you wanting the StochK to be rising?
  Cond1= StochK() > Ref(StochK(),-1);

  -- 
  Cheers
  Graham
  AB-Write >< Professional AFL Writing Service
  Yes, I write AFL code to your requirements 
  http://www.aflwriting.com 




  On 12/12/06, M. Smith <ink@xxxxxxxxx> wrote:
    Dave, would you write that out, I have tried and it still gives me an error, but  the error now is related to my change.  Please. Thanks. Masrhall
      ----- Original Message ----- 
      From: Dave 
      To: amibroker@xxxxxxxxxxxxxxx 
      Sent: Monday, December 11, 2006 6:30 AM
      Subject: RE: [amibroker] Help with buy formula



      Place your increase statement above your condition statements.



      -----Original Message-----
      From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of M. Smith
      Sent: Monday, 11 December 2006 1:46 PM
      To: amibroker@xxxxxxxxxxxxxxx
      Subject: Re: [amibroker] Help with buy formula



      I loaded this formula and it gave me an error message.  "condition 10=c<increase AND Ref(c,-1)>ref increase. Message was variable 'increase' used without having been initialized.  Can you help me out, Please.   Marshall

        ----- Original Message ----- 

        From: professor77747 

        To: amibroker@xxxxxxxxxxxxxxx 

        Sent: Sunday, December 10, 2006 3:23 PM

        Subject: [amibroker] Help with buy formula



        When I backtest my formula, all the buys and sells are shown 
        correctly except one. I cannot figure out what is wrong. Here is the 
        buy and sell code: 
        //Buy Signals 

        Condition1 = C > Dropline AND Ref(C,-1) < Ref(Dropline,-1); 
        Cond1=StochK() - Ref(StochK(),-1) >1; 
        Cond2=MACD() > Ref(MACD(),-1); 
        Cond6=StochD()<25; 
        Cond7=BarsSince(Cond6) <=7; 

        //Sell Signals 

        Condition10 = C < Increase AND Ref(C,-1) > Ref(Increase,-1); 
        Cond11=StochK() - Ref(StochK(),-1) < 1; 
        Cond12=MACD() < Ref(MACD(),-1); 
        Cond16=StochD()>75; 
        Cond17=BarsSince(Cond16) <=7; 

        //Buy and Sell orders 

        Buy = BarsSince(Condition1) <=5 AND Cond1 AND Cond7; 
        Sell = BarsSince(Condition10) <=5 AND cond11 AND Cond17; 

        //Short and Cover conditions 

        Short = Sell; 
        Cover=buy; 

        Graham wrote the code for the Condition1 and Condition10. It plots an 
        arrow on the graph so I know that it works. I have checked the 
        stochastic and macd for the buy in question and these are the 
        figures: 

        3/10 Stok = 20.06 
        3/13 Stok = 26.42 
        3/14 Stok = 34.98 

        3/13 Macd = -1.74 
        3/14 Macd = -1.54 
        3/14 Green up arrow 

        The formula should have covered my short and placed a buy. 

        It held my short and did not place a buy. 

        Everything else is perfect except that one day. I have backtested 
        from 9/2/05 and have 12 trades. 

        Thanks, 
        Tom




--------------------------------------------------------------------------
      I am using the free version of SPAMfighter for private users.
      It has removed 570 spam emails to date.
      Paying users do not have this message in their emails.
      Try SPAMfighter for free now!








   
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.16/582 - Release Date: 12/11/2006 4:32 PM