RSI CODE help!
Forums › ProRealTime English forum › ProOrder support › RSI CODE help!
- This topic has 7 replies, 2 voices, and was last updated 5 years ago by
robertogozzi.
-
-
04/18/2020 at 7:01 PM #126779
Hi Everyone,
Hoping someone can help me.
I am new to this and have written a simple code which opens a sell order when the RSI is >70 and a buy order at <30. I have included for a target point range, which for this example can be 5.
The code works fine, except, when it opens a long/short and the market moves in the required direction taking the RSI below 70 or above 30 but does not however trigger the target of 5 but instead renters the >70 or <30 area, the program gets confused and will ignore the target of 5 and then only closes the short or long at the point of <30 and long at >70. Is there a change I can make that will ensure that any opened position will close at the target value irrespective if the value goes above or below the 30/70 RSI level, and also if this were to occur then every time it does break the RSI level, it opens a subsequent position. When I back test it as it is, its doing what I want except the times where it bounces in and out of the 70/30 area.
Any advice, help or modifications to the code would be appreciated.
12345678910111213141516171819202122232425262728293031323334DEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 000000DEFPARAM FLATAFTER = 000000//ConditionsC1 = (RSI < 30)C2 = (RSI > 70)// Conditions to enter long positionsIF NOT LongOnMarket AND C1 THENBUY 1 CONTRACTS AT MARKETENDIF// Conditions to exit long positionsIf LongOnMarket AND C2 THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT ShortOnMarket AND C2 THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Conditions to exit short positionsIF ShortOnMarket AND C1 THENEXITSHORT AT MARKETENDIF// Stops and targets : Enter your protection stops and profit targets hereSET STOP PLOSS 0SET TARGET PPROFIT 504/18/2020 at 9:13 PM #126803>> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
🙂04/18/2020 at 9:17 PM #126810Try increasing the your TP, 5 seems to not abide by the minimum distance required.
10+ might solve it.
04/19/2020 at 1:23 PM #126884I don’t think that makes any difference, whilst backtesting and having found this issue, the problem isn’t with the TP its when the price drops below/above the 70/30 RSi and then revisits that area. at that point, I want the code to open another trade or if nothing else, just close out the original trade at the required TP. what actually happens is that it doesn’t do this and waits for it to open/close a trade at the opposite RSI. logically, it should close at the required TP, for whatever reason this does work, but fails if it renters the are of 70/30.
04/19/2020 at 2:48 PM #126897I can’t understand lines 2 and 3, They might be confusing.
Line 2 is useless, since there cannot be anything before 000000, -1 does not exist.
Line 3 means at anytime because whatever the time it will be > 0.
Your trades shouldn’t open at all, but if they do they should be immediately closed.
04/19/2020 at 4:01 PM #12690604/19/2020 at 5:46 PM #126914You have to tell me:
- instrument used
- TF used
- date & time of (some) candles where the strategy did not what expected.
04/19/2020 at 5:59 PM #126915Anyway, you can replace lines 7-8 with:
123456C1 = 0C2 = 0IF Not OnMarket THENC1 = (RSI < 30)C2 = (RSI > 70)ENDIFthis should do.
-
AuthorPosts
Find exclusive trading pro-tools on