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

Re: [amibroker] Only buy the first time the condition is true


  • Date: Fri, 05 Mar 2010 11:04:14 -0500
  • From: Keith McCombs <kmccombs@xxxxxxxxxxxx>
  • Subject: Re: [amibroker] Only buy the first time the condition is true

PureBytes Links

Trading Reference Links



Robert --

Buy = Sell = enable = intrade = 0;
MA_Short = MA(C,20)
MA_Med = MA(C,100)
MA_long = MA(C,200);
intrade = flip(buy, sell);
ready = flip(Cross(MA_Med, MA_Long) AND !intrade, Buy);
buy = ready AND Cross(MA_Short, MA_Med);
Sell = Cross(MA_Med, MA_Short);

-- Keith


On 3/5/2010 04:50, ics4mer wrote:
 

Hi,

Looking for some help with following situation.

Say we have 3 moving averages:

MA_Short = MA(C,20)
MA_Med = MA(C,100)
MA_long = MA(C,200);

My signals are the following

Buy = MA_Med > MA_Long AND Cross(MA_Short, MA_Med);
Sell = Cross(MA_Med, MA_Short);

However, I only want to trade the first occurence of cross(MA_short,MA_Med).

I don't want to take another long trade until MA_Med has dipped below MA_Long and risen above MA_Long again and the Cross(short, med) situation occurs again.

I suspect it has something to do with the flip() function but I can't quite sus it out!

I've nearly worked it out with a loop, but I'm sure that it's not the correct way to use AFL.

Any help greatly appreciated!

TIA

Robert



__._,_.___


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

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

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___