Storing the candle close price on differing TFs

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #251830 quote
    LivJoJade
    Participant
    New

    Hi

    I’m interested in automated trading and have the attached indicator and proscreener to use, I believe the proscreener can be used to convert to an automated system.

    The indicator delivers buy/sell signals for which the proscreener then searches, what I want to know is this. Say a buy signal is delivered on the 4hr, 2hr, 1hr or 30min can the candle close price be remembered irrespective of what timeframe it is delivered, I then search for a subsequent buy signal on the 10min, 5min, 2min or 1min. If the close price on the shorter timeframe is lower than the close price on the longer timeframe  it is an entry opportunity and we automatically buy, if the close price is higher than the ‘remembered’ longer timeframe signal we abort unless already in a profitable trade and therefore constitutes an additional entry.

    I hope that all makes sense and would appreciate any help forthcoming.

    Chris

    the-one-1.itf WIP1-1.itf
    #251837 quote
    Iván González
    Moderator
    Master

    Hi. Here you have an example.

    // --- Higher timeframe signals (example on 4h) ---
    TIMEFRAME(4hour,updateonclose)
    signalH = CALL "the one"
    IF signalH = 1 THEN
    higherClose = Close
    ENDIF
    
    // --- Back to lower timeframe ---
    TIMEFRAME(5minute)
    signalL = CALL "the one"
    
    // Only take entry if close < higher timeframe close
    IF signalL = 1 AND close < higherClose THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    robertogozzi and LivJoJade thanked this post
    #251872 quote
    LivJoJade
    Participant
    New

    First of all Ivan, many thanks for your help.

    From your reply and my very limited knowledge of coding I’ve written the attached WIP file, this for long positions only.

    Long TFs are 4, 2, 1 hour and 30 minutes.

    Shorter TFs are 10, 5, 2 and 1 minutes

    You will see from the Grocery Outlet Holding Corp screenshot a long entry was given on the 30 minute TF (close 1567.5) with a subsequent long entry on the 2minute TF (close  1510), however no entry was highlighted on the probacktest when run. Is my code incorrect or may I have overlooked something?

    Again, many thanks for your help.

    Chris

    Screenshot-2025-09-26-214232.png Screenshot-2025-09-26-214232.png WIP.itf the-one-2.itf
    #251901 quote
    LivJoJade
    Participant
    New

    UPDATE

    Having worked on this code over the weekend I attach my latest update. My concern is that when using multiple TFs it appears they need to be multiples and in this example of 10,5,2 and 1 minute that has to be 1 minute, does that mean the code will only autotrade on the 1 minute chart. If so can I overcome that so that entries can be on either the 10,5,2 or 1 depending on what  secondary shorter TF the signal is delivered.

     

    Many thanks in anticipation.

    longTF-Short-TF.itf Screenshot-2025-09-28-205814.png Screenshot-2025-09-28-205814.png
    #252010 quote
    robertogozzi
    Moderator
    Master

    The default timeframe (the one on the chart)  must always be <= the smallest timeframe in the code. And ALL timeframes in the code must be multiples of the default timeframe.

    In your case you can only trade the 1-minute timeframe.

    LivJoJade and Iván González thanked this post
    #252011 quote
    LivJoJade
    Participant
    New

    Hi Robert

    Many thanks for your reply and help. So I’m guessing individual codes for the 4 individual shorter timeframes is the only answer. I’ll get on it.

    Thanks again.

    #252084 quote
    LivJoJade
    Participant
    New

    Hi again

    Looking at the attached code can anyone please explain why the entry at 19:25 this evening didn’t trigger.

    Many thanks in anticipation.

    Chris

    Screenshot-2025-10-01-205718.png Screenshot-2025-10-01-205718.png 5minute-Long.itf
    #252095 quote
    robertogozzi
    Moderator
    Master

    What istrument is it?

    I could only spot PAR on your pic, but none of the instruments tagged PAR that I found match that price levels.

    #252098 quote
    LivJoJade
    Participant
    New

    Good morning Robert

    It is PAR Technology Corporation, a US share company.

    Many thanks for looking into this for me.

    Chris

    #252112 quote
    robertogozzi
    Moderator
    Master

    Sorry, but I could only find a similar asset quoting around 38.1, instead of 3.76, so I assume it’s not the same, so I couldn’t verify your missing trade.

    LivJoJade thanked this post
    #252142 quote
    LivJoJade
    Participant
    New

    good afternoon Robert

    If I can provide further information to hopefully you in assisting me.

    On 25/9 at the close of the 16.00 candle (value 3995.5) a buy signal was delivered on the 30 min chart, subsequently a further buy signal was given on the 1/10 at the close of the 19.25 candle (value 3791.5). As you can see this close on the shorter TF is lower than that given on the longer TF and should have resulted in a long position.

    I attach the indicator code, the probacktest / automated trading code for your purposes along with all the info I can find on the instrument.

    par technology corporation stock – Search

    As per usual, in anticipation I am most grateful for your help.

     

    Chris.

    the-one.itf 5minute-Long-1.itf Screenshot-2025-10-03-171656.jpg Screenshot-2025-10-03-171656.jpg
    #252158 quote
    robertogozzi
    Moderator
    Master

    That’s not a ProRealTime chart, how could you run your code?

    LivJoJade thanked this post
    #252166 quote
    LivJoJade
    Participant
    New

    Apologies Robert the PAR screenshot was to provide further information on the instrument (which you had difficulty locating) for which signals had been delivered, sorry for the confusion.

    However, using the same indicators and the same 4,2,1 and 30min longer TFs and the shorter 10,5,2 and 1min shorter TFs signal were given on Friday, they are:

    Instrument: AIG American Intl Grp Inc. Short signal (3/10/25) on 30min at 15:30 candle close (value 8021.5). Subsequent short signals (3/10/25)  on 5min at 17:10 candle close (value 8106.5) and on 1min at 20:41 candle close (value 8136.5)

    Instrument: Belden Inc. Long signal (29/9/25) on 30min at 17:00 candle close (value 12141). Subsequent long signals (3/10/25) both on 2min at 18:56 candle close (value 11876.5) and again at 20:50 candle close (value 11805)

    All entries show as being triggered if one runs a probacktest on the shorter TFs but are not triggered on an automatic trading system generated by the same probacktest code.

    Many thanks for your continued support Robert

    #252169 quote
    JS
    Participant
    Senior

    Hi,

    When I look at the code of the “Call” indicator “the one”, I notice that the conditions required to produce a positive (1) or negative (-1) signal are very specific, you need to meet ten (10) conditions to trigger either signal, which means it will occur relatively rarely…

    It’s therefore important that a signal is remembered until the opposite signal appears, in other words, a +1 signal should remain +1 until a (counter)signal of -1 is generated…

    The signal should only have two possible values: +1 or -1…

    This is where things go wrong, because line 6 in the code (Signal = 0) resets the signal every 5 minutes…

    Remove line 6 (//Signal = 0) from the code of “the one” and try again…

    ind1 = BollingerDown[26](close)
    ind2 = BollingerUp[26](close)
    ind3 = RSI[14](close)
    ind4 = 70
    ind5 = 30
    //Signal = 0
    
    IF (close > close[1] and close > close[2] and close[1] < close[2] and close[2] > close[3])THEN
    IF (ind3 > ind3[1] and ind3 < ind3[2] and ind3[1] < ind3[2] and ind3[2] > ind3[3]) THEN
    IF ind3 > ind4 THEN
    IF close > ind2 THEN
    
    Signal = -1
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    IF (close < close[1] and close < close[2] and close[1] > close[2] and close[2] < close[3]) THEN
    IF (ind3 < ind3[1] and ind3 > ind3[2] and ind3[1] > ind3[2] and ind3[2] < ind3[3])THEN
    IF ind3 < ind5 THEN
    IF close < ind1 THEN
    
    Signal = 1
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    return Signal style(histogram)
    robertogozzi and LivJoJade thanked this post
    #252179 quote
    LivJoJade
    Participant
    New

    Good evening JS, many thanks for taking the time to help.

    I have added your indicator code to the attached 2 min charts for the following example triggered on Friday afternoon.

    Instrument: Belden Inc. Long signal (29/9/25) on 30min at 17:00 candle close (value 12141). Subsequent long signals (3/10/25) both on 2min at 18:56 candle close (value 11876.5) and again at 20:50 candle close (value 11805)

    You will note from the probacktests that my code only allows entries when the value is 1 (18:56 and 20:50 close) where yours would have an entry on all candle closes until the indicator changes to -1, this unless I of course add the extra if “notlongonmarket”. Although in the example given the market has gone against it is not always the case a -1 will follow a 1 signal, one may wish to average up or down and would therefore need to revert to the 0 in order to trigger subsequent entries if a subsequent signal in the same direction is given prior to an exit signal.

    I hope I’ve explained that correctly.

    Many thanks for your time and expertise.

    Chris

    JS thanked this post
    Screenshot-2025-10-05-204247.png Screenshot-2025-10-05-204247.png Screenshot-2025-10-05-205037.png Screenshot-2025-10-05-205037.png
Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.

Storing the candle close price on differing TFs


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
LivJoJade @livjojade Participant
Summary

This topic contains 14 replies,
has 4 voices, and was last updated by LivJoJade
4 months, 3 weeks ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/25/2025
Status: Active
Attachments: 14 files
Logo Logo
Loading...