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

[amibroker] Filter / Permission Switch


  • Date: Thu, 04 Feb 2010 18:04:13 -0000
  • From: "venturerider2" <venturerider2@xxxxxxxxx>
  • Subject: [amibroker] Filter / Permission Switch

PureBytes Links

Trading Reference Links

Any advice would be greatly appreciated.

I am trying to code a basic permission switch that remains on (1) when a specific condition is met and remains on even though that condition no longer exists, until a different condition changes it. 
I tried the following but could not get it to work properly.

/* Parameters for Bolinger band top and bottom would precede this. */
 
//  Permission Switch
/* Permit a Long entry when the EMA crosses above the Bollinger Band Top.  Permit only long entries until EMA crosses below Bollinger Band Bottom, and then permit only short entries.  Then permit only short entries until EMA crosses back above BBTop, etc. */

/* Parameters for Bolinger band top and bottom would precede this. */

PermitLong = Cross (EMA (C,  3), BBTop; // set the switch to Long 
PermitShort = Cross (EMA (C, 3), BBBot ;// set the switch to Short

Flip(PermitLong, PermitShort);
Flip(PermitShort, PermitLong);

Plot(PermitLong, "PermitLong", colorRed, styleOwnScale); 
Plot(PermitShort, "PermitShort", colorBlue, styleOwnScale);

/*  So I notice when I run the backtest that the switching plots look fine.  The plots show that when a PermitLong condition occurs and generates a 1, it stays at 1 until a PermitShort condition occurs.  Then PermitShort remain at 1 until a PermitLong condition returns, etc. The plots show two square waves oscillating between 0 and 1 at the appropriate times of the breakouts/breakdowns.  So far so good.

Then when I combine any trading system with the switches, they do not work properly.    For simplicity lets just use the following:

Buy = C > Ref(C, -1)  AND PermitLong;
Sell = BarsSince(Buy) >=3;
Short = C < Ref (C, -1)  AND PermitShort ;
Cover = BarsSince(Short) >=3;

It will allow short trades during both PermitLong and PermitShort and will do the same for long trades.  I think it may be the way I am using Flip.

I am open to doing this without Flip -  whatever works.

I do not want PermitLong and NOT(PermitLong) since sometimes my parameters may allow trading in both directions.  So I like having separate switches.

Thanks for any help,

Joe




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

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/