[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Multiple TimeFrame and Plot tape help please.



PureBytes Links

Trading Reference Links

Hi I am trying to combine daily and weekly Ehlers' Instant Indicator
in the same tape plot but not sure why it does not plot properly. 
Please help, below are the code: TIA

SetBarsRequired(200000, 200000);

// Ehlers ITrend
// from Ehlers, John F. Cybernetic Analysis for Stocks and Futures.
Wiley. 2004. 
// Chapter 3, p. 21. Code on p. 24.
//#include_once "c:/program
files/Amibroker/formulas/Include/EhlersInclude.afl"
//#include_once "c:/program
files/Amibroker/formulas/Include/CommonInclude.afl"


function ITrend(array, alpha)
{
  // initialize early array values and declare as array
  //it = array;

  //it = (array[2] - 2*array[1] + array[0])/4; This initialization
takes a long time to converge.
  
  for ( i=0; i < BarCount; i++ ) {
    if ( i < 2 )
      it[i] = 0;
    else if ( i >=2 && i < 6 )
      it = (array[i] + 2*array[i-1] + array[i-2]) / 4;
//  }

//  for(i = 7; i < BarCount; i++) { 
    else if ( i >= 7  ) 
      it[i] = (alpha - alpha*alpha/4)*array[i]
              + 0.5*alpha*alpha*array[i-1] - (alpha -
0.75*alpha*alpha)*array[i-2]
              + 2*(1 - alpha)*it[i-1] - (1 - alpha)*(1 - alpha)*it[i-2];
  }
  return it;
}

function ITrendTrigger(array)
{
  trigger = 2*array - Ref(array, -2);
  return trigger;
}

delay = Param ("delay", 0, -5, 5, 1);

Davg = (H+L)/2;

// Instantaneous Trend
Dtrend     = ITrend(Davg, .07);
DtrendTrig = ITrendTrigger(Dtrend);

TimeFrameSet (inWeekly);
Wavg = (H+L)/2;

// Instantaneous Trend
Wtrend     = ITrend(Wavg, .07);
WtrendTrig = ITrendTrigger(wtrend);
TimeFrameRestore();

wtrend     = TimeFrameExpand ( Wtrend ,     inWeekly );
wtrendTrig = TimeFrameExpand ( WtrendTrig , inWeekly );

/* plot color ribbon */ 
Plot( 7, "", IIf(Wtrend - WtrendTrig < 0 AND Dtrend - DtrendTrig < 0 ,
colorGreen ,
             IIf(Wtrend - WtrendTrig > 0 AND dtrend - DtrendTrig < 0 ,
colorYellow ,
             IIf(Wtrend - WtrendTrig > 0 AND Dtrend - DtrendTrig > 0 ,
colorRed , colorBlueGrey ))), styleArea | styleOwnScale |
styleNoLabel, 0, 10 );





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/