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

[amibroker] Simple MA system backtesting



PureBytes Links

Trading Reference Links

I would really appreciate some suggestions or ideas. 
My system is very simple, one long MA, one short MA. Buy retracements 
below the short MA in an uptrend (shortMA>longMA), opposite for a 
downtrend.
I have a loop for entering and exiting the position - see below.

My question is - How can I enter only the first retracement to the 
short MA and ignore the rest of the waves in a trend? As is, I get 
few entries (and exits). 

Thank you,
Chris


for (i = 1; i < BarCount; i++) 
{
        if (EntryLongSignal[i-1]) 
        {
                Buy[i] = 1;
                BuyPrice[i] = O[i];
				  				  
				                  
            for (j = i; j < BarCount; j++) 
                {
                  if (j > i)
                  Buy[j] = 0;
								
							
							// Calc stop
							 if (j == i)
                           StopLong = BuyPrice[i] - StopLoss;

                			else if (L[j] <= StopLong) // 
Check stop
                                {
                                        Sell[j] = 1;
                                        SellPrice[j] = StopLong;
								
			  StopLong = Null;
								
			  i = j;
                                        break;
                                } 
                         else if (H[j] >= BuyPrice[i] + 
TakeProfit) // Check take profit
                                {
                                         Sell[j] = 1;
                                         SellPrice[j] = BuyPrice[i] + 
TakeProfit;
                                         StopLong = Null;
								
				i = j;
                                         break;
								
	  }
							 else if (j 
== BarCount - 1) 
                                  {
                                          StopLong = Null;
								
				 i = j;
                                          break;
                                  }
                }
  		}
}
  



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

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

*********************
TO GET TECHNICAL 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/