Maybe somebody is interested in this code:
hello I would like to receive support/help with the following code. He is very simple but I do not know exactly how I accomplish this:
I buy at RSI> 35 and sell when RSI undercuts the 70s line. Attention not when he crosses but after it is over it and leaves them again only.
i can code the crosses but not the keeping over the 70s line.
Thanks for your efforts.
Robert
rmhandel
EricParticipant
Master
?
rsi > 70 previous period and rsi < 70 current period?
yes it keeps above RSI > 70 the entire time. Because it raise above this line, and sells when RSI < 70 current period
Eric was giving you your answer:
c1 = RSI[14](close[1]) > 70 and RSI[14](close[0]) < 70
IF c1 then
Sell at market
endif
many thanks i am going to try it and will give you feedback.
hi, unfortunately it is not working.
The results of your code are same like this:
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
// Bedingungen zum Einstieg in Long-Positionen
indicator1 = RSI[14](close)
c1 = (indicator1 > 35)
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Bedingungen zum Ausstieg von Long-Positionen
indicator2 = RSI[14](close)
c2 = (indicator2 CROSSES UNDER 70)
IF c2 THEN
SELL AT MARKET
ENDIF
// Stops und Targets
To write code, please use the <> “insert PRT code” button, to make code easier to read.
There’s no need to tell your strategy to stay on market WHILE Rsi > 70, since you ordered to SELL only when it crosses UNDER 70, so it opens a LONG trade, then stay on market till RSI goes above 70 and will close the trade only when it CROSSES UNDER, isn’t that what you want?
stay on market till RSI goes above 70 and will close the trade only when it CROSSES UNDER, isn’t that what you want?
I understood exactly the same thing and the code looks ok to me.
yes this is what i wanted. But it don´t works so. The point is i want to stay long in market even the RSI is over 70 and quite time it is above it.
And at least i want to sell and close position when RSI is under 70 . Maybe i can post my ready code here if you want to test it in pro order somebody.
so we would better understand over the coding.
//-------------------------------------------------------------------------
// Hauptcode : über 70 bleibt und kreuzt 70
//-------------------------------------------------------------------------
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
// Bedingungen zum Einstieg in Long-Positionen
indicator1 = RSI[14](close)
c1 = (indicator1 CROSSES OVER 68)
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Bedingungen zum Ausstieg von Long-Positionen
indicator2 = RSI[14](close)
c2 = (indicator2[2] > 70)
indicator3 = RSI[14](close)
c3 = (indicator3 CROSSES UNDER 70)
IF c2 AND c3 THEN
SELL AT MARKET
ENDIF
As I said before, I tested your code AS IS and it works.
Are you using the same RSI on screen, or do you have different settings other than 14?
Can you attach any screenshot with all details of when it did not work?
I was writing while you posted your new code.
It’s different from the first one, which one is the good one?
They do different things, the latter buys when a CROSSOVER 68 occurs, while the original when price was > 35. It sells when there is a CROSSDUNDER 70 AND the two previous candles were above 70, while the original one only on CROSSUNDER.
I am asking ahaint, what do you exactly want?
Moreover, please use INSERT PRT button to enter code. Thanks.
Again, not ahaint… sorry!
The last posted code by rmhandel cannot work as c2 and c3 can’t be true at the same time.