Help me to create Amibroker AFL use with my formula

#31
Dear Nagarjuna,
I am also waiting for this.:rolleyes:

Hi Smarttrade,

How are you? I am sorry that I could not reply early. Awfully busy these days. Apart from that, the reason I did not reply is that I feel that this requirement is unnecessary. Couple of points.

1. I dont think ami can place orders automatically.
2. It is obvious that we can ignore signals 30 minutes prior to market close.

Please let me know if you still need this. I will try. Take care.

thank you
nagarjuna
 
#33
Dear Nagarjuna,

I added this below lines . Now its showing correctly.

Datefine = IIf(Ref(DateNum(),1) == Ref(DateNum(),-1),1,0);
BuyV = uptrend AND Ref(uptrend, -1) AND (H > ( Ref(H, -1) +5)) AND Datefine;
SellV = downtrend AND Ref(downtrend,-1) AND (L < ( Ref(L, -1) - 5)) AND Datefine;
did you mean to use <> instead of ==?
 
#34
Dear Nagarjuna,
Thank you for your reply. It must require to Backtest Purpose.
Here it is.

// Logic for uptrend or downtrend
k = EMA(StochK(39,3),3);
d = EMA(StochD(39,3,3),3);
uptrend= IIf( k > d, 1, 0 );
downtrend=IIf( k < d, 1, 0 );

// The current bar should be more than previous bar value + 5 points for buy in uptrend
BuyV = uptrend AND Ref(uptrend, -1) AND (H > ( Ref(H, -1) + 5));
// the current bar should be less than previous bar value - 5 points for sell in downtrend
SellV = downtrend AND Ref(downtrend,-1) AND (L < ( Ref(L, -1) - 5));

// Bars since previous buy or sell signal.
BuySB = BarsSince(Ref(BuyV,-1));
SellSB= BarsSince(Ref(SellV,-1));

// Ignore the previous day bar
Datefine = IIf(Ref(DateNum(),1) == Ref(DateNum(),-1),1,0);
//Datefine = 1;

// Check if it is time to close the postions.
EOD = iif(timenum() < 153000, 0, 1);
noEOD = iif(timenum() < 153000, 1, 0);

// We can signal buy only if previous signal was a sell.
Buy = BuyV AND BuySB > SellSB AND Datefine AND noEOD;
// We can signal sell only if previous signal was a buy.
Short = SellV AND BuySB < SellSB AND Datefine AND noEOD;
Cover = EOD AND BuySB > SellSB;
Sell = EOD AND BuySB < SellSB;

_SECTION_BEGIN("Smart Trader");

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() );

PlotShapes( shapeUpArrow * Buy, colorGreen,0,L,-12);
PlotShapes( shapeDownArrow * Short, colorRed,0,H,-12);

_SECTION_END();
 
#35
Dear Nagarjuna,

THANKS, THANKS, THANKS a LOT for your help :clapping:.

Jus Now I saw your Reply. I tried to Backtest this AFL. Now Close value is taking correctly @ 3.30 Bar close Value. But it Take Buy (Long) Trade value at Buy Bar Close Value in BackTest Report. as same as sell Also.

Example :-

1. if we get Buy signal (Pre.Bar High + 5 points). Assume pre.Bar high = 5000, Next bar high = 5010 and close = 4995. Our Buy Value is 5005. But Backtest Report Take Buy Value is that bar close value (4995).

2. If we get sell signal (pre.bar low - 5 points). Assume Pre.Bar Low = 5000, Next bar low = 4090 and close = 4085. Here our Sell value is 4095. But Backtest Report Take Sell Value is 4085 (Close) value.

How do correct this ?
 
#36
Dear Nagarjuna,

THANKS, THANKS, THANKS a LOT for your help :clapping:.

Jus Now I saw your Reply. I tried to Backtest this AFL. Now Close value is taking correctly @ 3.30 Bar close Value. But it Take Buy (Long) Trade value at Buy Bar Close Value in BackTest Report. as same as sell Also.

Example :-

1. if we get Buy signal (Pre.Bar High + 5 points). Assume pre.Bar high = 5000, Next bar high = 5010 and close = 4995. Our Buy Value is 5005. But Backtest Report Take Buy Value is that bar close value (4995).

2. If we get sell signal (pre.bar low - 5 points). Assume Pre.Bar Low = 5000, Next bar low = 4090 and close = 4085. Here our Sell value is 4095. But Backtest Report Take Sell Value is 4085 (Close) value.

How do correct this ?
Do you want to check this?

 
#38
Respected Member Of trader Ji

Plz help me ..i hv my parameters dnt knw how to genrate afl for that ..
plz if posble make a afl code for ths

if It close is abv bolinger band thn sell indicatr shuld apper n if close in below bband thn buy indicator...in mesh a fibonaci retracment in it also


Regards
 
#39
Hello seniors...
plz add buy & sell indicator n alerts in ths formula

barvisible = Status("barvisible");
r = RSI( 14 );
maxr = LastValue( Highest( IIf( barvisible, r, 0 ) ) );
minr = LastValue( Lowest( IIf( barvisible, r, 100 ) ) );
ranr = maxr - minr;
Plot( r, "RSI(14)", colorRed );
Plot( maxr , "0%", colorGrey50 );
Plot( maxr - 0.236 * ranr, "-23.6%", colorPaleGreen );
Plot( maxr - 0.382 * ranr, "-38.2%", colorPaleBlue );
Plot( maxr - 0.50 * ranr, "-50.0%", colorOrange );
Plot( maxr - 0.618 * ranr, "-61.8%", colorPaleBlue );
Plot( minr , "-100%", colorGrey50 );
GraphXSpace = 3;

Buy whn rsi touches ""Plot( minr , "-100%", colorGrey50 ); "" ths line
Sell whn Rsi touches ""Plot( maxr , "0%", colorGrey50 ); ""

Hoping for a urgent response
Regards
 

Similar threads