Cannabis Report
High Times
Home > Boards > Free Zone > A.I.M. > The "Stock Trading Riches" Investment System

I had to modify the script again, so

Public Reply | Private Reply | Keep | Last ReadPost New MsgReplies (1) | Next 10 | Previous | Next
PraveenP Member Profile
 
Followed By 4
Posts 173
Boards Moderated 1
Alias Born 01/10/03
160x600 placeholder
PraveenP   Wednesday, 10/28/15 02:16:18 AM
Re: neko post# 260
Post # of 281 
I had to modify the script again, so that on the first price (when ovshares is 0) we calculate shares based on control (not vcontrol).

So here is the correct script:

BEGIN {
control = 2000
vcontrol = 2 * control
cash = control
orig = control
}

{
price = $1
value = shares * price + cash
ovshares = vshares
oshares = shares
vshares = int(vcontrol / price)

if (ovshares == 0)
shares = int(control / price)
else
if (vshares > ovshares)
shares = oshares + (vshares - ovshares)
else
shares = oshares - (ovshares - vshares)

if (shares < 0)
shares = 0

cash = value - shares * price
if (cash < 0)
{
value += -1*cash
orig += -1*cash
cash = 0
}
print price" "shares" "cash" "value" "orig
}


Praveen Puri
Author of "Stock Trading Riches"
The Stock Trading Riches System discussion board: http://investorshub.advfn.com/boards/board.aspx?board_id=19287
Public Reply | Private Reply | Keep | Last ReadPost New MsgReplies (1) | Next 10 | Previous | Next
Follow Board Follow Board Keyboard Shortcuts Report TOS Violation
X
Current Price
Change
Volume
Detailed Quote - Discussion Board
Intraday Chart
+/- to Watchlist