Hi,
I was looking through the forums and had a query in regard to comparing indicators in different time periods. Say I wanted to compare an RSI from 6 candles ago to a current close[0]. How would I go about doing this for example could I do the following;
rsi_level= rsi[14]
if rsi_level[6]>rsi_level[0] then
///do somthing
endif
Also if certain conditions are met would it be possible to record a value inside pro real time.
if rsi_level>70 and daytrend>3 and roc_level>3 then
SELL SHORT 3 PER POINT AT MARKET
//What would be the code to record stochastic
sto=stochastic[0]
endif
Really appreciate the feedback and support provided
Kind Regards,
The documentation found under help can be very useful when you don’t know the format for a bit of code:
Stochastic
Your RSI code looks fine but bear in mind that the current candle is 0 so six candles including the current candle is candle 5.
Hi That’s great thanks for that in regard to the second question is it possible to record a variable ?
record_rsi= 0
my_rsi=rsi[14]
if roc>14 then
//record variable
record_rsi=my_rsi[0]
endif
Really Appreciate the input
Kind Regards,
is it possible to record a variable ?
Yes of course it is. Just save a value as any variable name just as you have done and that variable will keep that value until you give an instruction to change it.
So for example you could even save the last five values:
if ROC > 14 then
rsivalue5 = rsivalue4
rsivalue4 = rsivalue3
rsivalue3 = rsivalue2
rsivalue1 = rsi[14]
endif
Between lines 4 and 5 this one is missing:
rsivalue2 = rsivalue1
Well spotted Roberto – that’s what happens if you try to cook dinner and reply on a forum at the same time!