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

[amibroker] Re: playing with exits



PureBytes Links

Trading Reference Links

Yuki,

> P> Buy = Sell = Short = Cover = False; // Initialize Arrays
> 
> Where would I put the line above?  I already have a system in place
> that exits on the next day.  Would that statement go after the
normal buy statement?

You can put it at top of script or remove it. I use it to keep from
having to remember to select Long, Short or Both in settings. It
serves no other purpose in this example.

> P> // overide default settings
> P> SetTradeDelays(0,0,0,0);
> 
> I use this line above already.

Good.
 
> P> // make a simple trading system
> P> Buy = Cross(RSI(),30);
> 
> This is easy enough, just substitute my own buy rules here.  But I
> need to include the short side as well, and I have rules for that
> too, of course.
> 

Once you completely understand the logic of the long side, then you
should be able to spply the same logic to the short side. The key is
in understanding.

> P> // buy the next day at the open
> P> // use Ref(Buy -1) because the Ref function returns a value
> P> // so the "1" numbers inside the Buy array are moved forward this
way.
> P> Buy = Ref(Buy, -1);
> 
> Okay . . . I think I have become terribly confused here, which is
> normal for me when trying to figure out code.  ^_-
> 
> If I buy 'next day at the open', that is not my system then, is it?
> My system buys or shorts intraday, depending on price reaching a
> 'BStopLevel' or a 'SStopLevel'.  Then buyprice = BStopLevel and
> shortprice = SStopLevel.  Doesn't the code in the graph directly
> below foul up my own code?

Remove code referenced in this section. Then you have no trade delays.

> P> // define the BuyPrice
> P> BuyPrice = ValueWhen( Buy, Open);
> P> Sell = BarsSince(Buy) == 1;
> 
> P> SellPrice = IIf(Open >= BuyPrice,Open,C);
> 
> Okay . . . *this* line just above looks right to me.  It's an exit
> that exits on the open if the open is > buyprice.  I can write the
> opposite for the short I'm sure, using coverprice.

Sounds like the *light bulb* just went on and that you understand the
concept. Just let your system establish its' own BuyPrice and
ShortPrice, then *force* the desired SellPrice or CoverPrice using an
appropriate IIF statement.

> 
> P> Buy = ExRem(Buy,Sell);
> P> Sell = ExRem(Sell,Buy);
> 
> P> Filter = 1;
> P> AddColumn(BarsSince(Buy),"BarsSince(Buy)",1.0);
> P> //-----------------------------------------
> 
> P> Regards,
> 
> P> Phsst
> 
> I take it you would set this up as an exploration?  That never
> occurred to me, and I had wanted to set it up as a system, so I could
> get some profitability feedback on it.

Yes, an exploration... the purpose of which was for debugging the afl
script. Either delete it or enhance it to display pertinant info about
your trade setups / executions for debugging purposes.

> I wish I wish I wish I was better at this.

I believe you picked up on the relevent portions of the sample code
that will meet your needs. You did not convey all of your requirements
in your original request, so the sample was generic.

You are obviously an active, profitable discretionary trader, so any
weakness with AFL coding is not the end of the world... just a little
aggrevation.

I have not looked at William Peters Powertool since his first beta,
but I wonder if you might benefit from using it. If you haven't done
so yet, take a look at it.

Regards,

Phsst


------------------------ 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/