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

Re: [amibroker] Using timeframeset with looping code



PureBytes Links

Trading Reference Links

Graham,

I do this same task and it works OK for me.

First I do TimeFrameSet(inWeekly) and do some trend calculations.
Then I save weekly values into arrays.
Then I do TimeFrameExpand( x, inWeekly, expandPoint) which serves my purpose
and gives Empty values for all days except Friday.
Then I loop through those values to determine my weekly trend.
I really donıt see why youıre gettng empty values since the default
expansion is expandLast which puts Fridayıs close into every day of the
week.

Hereıs that section of code:

/*   Find Weekly Trend   */
 
wc = TimeFrameCompress(C,inWeekly); //Get weekly values
 
//Initialize trend 1 = Long, 0 = No change, -1 = Short
trend = IIf(wc> Ref(wc,-1) AND wc> Ref(wc,-2),1,IIf(wc< Ref(wc,-1) AND wc <
Ref(wc,-2),-1,0));
wc = TimeFrameExpand(wc,inWeekly);
trend = TimeFrameExpand(trend,inWeekly,expandPoint); //Just the last day of
the week
wtrend = trend; //Just for visual confirmation
//Now, if the current week is not over, neutralize the trend status
//This is necessary as Amibroker thinks the current day is the close of the
week.
if (NOT EOW[BarCount-1] AND NOT expiry[BarCount-1]) trend[BarCount-1] = 0;

/*   Make daily trend signals and Confirm all trend changes   */
 
Confirm = False;
for( i = 3; i < BarCount; i++ )
{ //if no profit by 2nd day, reverse trend
     if (Confirm[i-2] AND (NDXc[i] - wc[i])*trend[i-1] < 0)
     {    
          trend[i] = trend[i-1]*-1;
          Confirm[i] = False;
     }
     else
     { //if no trend change, continue prior trend. If needed Confirm -3 days
insures we continue whatever was decided above at -2
          if (Confirm[i-3] OR trend[i] == 0 OR IsNull(trend[i]))
          {
               trend[i] = trend[i-1]; //Continue the trend
               Confirm[i] = False; //Turn confirm signal off
          }
          else
          { //if Trend changed (values of -1 + 1 or 1 + -1) trend value is
OK as is (from weekly)
               if (trend[i] + trend[i-1] == 0)
                    Confirm[i] = True; //Flag the change
          }
     }
}

-- 
Terry


From: kaveman perth <kavemanperth@xxxxxxxxx>
Reply-To: amibroker@xxxxxxxxxxxxxxx
Date: Sun, 10 Oct 2004 18:41:51 +0800
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Using timeframeset with looping code

I cannot seem to get the timeframeset to work with any code that contains
loops.
I want to explore on weekly values for setups, then trade on daily
values breaking the weekly setups. This is especially important as I
am trying to backtest for this code. Rather than post a long code that
would take time to work through I have put together a simple formula
that will return the highest close, just purely as an example. I can
get values if I set the AA settings to weekly, but if put to daily I
get empty cells in the exploration.
Can someone help me on how to get this to work

TimeFrameSet(inWeekly);
x[0]=C[0];
for(i=1;i<BarCount;i++)
{ if(C[i]>x[i-1])
{ x[i]=C[i];
}
else
{ x[i]=x[i-1];
} }
TimeFrameRestore();

xx = TimeFrameExpand( x, inWeekly );

Filter=1;
AddColumn(C,"close",1.3);
AddColumn(x,"x",1.3);
AddColumn(xx,"xx",1.3);

-- 
Cheers
Graham
http://e-wire.net.au/~eb_kavan/


Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html


Yahoo! Groups Sponsor
 
 ADVERTISEMENT
 <http://us.ard.yahoo.com/SIG=12997ege5/M=295196.4901138.6071305.3001176/D=g
roups/S=1705632198:HM/EXP=1097491313/A=2128215/R=0/SIG=10se96mf6/*http://com
panion.yahoo.com>  


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
<mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
*  
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .




[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/