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

Re: Is it possible to create such a buy signal ?



PureBytes Links

Trading Reference Links

--- In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:
> Hello,
> 
> > - A buy occured with the above conditions of course
> > - Sell at buy price (open*1.02) + 0.5%
> > - or Sell at buy price (open*1.02) -0.5 %
> > - If a sell signal couldn't be generated today (because price 
didn't 
> > go up or down 0.5% from the buy price) then sell at close.
> > 
> > Again, all of this should happen the same day it was bought.
> 
> This one is fairly easy, add the following lines to your formula 
(after buy setup):
> 
> sell = buy; // this ensures that sell is performed at the same bar 
as buy
> 
> sell1cond = high > buyprice * 1.005; // +0.5% from buyprice
> sell2cond = low < buyprice * 0.9995; // -0.5% from buyprice
> 
> // the line below chooses appropriate sellprice depending on 
conditions met
> sellprice = IIF( sell1cond, buyprice * 1.005, IIF( sell2cond, 
buyprice * 0.9995, close ) );
> 
> One caveat is that if both conditions sell1cond and sell2cond are 
met
> the code chooses sell1cond (this simulates that prices first go up 
and
> the sell limit is activated). As we don't know intra-day behaviour 
this
> may be right or wrong.


Hey thank you very much.
Now the system behaves really corectly in generating the buys / sells.
I'm really glad I can perform a kind of intraday back test on my 173 
stocks portofolio in a matter of seconds :)

The only little glitch I noticed is that when it sells on a profit, 
it correctly report a +0.5% profit, but when it sells on a losse, it 
systematically reports a -0.1% instead of -0.50%.

Any clue why ?

Thanks,
Lemanioc