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

[amibroker] Re: How to "Enter Long" at Open on Next Day



PureBytes Links

Trading Reference Links

You should be able to code your script as though everything were going 
to happen on the same day as the signal, then just use SetTradeDelays 
to defer it 'till the next day.

Try something like this (untested):

SetTradeDelays(1, 1, 1, 1);

MA20 = MA(Close, 20);
MA80 = MA(Close, 80);
MA150 = MA(Close, 150);

Buy = (Close > MA20) && (MA20 > MA80) && (MA20 > MA150);
BuyPrice = Open;

Sell = ...
SellPrice = Open;

P.S. For better performance, only calculate the MA's once.

Mike


--- In amibroker@xxxxxxxxxxxxxxx, "electricwally77" <soundmaker@xxx> 
wrote:
>
> I appreciate any code help if possible.
> 
> I've been at my code for hours and can't figure out what I did 
wrong.
> 
> I'm trying to tell my system to Enter Long on the Next Trading Day 
(at
> the open price) only if the "Buy" rules are True the trading day 
before.
> 
> Likewise, I'm trying to tell my system to Exit Long on the Next
> Trading Day (at the open price) only if the "Sell" rules are True 
the
> trading day before.
> 
> In other words, If my system tells me to buy or sell on a particular
> day, I only want to execute the trade at the open on the next 
trading
> day (not the same day the system identifies a trade).
> 
> Here is my code below:
> 
> Cond1 = Ref(Close,-1); BuyPrice = Open;
> Cond2 = Close > MA( Close, 20 );
> Cond3 = MA(  Close , 20 ) > MA(  Close , 80 ); 
> Cond4 = MA(  Close , 20 ) > MA(  Close , 150 ); 
> Buy = Cond1 AND Cond2 AND Cond3 AND Cond4; 
> 
> Cond4 = Ref(Close,-1); SellPrice = Open;
> Cond5 = Close < MA( Close, 20 );
> Cond6 = MA(  Close , 20 ) < MA(  Close , 80 ); 
> Cond7 = MA(  Close , 20 ) < MA(  Close , 150 );
> Sell = Cond4 AND Cond5 AND Cond6 AND Cond7;
> 
> Thanks you members.
>


------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/