Skip to main content

RF Mello for Amibroker (AFL)

MelloTrader about 13 years ago Amibroker (AFL)

  • Rating:
    2 / 5 (Votes 5)
  • Tags:
    trading system, amibroker, exploration

This setup has small targets. You can optimize it. We have large number of winning trades.

Screenshots

Indicator / Formula

Copy & Paste Friendly
// RF Setup by Mello



_SECTION_BEGIN("Price");

SetChartOptions(0,chartShowArrows|chartShowDates);

SetBarsRequired(sbrAll,sbrAll);

SetBarFillColor(IIf(C>O,ParamColor("Bar Up Color", colorBrightGreen),IIf(C<=O,ParamColor("Bar Down Color", colorRed),colorLightGrey)));

Plot(C,"Close",IIf(C>O,ParamColor("Shadow Up Color", colorWhite),IIf(C<=O,ParamColor("Shadow Down Color", colorWhite),colorLightGrey)),64,0,0,0);

SetChartBkColor(ParamColor("Panel Color ",colorDarkGrey));

SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkGrey),ParamColor("Lower Chart",colorDarkGrey));

GraphXSpace=Param("GraphXSpace",20,-10,25,1);

//SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

 

_SECTION_BEGIN("Cálculo EMA");



prd01 = Optimize("Periodo", 9, 5, 34, 2);
EMA17 = EMA(C,prd01);
Cond1 = IIf(EMA17 >= Ref(EMA17, -1), 1, 0);
Plot( EMA17, "EMA17" ,ParamColor( "Color1", colorRed ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );

_SECTION_END();



_SECTION_BEGIN("Cálculo RF");


Cond2 = IIf(Ref(Close, -3) < Ref(Open, -3), 1, 0);
Cond3 = IIf(Ref(Close, -2) > Ref(Open, -2), 1, 0);
Cond4 = IIf(Ref(Close, -1) < Ref(Open, -1), 1, 0);

Cond5 = (Cond2 + Cond3 + Cond4);

Cond6 = Cond1 + Cond5;

precomax = Ref(HHV(H,3),-1); 
Precomin = Ref(LLV(L,3),-1);

Resistencia = ValueWhen(Cond6 ==4 , Precomax, 1);
Suporte = ValueWhen(Cond6 ==4 , Precomin, 1);
Distancia = ValueWhen(Cond6 ==4 , precomax - Precomin, 1);

alvo1 = Optimize("alvo1", 1.5, 1,3, 0.2);

Alvo = resistencia + (distancia * alvo1);


_SECTION_END();



_SECTION_BEGIN("Comprar/Vender");




Buy = Cond1 == 1 AND Cross(High, Resistencia);

BuyPrice = Resistencia ;
Preco = ValueWhen(Buy, resistencia, 1);
Venda = ValueWhen(Buy, alvo, 1);
Stope = ValueWhen(Buy, Suporte, 1);
Sell = Cross(High, Venda) OR Cross(stope, Low);
SellPrice = IIf(Cross(High, Venda), Venda, stope);

Buy=ExRem(Buy,Sell);

Sell=ExRem(Sell,Buy);


shape = Buy * shapeUpArrow + Sell * shapeDownArrow;

PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-5);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-10);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-7.5);

PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=10);

PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=15);

PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-12.5);

Plot(Venda, "Target", colorGreen, styleLine, Null, Null, 0, 0, 1);
Plot(Stope, "Stop", colorRed, styleLine, Null, Null, 0, 0, 1);
Plot(Preco, "Compra", colorWhite, styleLine, Null, Null, 0, 0, 1);




 

 

 



AddColumn( Buy, "Buy", 1);

AddColumn(Sell, "Sell", 1);

AddColumn(Close,"Close",1.2);

AddColumn(Volume,"Volume",1.0);

 

 



 // trade size: 100% of current portfolio equity
SetPositionSize( 5, spsPercentOfEquity );

8 comments

1. Divyesh
about 13 years ago

Nice code….!!

excellant results with 15 min TF and after modificaton……!!!

Thanx alot Mello Treader………….!!!

XXX

about 13 years ago

really good one thank to the coder ..@ TNSuresh, where saying “to much argument” delete one zero out of two..

about 13 years ago

Hi Mello,

Cooud you give us an explanation about your setup?

Thanks in advance.

about 13 years ago

Nice afl but it seems that the formula references FUTURE quotes.
If you backtest this system you may receive outstanding results
that CAN NOT be reproduced in real trading.

about 13 years ago

This afl can be improved. I do not have much knowledge about Amibroker programming. Basically this setup is based on observing 3 candles:
Situation 1 – Red (open > close) + Green (close > open) + Red (open > close)
and EMA higher than previous candle ==> BUY price cross highest this formation or
Situation 2 – Green (close > open) + Red (open > close) + Green (close > open)
and EMA lower than previous candle ==> SELL price cross lowest of this formation(not included in this afl).
The Target between 1-3 times the amplitude of this formation as much in order BUY or SELL mode.
Appearing the condition 1 and with the EMA continues upping, the purchase point does not change and can happen after several candles.
Appearing the condition 2 and with the EMA continues downwing, the selling point does not change and can happen after several candles(not included in this afl).
Suggestions for improvement in this setup are welcome.
Setup to be worked on frames exceeding 60 minutes

Sorry my English, I hope to help you.

Leave Comment

Please login here to leave a comment.