logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
finquant  
#1 Posted : Saturday, November 26, 2005 7:55:07 AM(UTC)
finquant

Rank: Member

Groups: Registered, Registered Users
Joined: 11/12/2005(UTC)
Posts: 18

Hi! Can I buy the signal day's close? I am testing this simple breakout-system and at the moment the system buys the day after the breakout. In real live I could be watching this live and buy it at the close. Is this possible to do? I also want to test time stops with this. How do I close after 1,2,...,N days. There were discussions about this earlier but I didn't quite understand it :)
CraigWB  
#2 Posted : Saturday, November 26, 2005 6:16:46 PM(UTC)
CraigWB

Rank: Member

Groups: Registered, Registered Users
Joined: 11/24/2005(UTC)
Posts: 17
Location: Chagrin Falls, Ohio USA

For buying at the close, I think what you want to do looks like this: In V8 or V9, open your Enhanced System Tester, press the New Simulation button, open the Trade Execution panel by pressing the "More..." button on the System Testing Options panel and select Buys/Sells at Close. If you select Market Order Type pricing within your system Buy Order , then the signal will generate a buy at close. For timed exits, there are several ways. One of the most efficient (computationally) is to test your entry signal in the following way for a 20-day long breakout with a 10 day exit: Sell Order Panel [color=blue:094114e805]BuySig:= Cross(C, Ref(HHV(C,19),-1)); DaysIn:= BarsSince(BuySig); ExitDays:= 10; ExitQ:= DaysIn = ExitDays; ExitQ[/color] Note that [color=blue:094114e805]DaysIn:= 0[/color] is the signal day. You can also use the Simulation.CurrentPositionAge global variable instead of BarsSince(), but it is EXTREMELY slow. Hope that helps. Craig
henry1224  
#3 Posted : Saturday, November 26, 2005 6:33:44 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Simulations functions are only used in the system tester! the system tester only tests your ideas to see if they are tradeable! It does not provide you with tradeable signals! you get your signals and alerts from the expert advisor! Explorations find stocks that have a signal or trading opportunity, once you open the chart, attach an expert, you can then determine if it's the right stock or not
CraigWB  
#4 Posted : Saturday, November 26, 2005 7:25:29 PM(UTC)
CraigWB

Rank: Member

Groups: Registered, Registered Users
Joined: 11/24/2005(UTC)
Posts: 17
Location: Chagrin Falls, Ohio USA

OK, it wasn't clear to me that was the question posed. Nonethleless, do you really want to use the Expert Advisor to mechanize trades on single trading systems?? I have to admit that I use MS primarily to backtest ideas and system concepts. Since I have multiple systems scanning my universe of stocks, the Expert Advisor wouldn't work (for me) anyway. My entries are computed (the night) before, and I then check for reasonableness. If the charts & entries, etc are acceptable then I place the entry stop(s). That way I have (reasonably) complete control over the execution, and wouldn't be scrambling 5-10 minutes before the close to make the entry. So, sorry for the confusion... Craig
finquant  
#5 Posted : Monday, November 28, 2005 6:23:05 AM(UTC)
finquant

Rank: Member

Groups: Registered, Registered Users
Joined: 11/12/2005(UTC)
Posts: 18

Thanks Craig! This was just what I wanted and it worked! :D One more thing: I have used position sizing 100 % but then my system ignores some signals. What I mean is that I can see them with my eyes that they are there but the system don't give signals. IF I change the position sizing to, for example, 50 % then it works again. What % should I use??? Btw, when I was using the 100 % position size and the system missed signals I was out at the moment. What I mean is that I had a buy signal and then a sell signal. Then when the next buy signal came, my system did not buy that?!
CraigWB  
#6 Posted : Tuesday, November 29, 2005 12:45:58 AM(UTC)
CraigWB

Rank: Member

Groups: Registered, Registered Users
Joined: 11/24/2005(UTC)
Posts: 17
Location: Chagrin Falls, Ohio USA

