Bull trend riding RSI take profit
#1
Could someone help me to work out this code.. ?

Code:
// Sell when RSI > 75 - want to change to allow for riding bull trends properly. - watch rsi each candle after 75 and sell when it starts dropping again.
 if (rsi2.result > 75 && advised) {
   this.sell('Take Profit - RSI past 75');


I want to trigger it when the RSI hits 75, to check every candle and see if the RSI is higher or lower than the last candle, if its higher, do nothing, if its lower, sell.

Any one help me work out how to do this? Im pretty new to code..


Thanks!
  Reply
#2
interesting, I follow.
  Reply
#3
You need to keep track of the previous candles RSI and compare the latest data to it.

In the init function declare a variable to hold the previous RSI -
Code:
this.prevRsi = 0;

Then in the check function with your trade logic:
Code:
if(RSI >= 75){ //Have you passed your sell threshold?
   if(RSI < prevRsi){ //Is the RSI lower than the previous candles RSI?
       //Sell
   }
}

prevRsi = RSI; //At the end of the check function, make sure you update previous RSI
  Reply


Forum Jump:


Users browsing this thread: