Simple Coding Help - No Promise.

I have this type of afl that changes colour based on price direction, but not sure if is based on moving average. Let me look for it.
 
hai seniors and experts ,
help required in generating buy and sell signals in triple moving average crossover.
say , ema 34 , ema 55 and ema 89 are three moving averages ,
firstly buy signal is generated when ema34 > ema55 > ema89 .
After certain move ema34 < ema55 > ema89 , at this time we should get exit signal only and
after certain down move again situation becomes like this
ema34 > ema55 > ema89 , at this moment we should get again fresh buying signal .
Reverse of all should be vice versa in case of sell .
I hope i have been able to clear the concept .
Thanks a lot in advance .
 
hello all and thanks for help

this is explain SWINGBARHIGH in tradestation with comment how can i build it in amibroker

Code:
SwingHighBar (Function)


The SwingHighBar function returns the number of bars ago a Swing High bar occurred.


Syntax

SwingHighBar( Instance, Price, Strength, Length )


Returns (Integer)

A numeric value containing the number of bars ago the specified Swing High occurred, or -1 if not found.


Parameters

Instance (Numeric)
Sets which occurrence (that is, 1 = most recent, 2 = 2nd most recent, and
so on) to return.

Price (Numeric)
Specifies which bar value (price, function, or formula) to use.

Strength (Numeric)
Sets the required number of bars on either side of the swing bar.

Length (Numeric)
Sets the number of trailing bars to consider.


Remarks

A Swing High occurs when the Price of a bar is at least as high as the same Price on the preceding bar(s), and
higher than the same Price on the bar(s) that follow it.

The input Strength is the number of bars on each side of the SwingHighBar.
A strength of 1 indicates that the value returned by the input Price must be:
-- greater than or equal to the same value returned for the bar on its left,
-- greater than the bar on its right.

The input Length refers to the number of bars being examined for the SwingHighBar.

The input Instance refers to which SwingHighBar you want to use.
For example, if in a twenty-one bar period three swing highs were found, it becomes necessary to specify which SwingHighBar is desired. If the most recent SwingHighBar is desired, a one (1) would be substituted for the input Instance.


Note

If no SwingHighBar is found in the period (Length) specified, the function will return a minus one (-1).
The value of the input Length must exceed Strength by at least one. In addition, the Maximum number of bars referenced by a study (known as MaxBarsBack) must be greater than the sum of the values of Strength and Length.


Example

Plots the number of bars ago that the most recent swing bar high occurred based on the Close with 3 bars on either side of the swing within 10 trailing bars.

