Wealth-Lab Wiki

API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers Pending Deletion PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers
RSS

Navigation


Quick Search
»
Advanced Search »


SaveHistoricalTrades

RSS

Syntax


public static void SaveHistoricalTrades(this WealthScript ws, string path, string fileOptions, string FileSetupString)

Parameter Description

pathFull path or file name
fileSaveOptionsOptions to prepare the trades for saving (see below). Use " ~SignalDatesx ~CloseoutOpenx ~CloseoutClosex ~Closeoutx ~PrintFilex ~NoPriorityx ~NoClosedx ~NoOpenx"
FileSetupStringThese will appear in the csv DEFAULT header and will be applied by Historical Trades. They are all keyword based and fully detailed in Strategy Summary Section 4 of Historical Trades. However, the ~EnterAt: and ~ExitAt: described below are all that are typically needed.

The File Save Options are: ~SignalDatesx ~CloseoutOpenx ~CloseoutClosex ~Closeoutx ~PrintFilex ~NoPriorityx ~NoClosedx ~NoOpenx ~SplitFactorx:0.5
And remove the trailing x to use the option. Only proper spelling of the option will turn it on. The options are in no particular order and may be removed.
~SignalDates - Save signal dates instead of trade dates.
~CloseoutOpen - Close out all open trades at the open of the last bar.
~CloseoutClose or ~Closeout - Close out all open trades at the close of the last bar.
~PrintFile - Prints the contents of the saved file to the Debug window.
~NoPriority - Disables priority in the csv so random priorities will be applied in Historical Trades.
~NoClosed - Closed trades will not be saved.
~NoOpen - Open trades will not be saved.
~SplitFactor:0.5 - Multiply actual price and commission by 0.5 in the csv. Use any split factor.


Typical and recommended FileSetupString is:
Use " ~Print: ~%Equity: ~EnterAt:SDO ~ExitAt:SDO "


A proper value after the : is expected or the keyword is ignored.
~Print:All - Print all summary, error and transaction detail.
~Print:min - Print minimum detail of summary and error only.
~%Equity:20 - Apply 20% equity per trade when using Position Options PosSizer and sizing will be automatically adjusted when executing multiple csv files. Select other Data Panel sizing options as needed.
~EnterAt:SDO ~ExitAt:SDO - Enter/Exit all trades at Same Day Open (SDO) of the date given. Use SDO, SDC, SDP, Open, Close, or Price if trade dates are saved. Use Next Day Open (NDO), NDC, NDP if signal dates are saved.


Special Case: If source strategy entries or exits use multiple trade timings (i.e. at open, at close and at price), then the individual entry and/or exit signal name must be prepended with Open: or Close: or Price:. SaveHistoricalTrades() will save the timing for each trade and Historical Trades will then execute each entry and exit to accurately emulate shares traded in the source strategy.

Description

Created by Wealth-Lab.com community member Kevin Sheehan, This function saves strategy trades in a format allowing Historical Trades to emulate strategy results and optimize by symbol, entry/exit time, and percent equity. Save trades to the documents folder as HistoricalTrades.csv with a proper FileSetupString and simply open and execute "Historical Trades: No Coding with By Symbol Optimization" to emulate the strategy and gain additional analysis.

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.