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

Re: [amibroker] Simple TRIX Crossover system question



PureBytes Links

Trading Reference Links


Pal,
 
Here's the code to do what you've asked.  Regarding a diversified group of futures markets, you'll have to optimize on the markets you want to trade.  I've built in the ability to optimize the params.
 
You could via positionscore trade  basket of futures via some scoring routine in addition to their respective buy/sell signals.
 
The big problem is you may want to look at the Trixline values.  They are all smaller than 1 which means that shorts are impossible with the criteria you've listed below.
 
Take a look at get back to us.  It seems like a promising idea, and I'll be happy to adjust the code based on what you find.
 
Warmest,
Gary
 
CODE BELOW:
 

//PARAMS
period1 = Optimize("Period 1", 9, 3, 13, 1);
period2 = Optimize("Period 2", 50, 21, 62,1);
period3 = Optimize("Period 3",80,62,233,1);
//C = Foreign("COMPQX", "C");
//INDICATORS
Trixline1=TEMA(TEMA(TEMA(ROC(C, 1), period1), period1), period1);
Trixline2=TEMA(TEMA(TEMA(ROC(C, 1), period2), period2), period2);
Trixline3=TEMA(TEMA(TEMA(ROC(C, 1), period3), period3), period3);
//ESTABLISH STATES
BuySTATE = TrixLINE1 > TrixLINE2 AND C > TrixLINE3;
SellSTATE = TrixLINE1 < TrixLINE2 AND C > TrixLINE3; 
ShortSTATE = TrixLINE1 < TrixLINE2 AND C < TrixLINE3;
CoverSTATE = TrixLINE1 > TrixLINE2 AND C < TrixLINE3;
//ESTABLISH SIGNALS
Buy = Flip(BuySTATE,SellSTATE);
Sell = NOT Buy;
Short = Flip(ShortSTATE,CoverSTATE);
Cover = NOT Short;
//EXREM
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);
//STOPS
ApplyStop( stopTypeProfit, stopModePercent, 30, ExitAtStop = True, Volatile = False, ReentryDelay = 0 );
ApplyStop( stopTypeTrailing, stopModePercent, 20, ExitAtStop = True, Volatile = False, ReentryDelay = 0 );
Equity(1); // THIS EVALUATES STOPS
//INDICATOR SECTION BEGINS
Plot(Trixline1, "TRIX", colorBlue, styleHistogram);
Plot(Trixline2, "TRIX", colorYellow, styleHistogram);
Plot(Trixline3, "TRIX", colorGreen, styleHistogram);
PlotShapes(shapeUpArrow * Buy,colorBrightGreen,0,TrixLINE1, -10); //BUY ARROW
PlotShapes(shapeDownArrow * Short,colorRed,0,TrixLINE1, 10); //SHORT ARROW
Title = Name() + ": " + Date() + " Open " + WriteVal(O,1.4) + " Hi " +WriteVal(H,1.4) + 
" Lo " + WriteVal(L,1.4) + " Close " + WriteVal(C,1.4);
//INTERPRETATION WINDOW ANALYSIS
"The bmTRIX is indicating a " + WriteIf(Trixline1 > Trixline2 AND C > TrixLine3, "bullish", "bearish") +
" market environment because it is " + WriteIf(TrixLine1 > Trixline2 AND C < TrixLine3, "above", "below") +
" the zero line.\n";
 
palsanand <palsanand@xxxxxxxxx> wrote:
1. Start with a simple moving average crossover (nine-day and 50-day) 2. Refinement 1: Add a third moving average (80-day) as a filter.Apply the indicator using the following rules: 1. Go long when 9d > 50d and close > 80d 2. Go flat when 9d < 50d and close > 80d 3. Go short when 9d < 50d and close < 80d 4. Go flat when 9d > 50d and close < 80d 5. Refinement 2: Trade a diversified group of futures markets.How do I modify the code below to adhere to the rules above and how do I get sell signal arrows on the graph?period1 = 9;period2 = 50;period3 = 80;//C = Foreign("COMPQX", "C");Trixline1=TEMA(TEMA(TEMA(ROC(C, 1), period1), period1), period1);Plot(Trixline1, "TRIX", colorBlue, styleHistogram);Trixline2=TEMA(TEMA(TEMA(ROC(C, 1), period2), period2),
 period2);Plot(Trixline2, "TRIX", colorYellow, styleHistogram);Trixline3=TEMA(TEMA(TEMA(ROC(C, 1), period3), period3), period3);Plot(Trixline3, "TRIX", colorGreen, styleHistogram);Cond1 = C > TrixLine3;Cond2 = C < TrixLine3;"The bmTRIX is indicating a " +WriteIf(Trixline1 > Trixline2 AND C > TrixLine3, "bullish", "bearish") +" market environment because it is " +WriteIf(TrixLine1 > Trixline2 AND C < TrixLine3, "above", "below") +" the zero line.\n";Buy = Cover = Cross( TrixLine1,TrixLine2 ) AND (C > TrixLine3);Sell = Short = Cross( TrixLine2,TrixLine1 ) AND (C < TrixLine3);shape = Buy * shapeUpArrow + Sell * shapeDownArrow;PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen,0,Graph1,-15); PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,Graph1,-15); //PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);//PlotShapes(IIf
 (Sell,shapeDownArrow,shapeNone),colorRed);GraphXSpace=10; //Sell = 0 ; // exit only by stopsApplyStop( stopTypeProfit, stopModePercent, 30, ExitAtStop = True, Volatile = False, ReentryDelay = 0 );ApplyStop( stopTypeTrailing, stopModePercent, 20, ExitAtStop = True, Volatile = False, ReentryDelay = 0 );Equity(1); // THIS EVALUATES STOPSTitle = Name() + ": " + Date() + " Open " + WriteVal(O,1.4) + " Hi " +WriteVal(H,1.4) + " Lo "+WriteVal(L,1.4) + "  Close " + WriteVal(C,1.4);//Plot(Sell==4,"ApplyStop Sell",colorRed,1|styleOwnScale);//Plot(Cover==4,"ApplyStop Cover",colorGreen,1|styleOwnScale); rgds, PalSend BUG REPORTS to bugs@xxxxxxxxxxxxxSend 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 Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
Do you Yahoo!?
Free Pop-Up Blocker - Get it now






Yahoo! Groups Sponsor


  ADVERTISEMENT 









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



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.