Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Multple Entries in the same stock ? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
strategy123
Posted : Friday, October 2, 2009 10:10:02 PM
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

jas0501
Posted : Friday, October 2, 2009 11:32:09 PM
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.

strategy123
Posted : Monday, October 5, 2009 10:50:13 AM
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.
jas0501
Posted : Monday, October 5, 2009 1:21:06 PM
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.

strategy123
Posted : Tuesday, October 6, 2009 9:05:12 AM
Registered User
Joined: 12/15/2008
Posts: 17

Very interesting.  Thx... 

meast
Posted : Sunday, November 14, 2010 12:06:24 PM
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
Users browsing this topic
Guest-1

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.