Mike - Okay, got it. I missed the obvious. Thanks for helping me learn programming. Also, your code worked fine. Thanks.
--- In [email protected], "Mike" <[EMAIL PROTECTED]> wrote: > > Wally, > > The "..." simply meant "write your own sell code here!". It is not > part of the AmiBroker syntax. Taking your original example, the > actual code becomes: > > 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 = (Close < MA20) && (MA20 < MA80) && (MA20 < MA150); > SellPrice = Open; > > Note that the above example answers your follow up question to > Tomasz. Yes, you can write code to override the AA window settings; > Use SetTradeDelays. > > For an explanation of any of the functions used, refer to the Help > menu in AmiBroker, or on-line at: > http://www.amibroker.com/guide/afl/afl_index.php?m=1 > > Keep in mind that you will still need to add money management logic > to the code and/or in your preferences settings (e.g. max positions, > position size, margin usage, long only vs. short only vs. long and > short, etc). > > Mike > > > > > 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; > > --- In [email protected], "electricwally77" <soundmaker@> > wrote: > > > > Mike, Thank you for helping. I received a syntax error on Line 8 of > > your code (Sell = ...). I tried placing a semi-colen (;) at the end > > but to no avail. I'm not sure how to correct this. > > > > Your code below....... > > > > > > 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; > > > > > > > > --- In [email protected], "Mike" <sfclimbers@> wrote: > > > > > > 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 [email protected], "electricwally77" <soundmaker@> > > > 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. > > > > > > > > > >
