Noob coding advice RSI stop
- This topic has 3 replies, 3 voices, and was last updated 3 years ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
Similar topics:
Forums › ProRealTime English forum › ProOrder support › Noob coding advice RSI stop
Hi Team,
Please be gentle with me, Im a complete noob and Im pretty sure my questions may be daft and basic. Anyway I`ve created a simple RSI strategy using the Simplified creation builder and applied it to the FTSE100 at 20min timeframe, on back-testing, it seems to turn a profit most of the time
However, back-testing further, there are certain dates like Feb / March 2020 where the market took a severe nose dive or October 2020 where there was a sharp upturn and I was wrong side and get stopped out. Is there a way I can prevent it from opening positions when the market is moving in one direction or another sharply?
Sorry if I sound like a complete noob.
Code looks like this, thanks in advance:
===================================================
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = RSI[17](close)
c1 = (indicator1 CROSSES OVER 29)
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator2 = RSI[17](close)
c2 = (indicator2 CROSSES OVER 70)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator3 = RSI[17](close)
c3 = (indicator3 CROSSES UNDER 70)
IF c3 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator4 = RSI[17](close)
c4 = (indicator4 CROSSES UNDER 29)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
Yes, you can add two variables to enable, or disable, opening Long or Short trades by setting them to either 1 or 0. I named them GoLong and GoShort:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
DEFPARAM CumulateOrders = False // Cumulating positions deactivated GoLong = 1 //0=disabled, 1=enabled GoShort = 1 //0=disabled, 1=enabled // Conditions to enter long positions indicator1 = RSI[17](close) c1 = (indicator1 CROSSES OVER 29) IF c1 and GoLong THEN BUY 1 CONTRACT AT MARKET ENDIF // Conditions to exit long positions indicator2 = RSI[17](close) c2 = (indicator2 CROSSES OVER 70) IF c2 THEN SELL AT MARKET ENDIF // Conditions to enter short positions indicator3 = RSI[17](close) c3 = (indicator3 CROSSES UNDER 70) IF c3 and GoShort THEN SELLSHORT 1 CONTRACT AT MARKET ENDIF // Conditions to exit short positions indicator4 = RSI[17](close) c4 = (indicator4 CROSSES UNDER 29) IF c4 THEN EXITSHORT AT MARKET ENDIF |
I may be completely wrong, but I think what he’s looking for is more of a trend detection – another condition that will prevent his trade opening in the wrong direction, or will cut out if the trend moves sharply against him ???
for example
|
1 2 3 4 |
Timeframe (1 hour) ma = average[a,t](typicalprice) cb1 = ma > ma[1] cs1 = ma < ma[1] |
Hi Guys,
Thank you so much for you time and responses, much appreciated. I understand I can use additional indicators to determine if I should open a position, I guess Im wondering what specific indicators and values would prevent opening the trades on the dates where the markets fell or rose in a big way.
Maybe some code that says if the market has shifted +/- 2% since open, dont trade?
Thanks Again
Find exclusive trading pro-tools on