From script to actual trading
Author: amadanes
Creation Date: 7/5/2010 6:05 PM
profile picture

amadanes

#1
I am new to Wealth-Lab. Just finished optimizing a scripted strategy and would like to implement it in my Fidelity account. Do I need to change the Code? trades, entries and exits are now in a - for loop. How would it work in real life?

Also, in the strategy I often have multiple positions of the same share bought at different times at different prices. I use SellAtMarket Positions.AllPositions. This would charge me separate commission for each position. I know how many shares I have and all the positions are the same stock. Is there a way to sell all the shares (I know how many I have) and then restart my loop without any active positions??

Please help anyone

Amos
profile picture

Cone

#2
Step 1. Refer to the User Guide, especially the Orders chapter.

Step 2. Try Paper Trading.

You probably don't need to change the script if you've written it correctly and trading signals execute on bar + 1. All results displayed in the app are theoretical. The live trading occurs when the script generates an Alert. Again, see the Orders chapter for a discussion.

QUOTE:
Is there a way to sell all the shares (I know how many I have) and then restart my loop without any active positions??
Depending on the requirements of the script, you could start the trading loop on the first bar of the current day programmatically; but it's a change that probably isn't required.

QUOTE:
I use SellAtMarket Positions.AllPositions.
In Trading Preference (F12) see the "Exit Orders..." option. What should happen is that each of the Alerts to exit multiple Positions will be sized to the number of shares you have in the account. Since they are duplicate orders, all but one will be filtered from being placed (or even showing up in Orders).

profile picture

amadanes

#3
Thank you very much for your previous answer. Could you please help me with the following:

I am trying to incorporate an option to close all open positions in SellAtLimit declaration. I was only able to do this in a loop going through the last position while any still exist.

When I use:

SellAtLimit( Bar, exitHigh, Position.AllPositions, 'Profit' );

the following error is generated

error CS1012 @(...) too many characters in leteral

When I use:

SellAtLimit(bar,exitHigh,#All,"Profit Target");
I get an error: CS 1040 @(...) preprocessor directive must appear as the first non white character on the line
profile picture

Eugene

#4
Re: SellAtLimit( Bar, exitHigh, Position.AllPositions, 'Profit' );

1. Switch exitHigh and Position.AllPositions. This is the WL4 way, now the order of operands has changed. (It's a good idea to check the QuickRef for the syntax.)
2. SellAtLimit @ bar peeks into the future, leading to inflated results. It should be fixed.

Could you point us to an example that tells to use #All in a WL5 strategy, please?
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).