Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 12/15/2008 Posts: 17
|
Have a simple buy setup and was wondering if SF can enter multiple positions in the same stock each time the same buy critieria is met. For example, buying each time a 21 day high is reached and exiting all positions if the 50SMA is penetrated. Is this possible ? thx
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
Not in the backscanner as only one position is permitted, however you can write it in realcode and plot the equity curve. Then compose a custom index of the equity curves for the overall picture of the strategy.
|
|
Registered User Joined: 12/15/2008 Posts: 17
|
QUOTE (jas0501)
Not in the backscanner as only one position is permitted, however you can write it in realcode and plot the equity curve. Then compose a custom index of the equity curves for the overall picture of the strategy.
thx.... but not sure I understand this at all. I'm familiar with realcode but really don't know what you mean "write it in realcode and plot the equity curve". I know how to create a custom index of a watch list but not sure how any of this links together. I guess I'm not famliar enough with it.
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
QUOTE (strategy123) QUOTE (jas0501)
Not in the backscanner as only one position is permitted, however you can write it in realcode and plot the equity curve. Then compose a custom index of the equity curves for the overall picture of the strategy.
thx.... but not sure I understand this at all. I'm familiar with realcode but really don't know what you mean "write it in realcode and plot the equity curve". I know how to create a custom index of a watch list but not sure how any of this links together. I guess I'm not famliar enough with it.
Basicly the idea is to manage the trades in real code. Here is a very simple sketch, uncompiled, untested, with incomplete logic but presenting the gist.
'# commision = userinput.integer = 10
'# positionSize = userinput.integer = 10000
Static equity as single
static entryPrice(10) as single
static inTrade as boolean
static openTradeCount
dim gain as single
dim shares as integer
if isfirstbar then
equity = 0
tradeCount = 0
end if
'
' code to mange entry
'
if entryCondition then
tradeCount += 1
' buy tomorrow's open
entryPrice(tradeCount) = price.open(-1)
shares = positionSize/price.open(-1)
equity -= shares* price.open(-1) - commission
end if
'
' code to mange exist for each open trade or for all open trade
'
if exitCondition then
equity += price.close(-1) - entryPrice(whichTrade) - commission
entryPrice(whichTrade) = 0
tradeCount -= 1
'
' adjust entry_Price array to compress and fill gap caused by trade close
' if each trades exit condition is unique to the trade
' otherwise the trade closes would be in a loop if exit all trades
'
end if
gain = 0
for i as integer = 1 to openTradeCount
gain += price.close - entryPrice
next i
plot = equity + gain
As I said a rough sketch, but the plot will show the equity curve for that stock starting at 0 and reflecting the totals gain or loss over the history of the symbol.
The custom index:total of the equity plot show the overall Profit/loss of the strategy.
One last note, this approach assumes infinite funds and a starting balance per stock of $0.
|
|
Registered User Joined: 12/15/2008 Posts: 17
|
Very interesting. Thx...
|
|
Registered User Joined: 3/26/2005 Posts: 18
|
TX jas for the post. It took a yr but I have one that seems to work. Is there any way to set the period for the calculation, as you would in backscanner? I would prefer to test only a few years but the indicator shows equity for all price data since 1991.
mick
|
|
Guest-1 |