You're welcome, finquant. Glad the code snippet worked. I don't think I can help you with your signal conflicts, though to me it sounds like you're getting an exit and buy/sell signals on the same day. If that happens, then I think the exit takes precedence in MS. This would argue for latching long entries/exits and short entries/exits together so that wouldn't happen, but that is a feature that is currently missing in MS. As for position sizing, etc, with some help from others in the forum, I was able to sort thru some of the quirks of MS. Here's a working code for a simple moving average system, complete with price pyramiding a la' the Turtles (i.e., 1/2 ATR(20) steps) and an ATR-based dynamic position sizing using 1% risk increments. This code takes into account that a straight-EOD system should emphasize buying at the close. These rules can be relaxed, of course, to enable entries to trigger during the day (just remove the [color=blue:5e5e623eb3]If[/color] statement with [color=blue:5e5e623eb3]PyramidPrice[/color]), but I digress... So, finally, here's the promised sample code...you'll want to replace the entry buy signal with your own signal(s). Buy Order [color=blue:5e5e623eb3]{* Long Entry *} BuyMAF:= Mov(C,OPT1,E); BuyQ:= C > Ref(BuyMAF,-1); BuyQ[/color] Stop Price [color=blue:5e5e623eb3]{* Long Entry *} BuyMAF:= Mov(C,OPT1,E); BuyQ:= Cross(C,Ref(BuyMAF,-1)); {* Obtains original entry price *} {* Pyramid into position *} BuyEntry:= ValueWhen(1,BuyQ,C); ATRF:= Mov(ATR(1),20,E); ATREntry:= ValueWhen(1,BuyQ,ATRF); PyramidPrice:= BuyEntry + 0.5*(Simulation.PositionCount-1)*ATREntry; If(C>PyramidPrice,C-0.01,1000000)[/color] Entry Size: % of Available Equity [color=blue:5e5e623eb3]SimAC:= Simulation.AccountCash; TotalEquity:= SimAC + Simulation.AccountBorrowed + Simulation.PortfolioValue + Simulation.AccountReserved; NumShares:=(0.01*TotalEquity)/Mov(ATR(1),20,E); TotalBuy:= C*NumShares; (Min(TotalBuy,SimAC)/SimAC)-0.001 {* End of Code Snippet *}[/color] This should give you an idea of how to do both pyramiding and dynamic position sizing. The Turtles' pyramiding required one to use the ATR and the price of the original entry and then jump in increments of 1/2 ATR(20). This code tries to maintain that flavor. Note also a particular quirk of MS: When you specify % of Available Equity and use a function, it means decimal fraction--the range from 0 to 1, not 0 to 100. Oh, and another thing---this code is REALLY SLOW because of the need to access the simulation global variables. Unfortunately, you can't get around this one if you want your sizing to change with your system test. Hope this helps. Craig
finquant  
#7 Posted : Tuesday, November 29, 2005 12:36:29 PM(UTC)
finquant

Rank: Member

Groups: Registered, Registered Users
Joined: 11/12/2005(UTC)
Posts: 18

Nice work! Craig rulez! =D>
Biff Malibu  
#8 Posted : Thursday, January 5, 2006 1:25:56 AM(UTC)
Biff Malibu

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 33

Is what you posted up above what I would also use to generate a sell signal 10 days after the buy signal is generated? I'm working on a system but I don't even know if the buy signals are any good, and I have criteria set forth, let's say a cross above the 50 day sma on double average volume over 50 days and then I simply want to sell this sucker 10 days later. How would I code that?? thank you very much, I really appreciate this forum.. I took turbo pascal but got a C in it, programming is not my suit!
Jose  
#9 Posted : Thursday, January 5, 2006 5:51:40 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
You'll need to work some more on your entry, but here is a timed-based exit indicator: [code:1:dae3c58327] { Long entry-related timed exit } { ©Copyright 2004~2006 Jose Silva For personal use only. http://www.metastocktools.com } { User inputs } exitPds:=Input("Exit trade at x periods", 1,2600,10); delay:=Input("Entry and Exit delay",0,5,0); plot:=Input("signals: [1]Entry + Exit, [2]All entries",1,2,1); { Sample entry conditions } In:=Cross(C,Mov(C,50,S)) AND V>Mov(V,50,S)*2; { Entry-related exit latch } latch:=If(PREV>0, If(BarsSince(PREV<=0)<exitPds,1,-1),In); { Clean Entry & Exit signals } entry:=latch=1 AND Alert(latch<1,2); exit:=latch=-1; { Select Clean signals or All entries } signals:=If(plot=1,entry-exit,In); { Plot signals in own window } 0;Ref(signals,-delay) [/code:1:dae3c58327] jose '-)
Biff Malibu  
#10 Posted : Thursday, January 12, 2006 5:23:15 AM(UTC)
Biff Malibu

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 33

It would have taken me years to come up with that on my own! thanks again! Biff
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.