Announcement

Collapse
No announcement yet.

What is the recommended method to check higher time frame indicators using inv().

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is the recommended method to check higher time frame indicators using inv().

    As you know it's a common practice, the validity of which I was trying to ascertain recently, for traders to "check" the status of indicators in higher time frames as confirmation of signals generated in the lower time frames.


    Using a simple example of a price oscillator crossover as a trade trigger, ie., when the value of the oscillator is above zero on a 5 minute chart (closing basis).

    Before taking the trade I want to check that the price oscillator is also above zero on a 15 minute chart at the exact point in time.

    Below is an example of one technique of checking the higher interval period using (-1 )and (-2) and while this method eliminates the "forward looking" problem when backtesting (which inflates the profitability) it is based on indicator readings of "older"completed bars.
    PHP Code:

    var myStudy15 osc(10,20,false,inv(15));// 15min study
     
    if(!Strategy.isLong()){
       
      if(  
    myStudy15.getValue(-2)<&& myStudy15.getValue(-1)>0)


            
    Strategy.doLong(etc etc)
        }

    What technique would you recommend (getSeries?)in a strategy EFS running on a 5min chart/int, to check the value of the same price oscillator value on the longer 15 minute interval?
    (similiar to a person bringing up a 15 minute after getting the 5 minute signal to visually confirm at that point in time that the oscillator is above 0, and if so initiating the trade?

    If the backtester cannot accurately be used, is there anyway to test the profitability of multiple interevals using tick replay and specifying (0) and (-1) on higher level timeframes?


    Thanks.
    Last edited by demarcog; 09-30-2006, 04:16 PM.
    Glen Demarco
    [email protected]

  • #2
    Re: What is the recommended method to check higher time frame indicators using inv().

    Hello demarcog,

    Originally posted by demarcog
    As you know it's a common practice, the validity of which I was trying to ascertain recently, for traders to "check" the status of indicators in higher time frames as confirmation of signals generated in the lower time frames.


    Using a simple example of a price oscillator crossover as a trade trigger, ie., when the value of the oscillator is above zero on a 5 minute chart (closing basis).

    Before taking the trade I want to check that the price oscillator is also above zero on a 15 minute chart at the exact point in time.

    Below is an example of one technique of checking the higher interval period using (-1 )and (-2) and while this method eliminates the "forward looking" problem when backtesting (which inflates the profitability) it is based on indicator readings of "older"completed bars.
    PHP Code:

    var myStudy15 osc(10,20,false,inv(15));// 15min study
     
    if(!Strategy.isLong()){
       
      if(  
    myStudy15.getValue(-2)<&& myStudy15.getValue(-1)>0)


            
    Strategy.doLong(etc etc)
        }

    This is the correct way to code this condition for a back testing formula. What the condition simulates in back testing is a trade signal that would be evaluated at the open of a new bar, which looks for a confirmed crossing of the 0 line based on the most recently closed 15-minute bar. This would simulate a long trade on the first trade, or the open, of the newest 5 and 15 minute bar (bar 0).

    To reproduce this for real time data, the equivalent code would need to incorporate one more function, getBarStateInterval(), which specifically looks for the new bar state of the current 15-minute bar before evaluating this confirmed trade signal.

    PHP Code:
    if(myPosition != "long" && getBarStateInterval("15") == BARSTATE_NEWBAR) {
      
        if(  
    myStudy15.getValue(-2)<&& myStudy15.getValue(-1)>0) {
            
    // go long code block
            
    Alert.playSound("ding.wav");
        }


    What technique would you recommend (getSeries?)in a strategy EFS running on a 5min chart/int, to check the value of the same price oscillator value on the longer 15 minute interval?
    (similiar to a person bringing up a 15 minute after getting the 5 minute signal to visually confirm at that point in time that the oscillator is above 0, and if so initiating the trade?
    The back testing condition that you are currently using is the recommended way to do this. The getSeries() function is used to maintain the stair-stepped plot of a higher time frame series during real time analysis or to extract a specific series from an array of series returned by an efsExternal() or efsInternal() call.

    If the backtester cannot accurately be used, is there anyway to test the profitability of multiple interevals using tick replay and specifying (0) and (-1) on higher level timeframes?


    Thanks.
    Back testing cannot perform what you are trying to do here because back testing only processes completed bars. What you're describing here can only be done in real time or tick replay because the formula would need to execute on a trade-by-trade basis.

    You can only test for intra-interval 0 line crosses in real time or tick replay. You could use the paper broker to record the trading activity. However, the strategy analysis that you see in the Strategy Analyzer would need to be performed by your EFS code to generate any system statistics. What you also need to keep in mind is that the crossing of the 0 line for bar 0 of the 15-minute interval could potentially cross and uncross multiple times before the interval closes. If you don't want the trade signal from occurring each time the cross occurs add a global boolean flag and set it to true the first time the cross occurs. Then at bar state new bar for the 15-minute interval reset the boolean flag back to false. You'll also need to add a check for a false value of the boolean flag to your trade conditions, which will allow only one trade signal per 15 minute bar. These intra-bar crossings of the 0 line are sometimes referred to as false signals because there may not be a crossed condition at the close of the interval. If your formula draws shapes or some type of indication on the bar where the unconfirmed crosses occur in real time, keep in mind that reloading the formula will erase those indications. When formulas are loaded or reloaded the historical bars are only processed as completed bars so it won't be able to see those occurrences to redraw the unconfirmed events on a historical basis.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Jason,

      Thanks for you help. I thought I read in a post somewhere that I could not used tick replay, (maybe it was bar replay) for strategies using multiple symbols and multiple intervals.

      To be honest, I've must have run several hundred thousand back tests over the years and have gotten a very good "feel" for what systems do well and would like to take the few worth trading and
      move forward. If I never backtest another system it will be OK with me....(actually I'm a backtesting junkie, I cannot download an indicator from this forum or a magazine without wrapping strategy statements into it for a quick spin through the backtester).

      At this point as you mentioned, should I use the generic broker functions using the esignal paper broker as the next step toward actual automated trading?

      Interactive Brokers seems to be the most active broker used by forum members and I've seen reverence to a"demo"account. Do you know if you have to have an account with IB to use the TWS demo account facility?

      Thanks again,

      Glen
      Glen Demarco
      [email protected]

      Comment


      • #4
        Hello demarcog,

        Yes, the generic broker functions would need to be used for the paper broker and forward testing as the Strategy methods only report trades to the Strategy Analyzer.

        For the TWS demo account, you will need to contact IB directly.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment

        Working...
        X