Hey,
I wonder if some one could help im trying to get MA 61 crossing 200 in bulltrend, and i also want in this bulltrend to have and RSI 2 that picks up a contract as it goes down to the value of 6 and sell the position when it hits the value of 95. The only thing i cant get to work is that i only want the RSI to react when the 61 have crossed over 200. So the RSI have to be depended of it self and also sync with the MA. So of when MA have been taken out of profit or MA been crossing under, then i dont want RSI to take any more positions until MA 61 is crossing 200 again. Just then does the RSI have acces to buy again.
Do i make sense?
Thank you, hope som of you guys can help me.
So to be clear, you only want 1 trade in each bullish trend? Triggered by the RSI2 crosses under level 6?
Hey, want in bullish trend that 1 long position triggered with MA is crossing and i also want under this positions of MA that the RSI2 starts buying multiple of times every time it is under level 6 in this bullish trend. So i get 1 long position and maybe in i get 5-10 more trades depending of the value of rsi2.
This is so far i have gotten and now the rsi buys all the time both in bullish and bear.
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = true // Cumulating positions deactivated
//DEFPARAM FlatBefore = 080000
//DEFPARAM FlatAfter = 223000
//KÖP
ID2 = average[30]
ID3 = average[80]
ID0 = RSI[2]
if b3 then
buy 1 contract at market
endif
b2 = (ID2 crosses over ID3)
b3 = (ID0 <6)
IF b2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
//SÄLJ
ID4 = average[30]
ID5 = average[80]
ID6 = RSI[2]
s1 = (ID4 crosses under ID5)
s2 = (ID6 >90)
if s2 then
sell at market
endif
IF s1 THEN
Sell at market
endif
> 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! <<
Code is read from top to bottom and your line 19 is below the line 14, which has no sense, because you are testing something that still don’t exist at line 14 (b3 is nothing at that moment).
I modified the code the way I understand your strategy :
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = true // Cumulating positions activated
//DEFPARAM FlatBefore = 080000
//DEFPARAM FlatAfter = 223000
//KÖP
MA30 = average[30]
MA80 = average[80]
ID0 = RSI[2]
b1 = (MA30 crosses over MA80)
b2 = (ID0 crosses under 6)
if b1 or b2 then
buy 1 contract at market
endif
//SÄLJ
s1 = (MA30 crosses under MA80)
s2 = (ID0 > 90)
if s1 or s2 then
sell at market
endif
(not tested, please make your own tests and give feedback here).
Hey and thank you, yes i will use the “insert code prt” from here on.
The code is still buying in bull and bear, i will add three pictures and trying to explain myself.
The third picture i am trying to show you how i want it to buy. The circle should be the long position in this bull trend. Then i have put out som green arrows in the rsi that i want to buy in the “dips” but only this can be done when the ma is in bull.
Thanks
OH SORRY, just change to code to this one instead:
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = true // Cumulating positions activated
//DEFPARAM FlatBefore = 080000
//DEFPARAM FlatAfter = 223000
//KÖP
MA30 = average[30]
MA80 = average[80]
ID0 = RSI[2]
b1 = (MA30 crosses over MA80)
b2 = (ID0 crosses under 6)
b3 = MA30>MA80
if (b1 or b2) and b3 then
buy 1 contract at market
endif
//SÄLJ
s1 = (MA30 crosses under MA80)
s2 = (ID0 > 90)
if s1 or s2 then
sell at market
endif
You should change the “6” level of the RSI, because it is not reaching this level in your example (I ran test myself).
Hey again, thank you very much sir. Now the code is exactly how i want it. Perfect! And i also understand now how to write other codes thanks to this. I will now backtest with som new and other values.
I appreciate this very much.
I will report back how its going.