Hi All,
I am completely new to all of this and have been going through the manuals and trying to write my own code but really struggling with most of it.
Firstly I can’t workout how sell partial open positions. E.g. SELL at market 50% of open long positions. I am also having trouble in working out how to add to a long if say the RSI is under 30 for X amount of consecutive days.
Would really appreciate any help. I thought about a first algo which will include a number of variables that I can use going forward for other strategies. Have written the basis of it below if anyone has time to help code?
Basic system which looks at RSI on stocks.
Open BUY position if Not LongOnMarket AND RSI <=30. $5,000 CASH AT MARKET.
Add to position (or open/add new position) if RSI remains under 30 for 3 consecutive days. $3,000 trade size if a position already exists. (no idea how to code)
Add to position if RSI goes above 30 and then goes back under 30. $3,000 trade size if a position already exists. (Presume the above buy when RSI <=30 will work but have IF LongOnMarket AND RSI <=30 THEN BUY 3000 CASH AT MARKET?)
SELL AT MARKET 50% of total open position if RSI =>70. (no idea how to code)
SELL remaining open position if RSI stays above 70 for 3 consecutive days. (no idea how to code)
SELL remaining if RSI drops below 70 then goes above 70.(no idea how to code)
OPEN SHORT positions if RSI goes above 85. $3,000 opening positions. (IF MyRSI =>85 THEN SELLSHORT 3000 CASH AT MARKET ENDIF?)
Add to short if RSI goes above 90. $2,000 if position already open. (IF MyRSI =>90 THEN SELLSHORT 2000 CASH AT MARKET ENDIF?)
Add to short position if RSI stays above 70 for 5 consecutive days. (dont know how to code)
Close 50% of total short position if RSI goes below 55. (dont know how to code)
Close remainder of short if RSI goes below 45. (dont know how to code)
Noticed need to have DEFPARAM CumulateOrders = True
The variables that I would want to be able to change are the RSI levels, amount of trade size in $, day counts for adding to positions and percentage of the positions when closing out.
Let me know if any questions and I apologise if what I have written is unclear.
Thanks