How can count all RSI bars over 70 and under 30?
How can count all RSI bars over 70 and under 30?
Loading saved threads...
user9947173 · External communityPost link
External question — Stack Overflow Stack Exchange
Author: user9947173
Original post: https://stackoverflow.com/questions/67467607
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I want to count rsi bars under or over 70 and 30 .
rsi oversold and bought area are sometime very strong in momentum.they not come back immediately as usual know.
So I want to count if RSI Bars over and under 70 30 for 5 bars. open orders
I code like that
for(int i = 0; i<20 ;i++)
{
rsi1 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+1);
Print("RSI1 is "+rsi1+"");
rsi2 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+2);
Print("RSI2 is "+rsi2+"");
rsi3 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+3);
Print("RSI3 is "+rsi3+"");
rsi4 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+4);
Print("RSI4 is "+rsi4+"");
}
if(OrdersTotal() == 0 ){
if( rsi1 > 70 && rsi2 > 70 && rsi3 > 70 && rsi4 > 70 )
OrderSend(Symbol(),OP_BUY,1,MarketInfo(Symbol(),MODE_ASK),3,0,0,"Main Buy",1111,0,Green);//this is rabbit
if( rsi1 < 30 && rsi2 < 30 && rsi3 < 30 && rsi4 < 30 )
OrderSend(Symbol(),OP_SELL,1,MarketInfo(Symbol(),MODE_BID),3,0,0,"Main Sell",1111,0,Red);//this is rabbit
But in actual it does not count 5 bars
only count 1 bars and open orders.
How can solve it.
Please someone help me.
want to count from here to here .
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/67469464
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
There is no need for the
for
loop, this is not an indicator and you are not working with historical data. If you want to check the last 5 closed candles your code should be:
double rsi1 = iRSI(NULL,0,10,PRICE_CLOSE,1); Print("RSI1 is "+rsi1);
double rsi2 = iRSI(NULL,0,10,PRICE_CLOSE,2); Print("RSI2 is "+rsi2);
double rsi3 = iRSI(NULL,0,10,PRICE_CLOSE,3); Print("RSI3 is "+rsi3);
double rsi4 = iRSI(NULL,0,10,PRICE_CLOSE,4); Print("RSI4 is "+rsi4);
double rsi5 = iRSI(NULL,0,10,PRICE_CLOSE,5); Print("RSI5 is "+rsi5);
if(OrdersTotal() == 0 )
{
if(rsi1>70 && rsi2>70 && rsi3>70 && rsi4>70 && rsi5>70)
OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"Main Buy",1111,0,clrGreen);
if(rsi1<30 && rsi2<30 && rsi3<30 && rsi4<30 && rsi5<30)
OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"Main Sell",1111,0,clrRed);
}
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: user9947173 Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/67467607 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I want to count rsi bars under or over 70 and 30 . rsi oversold and bought area are sometime very strong in momentum.they not come back immediately as usual know. So I want to count if RSI Bars over and under 70 30 for 5 bars. open orders I code like that for(int i = 0; i<20 ;i++) { rsi1 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+1); Print("RSI1 is "+rsi1+""); rsi2 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+2); Print("RSI2 is "+rsi2+""); rsi3 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+3); Print("RSI3 is "+rsi3+""); rsi4 = iRSI(Symbol(),0,10,PRICE_CLOSE,i+4); Print("RSI4 is "+rsi4+""); } if(OrdersTotal() == 0 ){ if( rsi1 > 70 && rsi2 > 70 && rsi3 > 70 && rsi4 > 70 ) OrderSend(Symbol(),OP_BUY,1,MarketInfo(Symbol(),MODE_ASK),3,0,0,"Main Buy",1111,0,Green);//this is rabbit if( rsi1 < 30 && rsi2 < 30 && rsi3 < 30 && rsi4 < 30 ) OrderSend(Symbol(),OP_SELL,1,MarketInfo(Symbol(),MODE_BID),3,0,0,"Main Sell",1111,0,Red);//this is rabbit But in actual it does not count 5 bars only count 1 bars and open orders. How can solve it. Please someone help me. want to count from here to here .
Checking account access…