Hi
I am trying to code in come divergence. I have an indicator that draws the low and high of the last 25 candles, I want to record the value of the RSI at whatever candle it happened the first time and then compare the RSI with when the price breaks that level.
IF low <= indicator2 then
MYRSI1 = RSI
I tried this but it resets MYRSI1 to the value where the priced dropped below the line again(indicator2 in the low line)
Lets say the market makes a low at candle 15. I want to save the RSI value at the point. On candle 30 it breaks the low, I then want to compare the current RSI value to the one saved at candle 15
IF low <= indicator2 then
MYRSI1 = RSI
Mybarindex = barindex
Endif
Thanks Grahal. Eventually figured it out. Wrote an indicator and works great.
VNParticipant
Average
Hi Grahal, I have a similar objective to Louwrens, but I am trying to record the price (the closing price) once an event takes place and then I want to go back and reference that price.
Example:
IF ShortOnMarket AND (TRADEPRICE – CLOSE) > 10 THEN
myTrigger = close
EndIf
But I only want the “myTrigger” variable to be updated only once such that on the next candle if the TRADEPRICE – CLOSE becomes 11, I don’t want to record the price. I only want the variable “myTrigger” to be updated with the closing price the first and only time the (TRADEPRICE – CLOSE ) > 10 condition is met.
Do you know is there a way this can be done?
>> 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! <<
🙂
You can make a test to know if you have already updated the variable for that specific order: (by using TRADEINDEX)
IF ShortOnMarket AND (TRADEPRICE – CLOSE) > 10 and tradeindex<>triggerindex THEN
myTrigger = close
triggerindex = tradeindex
EndIf
(not tested).