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

[amibroker] Re: Setup for Forex backtesting



PureBytes Links

Trading Reference Links

You can use ExRem function to remove multiple buy sell signals.

Buy = ExRem(Buy,Sell);

Sell = ExRem(Sell,Buy);

Short = ExRem(Short,Cover);

Cover = ExRem(Cover,Short);

rgds, Pal
--- In amibroker@xxxxxxxxxxxxxxx, "pip_hunter_2003" 
<pip_hunter_2003@xxxx> wrote:
> After more deeply investigation I found a Flip() command. Here is 
the 
> more shortened version BUT anyway it does not work. The LongOpen 
and 
> ShortOpen are allways 0 (there is many Buy and Sell signals).
> 
> I decided to put the whole testing script so you can see the whole 
> picture:
> 
> --- start of the clip ---
> 
> // -----------------------------------------------------------------
> // Calculate a signal point
> // -----------------------------------------------------------------
> SignalPeriod = Optimize("SignalPeriod", 60, 10, 100, 1);
> SignalLine = ComplexProprietaryFunction(SignalPeriod);
> 
> // -----------------------------------------------------------------
> // Resolve the status of current position
> // -----------------------------------------------------------------
> Buy = Sell = Short = Cover = 0;
> LongOpen = Flip(Buy, Sell OR Short OR Cover);
> ShortOpen = Flip(Short, Sell OR Buy OR Cover); 
> NoOpenPos = NOT (LongOpen OR ShortOpen);
> 
> // -----------------------------------------------------------------
> // Buy if HI hits the signal line, Short if LOW hits the signal line
> // -----------------------------------------------------------------
> Buy = IIf(NoOpenPos, Cross(High, SignalLine), 0);
> Sell = IIf(LongOpen, Cross(SignalLine, Low), 0);
> Short = IIf(NoOpenPos, Cross(SignalLine, Low), 0);
> Cover = IIf(ShortOpen, Cross(High, SignalLine), 0);
> 
> --- end of the clip ---
> 
> Jan
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "pip_hunter_2003" 
> <pip_hunter_2003@xxxx> wrote:
> > Ummm... There was an error in my clipped script here is the 
correct 
> > one,
> > 
> > --- start of clip ---
> > 
> > // Initialize the trade commands
> > Buy = Sell = Short = Cover = 0;
> > 
> > // Count the bars since last command
> > Bu = BarsSince(Buy);
> > Se = BarsSince(Sell);
> > Sh = BarsSince(Short);
> > Co = BarsSince(Cover);
> > 
> > // Find out the status of latest position
> > LongOpen = (Bu < Se) AND (Bu < Sh) AND (Bu < Co);
> > ShortOpen = (Sh < Se) AND (Sh < Bu) AND (Sh < Co);
> > NoOpenPos = IIf(LongOpen + ShortOpen, 0, 1);
> > 
> > --- end of clip ---
> > Jan
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "pip_hunter_2003" 
> > <pip_hunter_2003@xxxx> wrote:
> > > Thank you very much for your reply. I think this can help me in 
> > many 
> > > ways.
> > > 
> > > Also after reading more carefully the AFL manual I found the 
> > function 
> > > BarsSince(). I think that by this function I can see the status 
> (is 
> > > it long or short) of my latest position but I cannot get it 
work 
> > > correctly (maybe I am missing the nature of this function?!). 
> > > 
> > > Could you possible (or somebody else) check what is wrong with 
my 
> > > following formulas in my backtesting script,
> > > 
> > > --- start of clip ---
> > > 
> > > // Initialize the trade commands
> > > Buy = Sell = Short = Cover = 0;
> > > 
> > > // Count the bars since last command
> > > Bu = BarsSince(Buy = 1);
> > > Se = BarsSince(Sell = 1);
> > > Sh = BarsSince(Short = 1);
> > > Co = BarsSince(Cover = 1);
> > > 
> > > // Find out the status of latest position
> > > LongOpen = (Bu < Se) AND (Bu < Sh) AND (Bu < Co);
> > > ShortOpen = (Sh < Se) AND (Sh < Bu) AND (Sh < Co);
> > > NoOpenPos = IIf(LongOpen + ShortOpen, 0, 1);
> > > 
> > > --- end of clip ---
> > > Jan
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Pal Anand" <palsanand@xxxx> 
> > wrote:
> > > > /* in Indicator Builder after running the back-test to see 
the 
> > > chart 
> > > >  of the number of Open long and short positions of your 
system. 
> > Use 
> > > > the following code: */
> > > > 
> > > > Graph1 = Foreign( "~OpenLongPosCount", "V"); 
> > > > //Plot(Graph1,"OpenLongPosCount",1,style=1,0,20);
> > > > Graph2 = Foreign( "~OpenShortPosCount", "V"); 
> > > > //Plot(Graph2,"OpenShortPosCount",2,style=1,0,20);
> > > > //Plot(5,"MaxOpenPos",colorYellow);
> > > > 
> > > > rgds Pal


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
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/