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

[amibroker] Optimisation Problems



PureBytes Links

Trading Reference Links

Been bashing my head against the proverbial brick wall for a couple 
of days now.

I'm trying to test 3 different exit strategies using the Optiniser.

The Optimiser runs 3 times but gives the same number of trades and 
the same profit - should not be possible, so I am obviously missing 
something in the logic.

Testing against ASX300 for 2000 - 2007.

See relevant code below.  Any help please.

Graham

vaIsValidSignal = BuyLongTrig == True
					AND PriceGate == True
					AND MFGate == True;
vaBgColour = IIf(vaIsValidSignal == 0, BkGndColor, colorOrange);

//vEntry = 3;	
vEntry = Optimize("Entry Strategy", 1,1, 3, 1);
vTime = 1;	
//vTime = Optimize("Time Exit Strategy", 1,1, 2, 1);

switch(vEntry)	// Entry Strategies
{
	case 1:	//Stop entry next bar at signal bar High
			vaEntryPrice = Ref(High, -1);
			Buy = Ref(vaIsValidSignal,-1) AND High >= 
vaEntryPrice;
			BuyPrice = Max(Open, vaEntryPrice);
	case 2:	//Stop entry next bar at signal bar Close
			vaEntryPrice = Ref(Close, -1);
			Buy = Ref(vaIsValidSignal,-1) AND High >= 
vaEntryPrice;
			BuyPrice = Max(Open, vaEntryPrice);
	case 3:	//Enter at next bar Open
			vaEntryPrice = Open;
			Buy = Ref(vaIsValidSignal,-1);
			BuyPrice = Open;
}

Sell = 0;

vaTrailStop = Null;
vaSellStop =  0;
vaSellTarget = 0;
vATRMult = 0;
//vATRMult  = Optimize("ATR Multiplier", 0, 0, 2, 0.2);
vATRPer = 5;
//vATRPer  = Optimize("ATR Period", 5, 5, 20, 5);
VEntryBar = 0;
vTempStop = 0;
vaInitStop = EMA(Open, MAPd) - (vAtrMult * ATR(vATRPer));
vTimeStop = 5;
//vTimeStop = Optimize("Time Stop", 7, 5, 10, 1);
vTrigger = 0;

for(vCnt = 1; vCnt < BarCount; vCnt++)
{
	if(vTempStop == 0
		AND Buy[vCnt] == 1)	// Entry Bar & 0 positions 
open
	{
		// Position Opened		
		vTempStop = vaInitStop[vCnt - 1];
		vEntryBar = vCnt;
	}
	else
	{
		Buy[vCnt] = 0;	// Remove excess Buy signals
	}	// Not Entry Bar

	if(vTempStop > 0)
	{
		if ((vCnt - vEntryBar) - 1 == vTimeStop)	// 
need -1 so that stop is adjusted the bar after vTimeStop is reached
		{	// test # Bars Open
			switch(vTime)	// BreakEven/Exit Strategies
			{
				case 1:	// Move stop to entry price
						vTempStop = Max
(vTempStop, BuyPrice[vEntryBar]);
				case 2:	// Move stop to entry price 
if Close > entry price
						if (Close[vCnt] > 
BuyPrice[vEntryBar])
						{
							vTempStop = 
Max(vTempStop, BuyPrice[vEntryBar]);
						}
			}			
		}	// Position Open & not Entry Bar
		
		vTempStop = Max(vaInitStop[vCnt - 1], vTempStop);
		vaTrailStop[vCnt - 1] = Max(vaTrailStop[vCnt - 1], 
vTempStop);		
		if(Low[vCnt] <= vaTrailStop[vCnt - 1])
		{
			Sell[vCnt] = 1;
			SellPrice[vCnt] = Min(Open[vCnt], vaTrailStop
[vCnt - 1]);
			vTempStop = 0;
		}	
//_TRACE("Bar " + BarIndex() + " Buy " + Buy + " Sell " + Sell + " 
Target " + vaTargetVal + " Stop " + vTempStop);
	}	// Position Open
}	// for



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

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/