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

[amibroker] Re: help with trading system



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "ed2000nl" <pablito@xxxx> wrote:
> thanks Steve,
> 
> but I basicly understand what ValueWhen() does. In principle 
ValueWhen
> (Buy, Open) is the same as Open, or it returns the values of the 
Open 
> array at the positions where the Buy array is true.

Ed,
It is not exactly this.
The function
X=ValueWhen(Buy,Open);
is equal to the Open price on the"Buy" day but it holds the same 
price till the next Buy occurs [may be months later !!]
You will always find helpful the respective graph.

Buy=Cross(RSI(),35);PlotShapes(shapeUpArrow*Buy,colorGreen);
Sell=Cross(RSI(),60);PlotShapes(shapeDownArrow*Sell,colorRed);
Plot(C,"",1,64);
X=ValueWhen(Buy,Open);
Plot(X,"",colorWhite,1);

The white line is the ValueWhen(Buy,Open) : It is equal to the 
last "Buy"day Open, until the next Buy appears. 
Example:INTC was Buy on Jan2,2003. The OpenPrice for that day was 16.
X was equal to 16 for the next day and for ther next 6 months, 
because no new Buy appeared.
Valuewhen is a type of "memory", it keeps the value of the event, 
until the new event appears.
ValueWhen(COND,ARRAY) is identical to AMA(ARRAY,COND) and, IMO, it is 
very useful AFL function.
Dimitris Tsokakis


