| Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 3/29/2007 Posts: 11
|
I am trying to plan a scale in strategy for the following:
Setup: Currently not in a position
Price > 200SMA
RSI(2) > 25
RSI(1) < 25
RSI < 25
A Buy on Close
Scale In:
B If still in the trade and
Close < entry price ( A )
Buy 2x on Close
C If still in the trade and
Close < price ( B )
Buy 3x on Close
D If still in the trade and
Close < price ( C )
Buy 4x on Close
Exit:
RSI > 70
Exit all
I have the script to enter based on the Setup. I don't know how to 'remember' the purchase price (close of A, B or C) so I can reference it for the Scale in Strategy. How would I program this?
The Scale-In would stop if the exit is reached. E.g. If two buys happen (A and B), then RSI > 70, C and D would not execute.
While in a trade, no new A positions would be executed.
Thanks for your help with this,
- Miles
|
|
Registered User Joined: 3/29/2007 Posts: 11
|
Anybody have even a hint for what to do?Thanks,- Miles
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
You can't backscan this but can do it in code. Something like
'# StartingEquity = userinput.single = 100000
const xPeices as integer = 10
static InTrade as boolean
static buyFactor as integer
static equity as single
static entryPrice as single
static shares as integer
static totalShares as integer
if isfirstbar then
equity = StartingEquity
buyFactor = 1
inTrade = false
totalShares = 0
end if
if enterOnOpen then
end if
if inTrade = false then
If timeToEnter = true then
shares = (equity/xPieces)/price.close
totalshares += buyFactor * shares
entryPrice = price.close
equity -= entryPrice * buyfactor * shares
buyFactor += 1
end if
else ' must be in trade
if timeToExit = true the
equity += totalShares * price.close
totalShares = 0
buyFactor = 1
intrade = false
else if price.close < entryPrice andalso _
buyFactor < 4 then
entryprice = price.close
equity -= entryPrice * buyFactor * shares
totalShares += buyFactor * shares
buyFactor += 1
end if
end if
plot = equity + totalshares * price.close
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
delete lines
if enterOnOpen then
end if
Note the code is uncompiled and untested.
|
|
|
Guest-1 |