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

[amibroker] Re: Resetting trade delays based on value of variable



PureBytes Links

Trading Reference Links

After thoroughly testing this I have come to the conclusion the
SetTradeDelays function cannot be used the change the delays based on
some condition encountered during the processing of the AFL script. I
have tested numerous configurations and can only assume that AFL can
only use a single value for trade delays and cannot process a floating
value for this setting.

Ok, I may be proven wrong on that point but one thing has become very
clear. While I tend to look for complicated solutions to simple
problems I have discovered the value of writing AFL code to look into
the past for buy/sell conditions instead of using trade delays. I can
write one version of code that checks the previous bar for a buy/sell
condition and use this to back test my ideas and fine tune
performance. Once I find something that works I just change the code
so my charts and scans show me the day the buy/signal occurs... I know
many of you have learned this lesson long ago and I really appreciate
your input in helping me to get it too.

  Pete  :-)

--- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxx> wrote:
>
> Hi Pete - If all else fails you could always delay the signals
themselves 
> ....
> 
> Buy = whatever;
> DelayedBuy1 = ref( Buy, -1 );
> DelayedBuy2 = ref( Buy, -2 );
> Buy = IIF( Cond1True, Buy, IIF( Cond2True, DelayedBuy1, DelayedBuy2 ) );
> 
> And there is always looping available for the complicated situations.
> 
> Steve
> 
> ----- Original Message ----- 
> From: "Pete" <dryheat3@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Saturday, August 16, 2008 11:38 PM
> Subject: [amibroker] Re: Resetting trade delays based on value of
variable
> 
> 
> >I have a system that can be enhanced if I can change the trading
> > delays when certain conditions are met. There must be some way in AFL
> > to set trade delays to one value for condition 'A' and then reset the
> > the trading delays when condition 'B' is met.
> > Ridiculous example:
> > SetTradeDelays(1,1,1,1);
> > BigGame = (IIF(AZ_Cardinals = Win, "Amazing", "Figures");
> > IIF(BigGame = "Amazing", SetTradeDelays((2,2,2,2),
> > SetTradeDelays(0,0,0,0);
> > Buy = <<something>>;
> > Sell = <<something else>>;
> >
> >  Pete  :-)
> >
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, dingo <dingo@> wrote:
> >>
> >> why don't you just use SetTradeDelays(0,0,0,0)  and then if you want
> > a delay
> >> add it in your code?
> >>
> >> d
> >>
> >> On Sat, Aug 16, 2008 at 10:09 PM, Pete <dryheat3@> wrote:
> >>
> >> > I spent some more time trying to work this out and could not
find some
> >> > way to verify if this is working. However, I found a much less
complex
> >> > method to apply this technique (see code below), but I still cannot
> >> > get it to do what I expect. Example: comment out the line of
code for
> >> > the SetTradeDelays and run the back test. I get slightly different
> >> > results but when I drill down into individual trades the exits are
> >> > occurring on the day of the signal whether the line of code in
place
> >> > or commented out.
> >> >
> >> > //[code]*************************************************
> >> > SetTradeDelays(0,0,0,0);
> >> > BuyPrice = Open;
> >> > SellPrice = Open;
> >> >
> >> > Buy = <<insert buy rule here>>
> >> > fltr = <<some test value to see if delays should be adjusted>>
> >> >
> >> > tstDly = WriteIf(fltr == 1 , "1", "0");
> >> > SetTradeDelays(0, 0, StrToNum(tstDly) , StrToNum(tstDly) );
> >> >
> >> > sell = <<insert sell rule here>>
> >> > //[/code]************************************************
> >> >
> >> >  Pete  :-)
> >> >
> >> > --- In amibroker@xxxxxxxxxxxxxxx, "Pete" <dryheat3@> wrote:
> >> > >
> >> > > Just wondering if this is even possible. I checked the AFL help
> > files,
> >> > > searched the online AFL Formula reference and also searched this
> > yahoo
> >> > > group. Every example only shows the SetTradDelays() function
being
> >> > > used one time in the code and never 'adjusted' to some other
value
> >> > > based on a condition. I created this function which seems to me
> > should
> >> > > work correctly but I have no way to really be sure it's
working as
> >> > > designed. I am using the printf() function several times to keep
> > track
> >> > > of different values during bar replay, (thanks to Razzbarry),
but I
> >> > > can't find a way to print the values of the trade delays to the
> > output
> >> > > window.
> >> > > //[code]*************************************************
> >> > > SetTradeDelays(0,0,0,0);
> >> > > BuyPrice = Open;
> >> > > SellPrice = Open;
> >> > >
> >> > > Buy = <<insert buy rule here>>
> >> > > fltr = <<some test value to see of delays should be adjusted>>
> >> > > function dly()
> >> > > {
> >> > >       if (fltr == 1)
> >> > >       SetTradeDelays(0,0,1,1);
> >> > >       else
> >> > >       SetTradeDelays(0,0,0,0);
> >> > > }
> >> > > sell = <<insert sell rule here>>
> >> > > //[/code]************************************************
> >> > >
> >> > > The goal here is to change the trade delays to 0,0,1,1 only
if the
> >> > > fltr variable returns a true value of 1.
> >> > > Thanks for taking the time to check this out.
> >> > >
> >> > >   Pete  :-)
> >> > >
> >> >
> >> >
> >> >
> >> > ------------------------------------
> >> >
> >> > 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> >> > http://www.amibroker.com/devlog/
> >> >
> >> > For other support material please check also:
> >> > http://www.amibroker.com/support.html
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> > ------------------------------------
> >
> > 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > Yahoo! Groups Links
> >
> >
> >
> >
>



------------------------------------

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/