Buy Stop Limit Orders in Community.Components
Author: sedelstein
Creation Date: 2/26/2012 2:54 PM
profile picture

sedelstein

#1
I am looking at Buy Stop Limit Orders here

http://www2.wealth-lab.com/WL5Wiki/StopLimitOrders.ashx

CODE:
Please log in to see this code.


The way I understood stop limit orders is that there is a price (the stop price) where a limit order is triggered where the limit price may be different than the stop price.

The calls to these functions require only 1 price. Am I missing something or are there other functions out there that handle these types of orders?

profile picture

Eugene

#2
The limit price here is identical to the stop price (actually, greater or equal for Buy/Cover and less or equal for Sell/Short).

We encourage you to take a look at the code which is open source. Feel free to modify and share your code with the community.
profile picture

sedelstein

#3
Well, it certainly compiled and ran but the issue for me now is that I want the stop/limit order to execute on bar+1 and this code won't generate an alert me. Suggestions?

CODE:
Please log in to see this code.

profile picture

sedelstein

#4
Well, it all may be pointless as when I went to the Orders portion of WL6.2 and tried to find a stop/limit order, it wasn't there.
profile picture

Cone

#5
It seems to make sense to allow placement of a stop/limit order, but without the Position status feedback into the script, there would be no way to keep the script in synch with a real-life occurrence of an event in which the live trade did not execute. It's not likely we'll ever see a stop/limit order for system trading.
profile picture

Pablo123

#6
I'm looking to produce code that executes an intraday buystop ( say 1 minute time frame) after a limit is reached, i.e., after a stock declines 7% from its previous daily closing price, I want to wait for the stock to rise to its 6% daily closing price before buying the stock. Of course I would like to vary/optimze the parameters later.

Possible with Wealth-Lab? Appreciate any feedback.
profile picture

Eugene

#7
Try this on intraday data:
CODE:
Please log in to see this code.
profile picture

Pablo123

#8
Eugene,

This is nothing short of awesome! Thanks. I just ran it on NASDAQ stocks over 2 weeks using a 5 minute interval. It took a while to run mainly to collect data, but it worked exactly how I need.

Question: Is the data that is collected for back testing done every time. In other words,if I run the script over the same time frame and same 2 weeks, would the program re-collect the same data or is the data stored locally by the program ?

Pablo
profile picture

Eugene

#9
Of course Wealth-Lab stores the data on the hard drive. To speed up backtests, I recommend you turn off on-demand data updates in the Data Manager, and then update your data sources manually with "Update DataSet" / "Update All Data" or automatically on schedule.
profile picture

Pablo123

#10
Eugene,

I'm trying to add selection criteria to this buy stop code that you provided in post #7. Instead of just applying the intraday buy stop to all stocks, I want to apply it only to those stocks that meet daily time frame criteria (as opposed to intraday). For example, I want to apply the intraday buy stop rule only to those stocks that have a daily RSI(3) less than say 20 (make it a parameter so it can be optimized). Also, once the stock is bought, I want to exit at the daily open after the daily RSI(3) is greater than say 50 (again a parameter would be best for optimization capability).

My problem is going from intraday time frame to daily time frame to screen the stocks I want to buy intraday, then back to intraday time frame to buy those screened stocks that have dropped 7% and bounce back at least 1% (buy stop), and then finally going back to the daily time frame to determine which of the bought stocks should be sold at the open(market order) the next trading day.

Any help would be greatly appreciated.

Pablo
profile picture

Eugene

#11
Paul,

When modifying the code above, please consider reviewing the Wealth-Lab WealthScript Programming Guide. In particular the chapters "Multi-Time Frame Analysis" (re: going to Daily scale from intraday) and Programming Trading Strategies > "Strategy Parameters" (re: optimizable parameters) apply the most to your task. Hope this helps.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).