Plot1( SwingHighBar( 1, Close, 3, 10 );
i appreciate that for this and many many thaks if anyone help.
 
Hi Coding gurus,
Could someone help me to prevent multiple buy signals from being generated.
Scenio is as follows:

Buy = a >b OR c>d;
Sell = b>a or d>c;

Now I keep getting buy or sell signal in subsequent bars till the condition is true, I want to avoid buy signal till the time a fresh sell signal is generated. How to do it?
 
Hi Coding gurus,
Could someone help me to prevent multiple buy signals from being generated.
Scenio is as follows:

Buy = a >b OR c>d;
Sell = b>a or d>c;

Now I keep getting buy or sell signal in subsequent bars till the condition is true, I want to avoid buy signal till the time a fresh sell signal is generated. How to do it?
Any help guys...
 

vijkris

Learner and Follower
Hi Coding gurus,
Could someone help me to prevent multiple buy signals from being generated.
Scenio is as follows:

Buy = a >b OR c>d;
Sell = b>a or d>c;

Now I keep getting buy or sell signal in subsequent bars till the condition is true, I want to avoid buy signal till the time a fresh sell signal is generated. How to do it?
Use Exrem function
Code:
Buy = a >b OR c>d;
Sell = b>a or d>c;
Buy = exrem(buy,sell);
Sell = exrem(sell,buy);
 

saivenkat

Well-Known Member
Hello Coders and Afl gurus

This flower afl i got from TJ only in another thread.. but since then that thread is long inactive.. i post here ..seeking some help by way of certain "Modi"fications.


In this afl.. i need to have scan included..with BUY SIGNALS being generated when the renko bars cross 50% line from below.. and SELL SIGNALS when it crosses 50% line from up side.

Further the Buy and sell signal should be generated only on the day the renko bars crosses 50% yellow line,.. I mean.. suppose if today the renko bar closes at 60 .. on scanning the buy signal should appear... and if on next day the renko bar closes again above 50, say at 80 levels, then the buy signal should not be generated on next day.
:sos: :sos:​


Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarsRequired(sbrAll,sbrAll);
SetChartBkColor(ParamColor("Outer panel",colorDarkOliveGreen));
GraphXSpace=Param("GraphXSpace",20,-10,25,1);
_SECTION_END();

_SECTION_BEGIN( "Flower" );
Title = StrFormat( "\\c02 {{DATE}} | Volume = " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
_SECTION_END();
 
_SECTION_BEGIN( "Sup/Res Detail" );
SupResPeriod = Param( "LookBack Period", 50, 0, 200, 1 );
SupResPercentage = Param( "Percentage", 100, 0, 200, 1 );
PricePeriod = Param( "Price Period", 16, 0, 200, 1 );
SupportLinecolor = ParamColor( "Support Color", colorGreen );
SupportLinestyle = ParamStyle( "Support Style", styleThick | 8 | styleNoLabel );
ResistanceLinecolor = ParamColor( "Resistance Color", colorRed );
Resistancestyle = ParamStyle( "Resistance Style", styleThick | 8 | styleNoLabel );
_SECTION_END();

_SECTION_BEGIN( "Line Detail" );
OverBought = Param( "OverBought Above", 200, 0, 400, 1 );
OverSold = Param( "OverSold Bellow", -200, -400, 0, 1 );
_SECTION_END();

_SECTION_BEGIN( "Trend Bought/Sold Detail" );
Smoother = Param( "Trend Smoother", 5, 5, 20 );
upcolor = ParamColor( "UpTrend Color", colorGreen );
Downcolor = ParamColor( "DownTrend Color", colorRed );
_SECTION_END();
 
_SECTION_BEGIN( "Circle Detail" );
Warningcolor = ParamColor( "Warning/Watch Signal", colorBlue );
WatchColor = ParamColor( "Accumulation Zone", colorWhite );
EntryColor = ParamColor( "Entry Signal", colorAqua );
ProfitTakeColor = ParamColor( "Distribution Zone", colorYellow );
ExitColor = ParamColor( "Exit Signal", colorRed );
_SECTION_END();
 
_SECTION_BEGIN( "Swing Sup/Res" );
Lookback = SupResPeriod;
PerCent = SupResPercentage;
Pds = PricePeriod;
Var = MACD();
Up = IIf( Var > Ref( Var, -1 ), abs( Var - Ref( Var, -1 ) ), 0 );
Dn = IIf( Var < Ref( Var, -1 ), abs( Var - Ref( Var, -1 ) ), 0 );
Ut = Wilders( Up, Pds );
Dt = Wilders( Dn, Pds );
RSIt = 100 * ( Ut / ( Ut + Dt ) );
A1 = RSIt;
B2 = RSI( pds );
C3 = CCI( pds );
D4 = StochK( pds );
E5 = StochD( pds );
F6 = MFI( pds );
G7 = Ultimate( pds );
H8 = ROC( C, pds );
Osc = C3;
Value1 = Osc;
Value2 = HHV( Value1, Lookback );
Value3 = LLV( Value1, Lookback );
Value4 = Value2 - Value3;
Value5 = Value4 * ( PerCent / 100 );
ResistanceLine = Value3 + Value5;
SupportLine = Value2 - Value5;
baseline = IIf( Osc < 100 AND Osc > 10 , 50 , IIf( Osc < 0 , 0, 0 ) );
Plot( ResistanceLine, "", SupportLinecolor, SupportLinestyle );
Plot( SupportLine, "", ResistanceLinecolor, Resistancestyle );
_SECTION_END();

_SECTION_BEGIN( "Entry/Exit Detail" );
n = Smoother;
ys1 = ( High + Low + Close * 2 ) / 4;
rk3 = EMA( ys1, n );
rk4 = StDev( ys1, n );
rk5 = ( ys1 - rk3 ) * 200 / rk4;
rk6 = EMA( rk5, n );
UP = EMA( rk6, n );
DOWN = EMA( up, n );
Oo = IIf( up < down, up, down );
Hh = Oo;
Ll = IIf( up < down, down, up );
Cc = Ll;
barcolor2 = IIf( Ref( oo, -1 ) < Oo AND Cc < Ref( Cc, -1 ), upcolor, IIf( up > down, upcolor, downcolor ) );
PlotOHLC( Oo, hh, ll, Cc, "Accumulation/Distribution", barcolor2, styleCandle );  // When value is -ve it is accumulation, when +ve it is distribution ( 200 lines are limtits to watch )
Buy = Cross( up, OverSold );
Sell = Cross( OverBought, up );
PlotShapes ( IIf( Buy, shapeSmallCircle, shapeNone ) , EntryColor, layer = 0, yposition = -220, offset = 1 );
PlotShapes ( IIf( Sell, shapeSmallCircle, shapeNone ) , ExitColor, layer = 0, yposition = 220, offset = 1 );
_SECTION_END();
 
_SECTION_BEGIN( "Overbought/Oversold/Warning Detail" );
n = Smoother;
ys1 = ( High + Low + Close * 2 ) / 4;
rk3 = EMA( ys1, n );
rk4 = StDev( ys1, n );
rk5 = ( ys1 - rk3 ) * 210 / rk4;
rk6 = EMA( rk5, n );
UP = EMA( rk6, n );
DOWN = EMA( up, n );
Oo = IIf( up < down, up, down );
Hh = Oo;
Ll = IIf( up < down, down, up );
Cc = Ll;
barcolor2 = IIf( Ref( oo, -1 ) < Oo AND Cc < Ref( Cc, -1 ), colorGreen, IIf( up > down, colorGreen, colorRed ) );
PlotOHLC( Oo, hh, ll, Cc, "", barcolor2, styleCandle | stylehidden );
UP = EMA( rk6, n );
UPshape = IIf( UP >= OverBought OR UP <= OverSold, shapeHollowSmallCircle, shapeNone );
UPColor = IIf( UP >= 210, ProfitTakeColor, IIf( UP <= -210, WatchColor, Warningcolor ) );
Plot( UP, "", colorGrey50, styleThick | stylehidden );
PlotShapes( UPShape, UPColor, 0, UP, 0 );
_SECTION_END();
 
_SECTION_BEGIN( "Plot Lines" );
Plot( OverBought, "", colorDarkGrey, styleLine | styleNoLabel );
Plot( 50, "", colorYellow, styleDashed | styleThick );
Plot( OverSold, "", colorDarkGrey, styleLine | styleNoLabel );
_SECTION_END();
Thanks 'n regards :thanx:
Saivenkat :)
 
Hello Friends

I am starting this thread for helping anyone who requires small changes in AFLs or AFL coding done for small / simple requirements that can be clearly defined.

What does not go is conversion . . . from Amibroker to anything else . . . or from anything else to Amibroker . . .

Debugging requested for copy/paste AFLs, Please don't post huge AFLs with zillions of lines of code for debugging

I will not be available for any conversions and I am not interested in debugging some-one else's copy/pasted work and lastly . . .
Not interested in hacking/craking any ones work . . .

Only if have a clearly definable task to be coded I maybe able to help . . . No Promises but will try within my limitations . . .


As an example, recently one of our friends wanted a motivational message to be included in his Charts,
I enjoyed doing that, as i could easily empathize with why he wanted that . . .


Cheers

:) Happy
how to check in afl which paramfield is chosen by user?
 

Similar threads

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?