> 
> The point I did not understand is with the delay. Apparently the 
Buy 
> array remains unchanged if I set the buydelay to 1. I would have 
> thought that the positions of the "1" numbers inside the buy array 
> would shift 1 position to the right.
> 
> If this were so then I could have used ValueWhen(Buy,Open) even 
> though I set the buydelay to 1.
> 
> I must admit that I do not understand the definition of ValueWhen 
in 
> the help files with respect to the third parameter n: "n-th most 
> recent occurence". So I wonder if I still could use ValueWhen as I 
> did originally if I put some value there for n .....
> 
> I have a bit of a hard time learning AFL. I have to find out how I 
> can work with it interactively in order to find out what I am doing 
> every step op the way.
> 
> regards, Ed 
>   
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxxx> 
wrote:
> > Hi Ed,
> > 
> > You can look at Valuewhen() like this:
> > Variable = valuewhen( A, B );
> > is the same as saying
> > Variable = the VALUE of B WHEN A occurs;
> > 
> > So...
> > 
> > BuyPrice = ValueWhen(Buy, Open);
> > is the same as saying
> > BuyPrice = the VALUE of open WHEN a signal occurs in the "Buy" 
> array (i.e. - no delay).
> > 
> > Steve
> > 
> > 
> > ----- Original Message ----- 
> >   From: ed2000nl 
> >   To: amibroker@xxxxxxxxxxxxxxx 
> >   Sent: Monday, September 29, 2003 5:35 PM
> >   Subject: [amibroker] Re: help with trading system
> > 
> > 
> >   OK thanks. I see I have a lot more studying and playing ahead 
of 
> me. 
> >   I'm not sure if I understand the bit about ValueWhen() 
completely 
> but 
> >   for now I will not use it if I also use SetTradeDelays(). 
> > 
> >   thanks and
> >   regards, Ed
> > 
> > 
> >   --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> <amibroker@xxxx> 
> >   wrote:
> >   > Hello,
> >   > 
> >   > > thanks. I found the proper buy and sell signals. Still I am 
> >   > > puzzled ... my super simple code does not give proper 
> results. If 
> >   I 
> >   > > execute this code on CTMI I get 3 trades. However, it not 
> always 
> >   buys 
> >   > > at the open like I tell it to. Do you agree when looking at 
> the 
> >   code 
> >   > > below that it *always* should buy at the open?
> >   > 
> >   > No. To buy always at open you should write:
> >   > 
> >   > BuyPrice = Open;
> >   > 
> >   > (isn't this obvious ?)
> >   > 
> >   > If you write
> >   > 
> >   > BuyPrice = ValueWhen(Buy, Open);
> >   > 
> >   > and you SET DELAY > 0
> >   > this code actually attempts to buy at OPEN price WHEN NON 
> DELAYED 
> >   buy
> >   > occurred. Since trading is delayed as per your setting the 
open 
> of
> >   > N-days before may NOT fit into High-LOW range of the bar when
> >   > ACTUAL TRADE takes place so AmiBroker must readjust it to
> >   > fit into H-L range (what ever is nearer your desired price).
> >   > 
> >   > 
> >   > Hope this helps.
> >   > 
> >   > Best regards,
> >   > Tomasz Janeczko
> >   > amibroker.com
> >   > ----- Original Message ----- 
> >   > From: "ed2000nl" <pablito@xxxx>
> >   > To: <amibroker@xxxxxxxxxxxxxxx>
> >   > Sent: Monday, September 29, 2003 10:47 PM
> >   > Subject: [amibroker] Re: help with trading system
> >   > 
> >   > 
> >   > > Jayson,
> >   > > 
> >   > 
> >   > > How can this be explained?
> >   > > 
> >   > > regards, Ed
> >   > > 
> >   > > //----------------------------------------------------
> >   > > // overide default settings, set buy delay at 1 bar
> >   > > SetTradeDelays(1,0,0,0);
> >   > > 
> >   > > // make a simple trading system
> >   > > Buy = Cross(RSI(),30);
> >   > > 
> >   > > // define the BuyPrice
> >   > > BuyPrice = ValueWhen( Buy, Open);
> >   > > 
> >   > > // define the sell condition
> >   > > SellCond1 = C > BuyPrice * 1.02; 
> >   > > SellCond2 = C < BuyPrice * 0.96; 
> >   > > SellCond3 = Cross( BarsSince(Buy), 5 ); 
> >   > > 
> >   > > Sell = SellCond1 OR SellCond2 OR SellCond3;
> >   > > 
> >   > > // define the SellPrice
> >   > > SellPrice = ValueWhen( Sell, Close);
> >   > > 
> >   > > Buy = ExRem(Buy,Sell);
> >   > > Sell = ExRem(Sell,Buy);
> >   > > //----------------------------------------------------
> >   > > 
> >   > > 
> >   > > backtest:
> >   > > 
> >   > > CTMI Long 7/25/2002 15.7500 7/25/2002 16.5900 5.3%
> >   > > 533.33 5.3% 634.921 10000 533.333 1 5.33%
> >   > > CTMI Out 7/25/2002 16.5900 3/14/2003 17.8190 7.4%
> >   > > 0.00 0.0% 0 0 533.333 160 0.00%
> >   > > CTMI Long 3/14/2003 17.8190 3/14/2003 18.5100 3.9%
> >   > > 408.47 3.9% 591.129 10533.3 941.804 1 3.88%
> >   > > CTMI Out 3/14/2003 18.5100 8/22/2003 13.1000 -29.2%
> >   > > 0.00 0.0% 0 0 941.804 112 0.00%
> >   > > CTMI Long 8/22/2003 13.1000 8/26/2003 13.5800 3.7%
> >   > > 400.92 3.7% 835.252 10941.8 1342.72 3 1.22%
> >   > > CTMI Out 8/26/2003 13.5800 9/26/2003 14.0000 3.1%
> >   > > 0.00 0.0% 0 0 1342.72 22 0.00%
> >   > > 
> >   > > 
> >   > > 
> >   > > 
> >   > > 
> >   > > --- In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx> 
> wrote:
> >   > > > Are you simply double clicking the trade to plot the 
arrows 
> or 
> >   have 
> >   > > you
> >   > > > right clicked then chosen "Show actual trades"??
> >   > > > 
> >   > > > Try this...  create a new indicator with this code.....
> >   > > > 
> >   > > > 
> >   > > > x = Cross(RSI(),30);
> >   > > > Plot(RSI(),"",5,1);
> >   > > > PlotGrid(30,colorWhite);
> >   > > > Plot(x,"",4,2|styleOwnScale);
> >   > > > 
> >   > > > The red lines will show the actual cross. Now run this 
> simple 
> >   > > system test...
> >   > > > 
> >   > > > 
> >   > > > SetTradeDelays(3,0,0,0);
> >   > > > Buy= Cross(RSI(),30);
> >   > > > Sell=Cross(30,RSI());
> >   > > > 
> >   > > > Test over enough days to be sure you get a signal. Next 
rt 
> >   click a 
> >   > > trade and
> >   > > > choose "Show actual trade". I believe you will see the 
> arrow to 
> >   be 
> >   > > 3 days
> >   > > > after the red line cross..
> >   > > > 
> >   > > > 
> >   > > > 
> >   > > > 
> >   > > > 
> >   > > > Regards,
> >   > > > Jayson
> >   > > is subject to the Yahoo! Terms of Service.
> >   > > 
> >   > > 
> >   > > 
> >   > > Send BUG REPORTS to bugs@xxxx
> >   > > Send SUGGESTIONS to suggest@xxxx
> >   > > -----------------------------------------
> >   > > 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/ 
> >   > > 
> >   > > 
> >   > >
> > 
> > 
> >         Yahoo! Groups Sponsor 
> >               ADVERTISEMENT
> >              
> >        
> >        
> > 
> >   Send BUG REPORTS to bugs@xxxx
> >   Send SUGGESTIONS to suggest@xxxx
> >   -----------------------------------------
> >   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/mOAaAA/3exGAA/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/