04-25-2019, 07:42 AM
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 -
Then in the check function with your trade logic:
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