Code for setting a value at a certain point

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #65118 quote
    Louwrens
    Participant
    Junior

    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

    #65183 quote
    GraHal
    Participant
    Master
    IF low <= indicator2 then
    MYRSI1 = RSI
    Mybarindex = barindex
    Endif
    
    #65253 quote
    Louwrens
    Participant
    Junior

    Thanks Grahal. Eventually figured it out. Wrote an indicator and works great.

    GraHal thanked this post
    #115279 quote
    VN
    Participant
    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?

    #115284 quote
    robertogozzi
    Moderator
    Master

    >> 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! <<
    🙂

    #115285 quote
    Nicolas
    Keymaster
    Master

    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).

    GraHal thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Code for setting a value at a certain point


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Louwrens @louwrens Participant
Summary

This topic contains 5 replies,
has 5 voices, and was last updated by Nicolas
6 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/12/2018
Status: Active
Attachments: No files
Logo Logo
Loading...