My visual effect afl collection.

yasu222

Active Member
#51
Double ema junction

//DOUBLE EMA JUNCTION..
_SECTION_BEGIN("JUNCTION");

Lpr = Param("Fast",3,3,50,1);
a1=EMA(H,LPR);
b1=EMA(L,LPR);

Hpr = Param("Slow",30,10,600,3);
a2=EMA(H,Hpr);
b2=EMA(L,Hpr);

Buy = a1 > a2 AND b1 > a2;
Sell = a1 < b2 AND b1 < b2;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBrightGreen,colorPink ),0, IIf( Buy, Low, High) ); // altered here

Plot(a1,"",colorLightBlue,1);
Plot(b1,"",colorPink,1);

Plot(a2,"",colorBrightGreen,1);
Plot(b2,"",colorYellow,1);

GraphXSpace =5;
_SECTION_END();

OPTIMISATION JUNCTION AFL -

Lpr = Optimize("Fast",3,3,50,1);
a1=EMA(H,LPR);
b1=EMA(L,LPR);

Hpr = Optimize("Slow",30,10,600,3);
a2=EMA(H,Hpr);
b2=EMA(L,Hpr);

Buy = a1 > a2 AND b1 > a2;
Sell = a1 < b2 AND b1 < b2;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
 

yasu222

Active Member
#52
Afl syntax - Total

AFL Function Reference - Alphabetical list of functions
#include ( Miscellaneous functions) - preprocessor include command (AFL 2.2)
#include_once ( Miscellaneous functions) - preprocessor include (once) command (AFL 2.70)
#pragma ( Miscellaneous functions) - sets AFL pre-processor option (AFL 2.4)
abs ( Math functions) - absolute value
AccDist ( Indicators) - accumulation/distribution
acos ( Math functions) - arccosine function
AddColumn (Exploration / Indicators) - add numeric exploration column (AFL 1.8)
AddSummaryRows (Exploration / Indicators) - add summary row(s) to the exploration output (AFL 3.2)
AddTextColumn (Exploration / Indicators) - add text exploration column (AFL 1.8)
AddToComposite ( Composites) - add value to composite ticker (AFL 2.0)
ADLine ( Composites) - advance/decline line (AFL 1.2)
AdvIssues ( Composites) - advancing issues (AFL 1.2)
AdvVolume ( Composites) - advancing issues volume (AFL 1.2)
ADX ( Indicators) - average directional movement index (AFL 1.3)
AlertIf ( Trading system toolbox) - trigger alerts (AFL 2.1)
AlmostEqual ( Math functions) - rounding error insensitive comparison (AFL 2.80)
AMA ( Moving averages, summation) - adaptive moving average (AFL 1.5)
AMA2 ( Moving averages, summation) - adaptive moving average (AFL 1.5)
ApplyStop ( Trading system toolbox) - apply built-in stop (AFL 1.7)
Asc ( String manipulation) - get ASCII code of character (AFL 2.80)
asin ( Math functions) - arcsine function
atan ( Math functions) - arc tan
atan2 ( Math functions) - calculates arctangent of y/x (AFL 2.90)
ATR ( Indicators) - average true range (AFL 1.3)
BarIndex ( Date/Time) - get zero-based bar number (AFL 2.3)
BarsSince ( Trading system toolbox) - bars since
BBandBot ( Indicators) - bottom bollinger band
BBandTop ( Indicators) - top bollinger band
BeginValue ( Date/Time) - Value of the array at the begin of the range (AFL 2.3)
CategoryAddSymbol ( Information / Categories) - adds a symbol to a category (AFL 2.5)
CategoryFind ( Information / Categories) - search for category by name (AFL 3.0)
CategoryGetName ( Information / Categories) - get the name of a category (AFL 2.5)
CategoryGetSymbols ( Information / Categories) - retrieves comma-separated list of symbols belonging to given category (AFL 2.5)
CategoryRemoveSymbol ( Information / Categories) - remove a symbol from a category (AFL 2.5)
CategorySetName ( Information / Categories) - set the name of category (group, market, watch list, industry) (AFL 3.20)
CCI ( Indicators) - commodity channel index
ceil ( Math functions) - ceil value
Chaikin ( Indicators) - chaikin oscillator
ClipboardGet ( Miscellaneous functions) - retrieves current contents of Windows clipboard (AFL 2.60)
ClipboardSet ( Miscellaneous functions) - copies the text to the Windows clipboard (AFL 2.6)
ColorBlend ( Indicators) - blends (mixes) two colors (AFL 3.30)
ColorHSB ( Miscellaneous functions) - specify color using Hue-Saturation-Brightness (AFL 2.80)
ColorRGB ( Miscellaneous functions) - specify color using Red-Green-Blue components (AFL 2.80)
Correlation ( Statistical functions) - correlation (AFL 1.4)
cos ( Math functions) - cosine
cosh ( Math functions) - hyperbolic cosine function (AFL 2.80)
CreateObject ( Miscellaneous functions) - create COM object (AFL 1.8)
CreateStaticObject ( Miscellaneous functions) - create static COM object (AFL 1.8)
Cross ( Trading system toolbox) - crossover check
Cum ( Moving averages, summation) - cumulative sum
Date ( Date/Time) - date (AFL 1.1)
DateNum ( Date/Time) - date number (AFL 1.4)
DateTime ( Date/Time) - retrieves encoded date time (AFL 2.3)
DateTimeAdd ( Date/Time) - adds specified number of seconds/minutes/hours/days to datetime (AFL 3.40)
DateTimeConvert ( Date/Time) - date/time format conversion (AFL 2.90)
DateTimeDiff ( Date/Time) - get difference in seconds between two datetime values (AFL 3.30)
DateTimeToStr ( String manipulation) - convert datetime to string (AFL 2.8)
Day ( Date/Time) - day of month (AFL 1.4)
DayOfWeek ( Date/Time) - day of week (AFL 1.4)
DayOfYear ( Date/Time) - get ordinal number of day in a year (AFL 2.4)
DaysSince1900 ( Date/Time) - get number of days since January 1st, 1900 (AFL 3.20)
DecIssues ( Composites) - declining issues (AFL 1.2)
DecVolume ( Composites) - declining issues volume (AFL 1.2)
DEMA ( Moving averages, summation) - double exponential moving average (AFL 2.0)
EMA ( Moving averages, summation) - exponential moving average
EnableRotationalTrading ( Trading system toolbox) - Turns on rotational-trading mode of the backtester (AFL 2.5)
EnableScript ( Miscellaneous functions) - enable scripting engine
EnableTextOutput ( Miscellaneous functions) - enables/disables text output in the Chart Commentary window (AFL 2.2)
EncodeColor (Exploration / Indicators) - encodes color for indicator title (AFL 2.2)
EndValue ( Date/Time) - value of the array at the end of the selected range (AFL 2.3)
Equity ( Trading system toolbox) - calculate single-symbol equity line (AFL 2.0)
EXP ( Math functions) - exponential function
ExRem ( Trading system toolbox) - remove excessive signals (AFL 1.5)
ExRemSpan ( Trading system toolbox) - remove excessive signals spanning given number of bars (AFL 2.0)
fclose (File Input/Output functions) - close a file (AFL 2.5)
fdelete (File Input/Output functions) - deletes a file (AFL 2.70)
feof (File Input/Output functions) - test for end-of-file (AFL 2.5)
FFT ( Basic price pattern detection) - performs Fast Fourier Transform (AFL 2.90)
fgets (File Input/Output functions) - get a string from a file (AFL 2.5)
fgetstatus (File Input/Output functions) - retrieves file status/properties (AFL 2.90)
FIR ( Moving averages, summation) - Finite Impulse Response filter (AFL 3.40)
FirstVisibleValue ( Indicators) - get first visible value of array (AFL 3.40)
Flip ( Trading system toolbox) - (AFL 1.5)
floor ( Math functions) - floor value
fmkdir (File Input/Output functions) - creates (makes) a directory (AFL 2.70)
fopen (File Input/Output functions) - open a file (AFL 2.5)
Foreign (Referencing other symbol data) - access foreign security data (AFL 1.5)
fputs (File Input/Output functions) - write a string to a file (AFL 2.5)
frac ( Math functions) - fractional part
frmdir (File Input/Output functions) - removes a directory (AFL 2.70)
FullName ( Information / Categories) - full name of the symbol (AFL 1.1)
GapDown ( Basic price pattern detection) - gap down
GapUp ( Basic price pattern detection) - gap up
GetBacktesterObject ( Trading system toolbox) - get the access to backtester object (AFL 2.60)
GetBaseIndex (Referencing other symbol data) - retrieves symbol of relative strength base index (AFL 2.1)
GetCategorySymbols ( Information / Categories) - retrieves comma-separated list of symbols belonging to given category (AFL 2.4)
GetChartBkColor ( Indicators) - get the RGB color value of chart background (AFL 3.20)
GetChartID (Exploration / Indicators) - get current chart ID (AFL 2.3)
GetCursorMouseButtons ( Indicators) - get current state of mouse buttons (AFL 2.80)
GetCursorXPosition ( Indicators) - get current X position of mouse pointer (AFL 2.80)
GetCursorYPosition ( Indicators) - get current Y position of mouse pointer (AFL 2.80)
GetDatabaseName ( Information / Categories) - retrieves folder name of current database (AFL 2.3)
GetExtraData ( Miscellaneous functions) - get extra data from external data source (AFL 1.9)
GetFnData ( Information / Categories) - get fundamental data (AFL 2.90)
GetOption ( Trading system toolbox) - gets the value of option in automatic analysis settings (AFL 2.60)
GetPerformanceCounter ( Miscellaneous functions) - retrieves the current value of the high-resolution performance counter (AFL 2.90)
GetPlaybackDateTime ( Date/Time) - get bar replay position date/time (AFL 3.0)
GetPriceStyle (Exploration / Indicators) - get current price chart style (AFL 2.70)
GetRTData ( Miscellaneous functions) - retrieves the real-time data fields (AFL 2.60)
GetRTDataForeign ( Miscellaneous functions) - retrieves the real-time data fields (for specified symbol) (AFL 2.80)
GetScriptObject ( Miscellaneous functions) - get access to script COM object (AFL 1.8)
GetTradingInterface ( Trading system toolbox) - retrieves OLE automation object to automatic trading interfac (AFL 2.70)
GfxArc (Low-level graphics) - draw an arc (AFL 3.0)
GfxChord (Low-level graphics) - draw a chord (AFL 3.0)
GfxCircle (Low-level graphics) - draw a circle (AFL 3.0)
GfxDrawText (Low-level graphics) - draw a text (clipped to rectangle) (AFL 3.0)
GfxEllipse (Low-level graphics) - draw an ellipse (AFL 3.0)
GfxGradientRect (Low-level graphics) - draw a rectangle with gradient fill (AFL 3.0)
GfxLineTo (Low-level graphics) - draw a line to specified point (AFL 3.0)
GfxMoveTo (Low-level graphics) - move graphic cursor to new position (AFL 3.0)
GfxPie (Low-level graphics) - draw a pie (AFL 3.0)
GfxPolygon (Low-level graphics) - draw a polygon (AFL 3.0)
GfxPolyline (Low-level graphics) - draw a polyline (AFL 3.0)
GfxRectangle (Low-level graphics) - draw a rectangle (AFL 3.0)
GfxRoundRect (Low-level graphics) - draw a rectangle with rounded corners (AFL 3.0)
GfxSelectFont (Low-level graphics) - create / select graphic font (AFL 3.0)
GfxSelectPen (Low-level graphics) - create / select graphic pen (AFL 3.0)
GfxSelectSolidBrush (Low-level graphics) - create / select graphic brush (AFL 3.0)
GfxSetBkColor (Low-level graphics) - set graphic background color (AFL 3.0)
GfxSetBkMode (Low-level graphics) - set graphic background mode (AFL 3.0)
GfxSetOverlayMode (Low-level graphics) - set low-level graphic overlay mode (AFL 3.0)
GfxSetPixel (Low-level graphics) - set pixel at specified position to specified color (AFL 3.0)
GfxSetTextAlign (Low-level graphics) - set text alignment (AFL 3.0)
GfxSetTextColor (Low-level graphics) - set graphic text color (AFL 3.0)
GfxTextOut (Low-level graphics) - writes text at the specified location (AFL 3.0)
GicsID ( Information / Categories) - get GICS category information (AFL 3.40)
GroupID ( Information / Categories) - get group ID/name (AFL 1.8)
HHV ( Lowest/Highest) - highest high value
HHVBars ( Lowest/Highest) - bars since highest high
Highest ( Lowest/Highest) - highest value
HighestBars ( Lowest/Highest) - bars since highest value
HighestSince ( Lowest/Highest) - highest value since condition met (AFL 1.4)
HighestSinceBars ( Lowest/Highest) - bars since highest value since condition met (AFL 1.4)
HighestVisibleValue ( Indicators) - get the highest value within visible chart area (AFL 3.30)
HMA ( Moving averages, summation) - Hull Moving Average (AFL 3.40)
Hold ( Trading system toolbox) - hold the alert signal
Hour ( Date/Time) - get current bar's hour (AFL 2.0)
IIf ( Trading system toolbox) - immediate IF function
IndustryID ( Information / Categories) - get industry ID / name (AFL 1.8)
InGICS ( Information / Categories) - test GICS membership (AFL 3.40)
Inside ( Basic price pattern detection) - inside day
Int ( Math functions) - integer part
Interval ( Date/Time) - get bar interval (in seconds) (AFL 2.1)
InWatchList ( Information / Categories) - watch list membership test (by ordinal number)
InWatchListName ( Information / Categories) - watch list membership test (by name) (AFL 3.0)
IsContinuous ( Information / Categories) - checks 'continuous quotations' flag state (AFL 2.60)
IsEmpty ( Miscellaneous functions) - empty value check (AFL 1.5)
IsFavorite ( Information / Categories) - check if current symbol belongs to favorites (AFL 2.5)
IsFinite ( Miscellaneous functions) - check if value is not infinite (AFL 2.3)
IsIndex ( Information / Categories) - check if current symbol is an index (AFL 2.5)
IsNan ( Miscellaneous functions) - checks for NaN (not a number) (AFL 2.3)
IsNull ( Miscellaneous functions) - check for Null (empty) value (AFL 2.3)
IsTrue ( Miscellaneous functions) - true value (non-empty and non-zero) check (AFL 1.5)
LastValue ( Trading system toolbox) - last value of the array
LastVisibleValue ( Indicators) - get last visible value of array (AFL 3.40)
LineArray (Exploration / Indicators) - generate trend-line array (AFL 2.5)
LinearReg ( Statistical functions) - linear regression end-point (AFL 2.2)
LinRegIntercept ( Statistical functions) - (AFL 2.2)
LinRegSlope ( Statistical functions) - linear regression slope (AFL 1.4)
LLV ( Lowest/Highest) - lowest low value
LLVBars ( Lowest/Highest) - bars since lowest low
log ( Math functions) - natural logarithm
log10 ( Math functions) - decimal logarithm
Lookup ( Date/Time) - search the array for bar with specified date/time (AFL 3.40)
Lowest ( Lowest/Highest) - lowest value
LowestBars ( Lowest/Highest) - bars since lowest
LowestSince ( Lowest/Highest) - lowest value since condition met (AFL 1.4)
LowestSinceBars ( Lowest/Highest) - barssince lowest value since condition met (AFL 1.4)
LowestVisibleValue ( Indicators) - get the lowest value within visible chart area (AFL 3.30)
MA ( Moving averages, summation) - simple moving average
MACD ( Indicators) - moving average convergence/divergence
MarketID ( Information / Categories) - market ID / name (AFL 1.8)
Max ( Math functions) - maximum value of two numbers / arrays
MDI ( Indicators) - minus directional movement indicator (-DI) (AFL 1.3)
Median ( Statistical functions) - calculate median (middle element) (AFL 2.5)
MFI ( Indicators) - money flow index
MicroSec ( Date/Time) - get bar's microsecond part of the timestamp
MilliSec ( Date/Time) - get bar's millisecond part of the timestamp
Min ( Math functions) - minimum value of two numbers / arrays
Minute ( Date/Time) - get current bar's minute (AFL 2.0)
Month ( Date/Time) - month (AFL 1.4)
mtRandom ( Statistical functions) - Mersene Twister random number generator (AFL 3.0)
mtRandomA ( Statistical functions) - Mersene Twister random number generator (array version) (AFL 3.0)
Name ( Information / Categories) - ticker symbol (AFL 1.1)
NoteGet ( Miscellaneous functions) - retrieves the text of the note (AFL 2.6)
NoteSet ( Miscellaneous functions) - sets text of the note (AFL 2.6)
Now ( Date/Time) - gets current system date/time (AFL 2.3)
NumToStr ( String manipulation) - convert number to string (AFL 2.5)
NVI ( Indicators) - negative volume index
Nz ( Miscellaneous functions) - Null (Null/Nan/Infinity) to zero (AFL 2.3)
OBV ( Indicators) - on balance volume
Optimize ( Trading system toolbox) - define optimization variable (AFL 1.7)
OptimizerSetEngine ( Trading system toolbox) - select external optimization engine (AFL 3.20)
OptimizerSetOption ( Trading system toolbox) - set the value of external optimizer engine parameter (AFL 3.20)
OscP ( Indicators) - price oscillator
OscV ( Indicators) - volume oscillator
Outside ( Basic price pattern detection) - outside bar
Param (Exploration / Indicators) - add user user-definable numeric parameter (AFL 2.3)
ParamColor (Exploration / Indicators) - add user user-definable color parameter (AFL 2.3)
ParamDate (Exploration / Indicators) - add user user-definable date parameter (AFL 2.60)
ParamField (Exploration / Indicators) - creates price field parameter (AFL 2.70)
ParamList (Exploration / Indicators) - creates the parameter that consist of the list of choices (AFL 2.70)
ParamStr (Exploration / Indicators) - add user user-definable string parameter (AFL 2.3)
ParamStyle (Exploration / Indicators) - select styles applied to the plot (AFL 2.70)
ParamTime (Exploration / Indicators) - add user user-definable time parameter (AFL 2.60)
ParamToggle (Exploration / Indicators) - create Yes/No parameter (AFL 2.70)
ParamTrigger (Exploration / Indicators) - creates a trigger (button) in the parameter dialog (AFL 2.70)
PDI ( Indicators) - plus directional movement indicator (AFL 1.3)
Peak ( Basic price pattern detection) - peak (AFL 1.1)
PeakBars ( Basic price pattern detection) - bars since peak (AFL 1.1)
Percentile ( Statistical functions) - calculate percentile (AFL 2.5)
PercentRank ( Indicators) - calculate percent rank (AFL 3.40)
PlaySound ( Miscellaneous functions) - play back specified .WAV file (AFL 3.40)
Plot (Exploration / Indicators) - plot indicator graph (AFL 1.8)
PlotForeign (Referencing other symbol data) - plot foreign security data (AFL 2.2)
PlotGrid (Exploration / Indicators) - Plot horizontal grid line (AFL 2.3)
PlotOHLC (Exploration / Indicators) - plot custom OHLC chart (AFL 2.2)
PlotShapes (Exploration / Indicators) - plots arrows and other shapes (AFL 2.3)
PlotText ( Indicators) - write text on the chart (AFL 2.80)
PlotVAPOverlay (Exploration / Indicators) - plot Volume-At-Price overlay chart (AFL 2.4)
PlotVAPOverlayA ( Indicators) - plot multiple-segment Volume-At-Price chart (AFL 3.20)
PopupWindow ( Miscellaneous functions) - display pop-up window (AFL 3.0)
Prec ( Math functions) - adjust number of decimal points of floating point number
Prefs ( Miscellaneous functions) - retrieve preferences settings (AFL 1.4)
printf ( String manipulation) - Print formatted output to the output window. (AFL 2.5)
PVI ( Indicators) - positive volume index
Random ( Statistical functions) - random number (AFL 1.9)
Ref ( Trading system toolbox) - reference past/future values of the array
RelStrength (Referencing other symbol data) - comparative relative strength (AFL 1.3)
RequestTimedRefresh ( Indicators) - forces periodical refresh of indicator pane (AFL 2.90)
RestorePriceArrays (Referencing other symbol data) - restore price arrays to original symbol (AFL 2.5)
RMI ( Indicators) - Relative Momentum Index (AFL 2.1)
ROC ( Indicators) - percentage rate of change
Round ( Math functions) - round number to nearest integer
RSI ( Indicators) - relative strength index
RWI ( Indicators) - random walk index
RWIHi ( Indicators) - random walk index of highs
RWILo ( Indicators) - random walk index of lows
SAR ( Indicators) - parabolic stop-and-reverse (AFL 1.3)
Say ( Miscellaneous functions) - speaks provided text (AFL 2.90)
Second ( Date/Time) - get current bar's second (AFL 2.0)
SectorID ( Information / Categories) - get sector ID / name (AFL 1.8)
SelectedValue (Exploration / Indicators) - retrieves value of the array at currently selected date/time point (AFL 2.1)
SetBacktestMode ( Trading system toolbox) - Sets working mode of the backtester (AFL 3.0)
SetBarFillColor ( Indicators) - set bar/candlestick/cloud chart fill color (AFL 3.1)
SetBarsRequired ( Miscellaneous functions) - set number of previous and future bars needed for script/DLL to properly execute (AFL 2.1)
SetChartBkColor ( Indicators) - set background color of a chart (AFL 2.80)
SetChartBkGradientFill ( Indicators) - enables background gradient color fill in indicators (AFL 2.90)
SetChartOptions (Exploration / Indicators) - set/clear/overwrite defaults for chart pane options (AFL 2.70)
SetCustomBacktestProc ( Trading system toolbox) - define custom backtest procedure formula file (AFL 2.70)
SetForeign (Referencing other symbol data) - replace current price arrays with those of foreign security (AFL 2.5)
SetFormulaName ( Trading system toolbox) - set the name of the formula (AFL 2.5)
SetOption ( Trading system toolbox) - sets options in automatic analysis settings (AFL 2.3)
SetPositionSize ( Trading system toolbox) - set trade size (AFL 2.70)
SetSortColumns (Exploration / Indicators) - sets the columns which will be used for sorting in AA window (AFL 2.90)
SetTradeDelays ( Trading system toolbox) - allows to control trade delays applied by the backtester (AFL 2.1)
ShellExecute ( Basic price pattern detection) - execute a file (AFL 3.40)
sign ( Math functions) - returns the sign of the number/array (AFL 2.50)
Signal ( Indicators) - macd signal line
sin ( Math functions) - sine function
sinh ( Math functions) - hyperbolic sine function (AFL 2.80)
sqrt ( Math functions) - square root
StaticVarCompareExchange ( Miscellaneous functions) - atomic interlocked static variable compare-exchange operation (AFL 3.50)
StaticVarCount ( Miscellaneous functions) - get the total number of static variables in memory (AFL 3.30)
StaticVarGet ( Miscellaneous functions) - gets the value of static variable (AFL 2.60)
StaticVarGetText ( Miscellaneous functions) - gets the value of static variable as string (AFL 2.60)
StaticVarRemove ( Miscellaneous functions) - remove static variable (AFL 2.80)
StaticVarSet ( Miscellaneous functions) - sets the value of static variable (AFL 2.60)
StaticVarSetText ( Miscellaneous functions) - Sets the value of static string variable. (AFL 2.60)
Status ( Miscellaneous functions) - get run-time AFL status information (AFL 1.65)
StdErr ( Statistical functions) - standard error (AFL 1.4)
StDev ( Statistical functions) - standard deviation (AFL 1.4)
StochD ( Indicators) - stochastic slow %D
StochK ( Indicators) - stochastic slow %K
StrCount ( String manipulation) - count the occurrences of substring within a string (AFL 3.20)
StrExtract ( String manipulation) - extracts given item (substring) from comma-separated string (AFL 2.4)
StrFind ( String manipulation) - find substring in a string (AFL 2.5)
StrFormat ( String manipulation) - Write formatted output to the string (AFL 2.5)
StrLeft ( String manipulation) - extracts the leftmost part (AFL 2.0)
StrLen ( String manipulation) - string length (AFL 1.5)
StrMid ( String manipulation) - extracts part of the string (AFL 2.0)
StrReplace ( String manipulation) - string replace (AFL 2.90)
StrRight ( String manipulation) - extracts the rightmost part of the string (AFL 2.0)
StrToDateTime ( String manipulation) - convert string to datetime (AFL 2.80)
StrToLower ( String manipulation) - convert to lowercase (AFL 2.80)
StrToNum ( String manipulation) - convert string to number (AFL 2.5)
StrToUpper ( String manipulation) - convert to uppercase (AFL 2.80)
Study ( Miscellaneous functions) - reference hand-drawn study (AFL 1.5)
Sum ( Moving averages, summation) - sum data over specified number of bars
tan ( Math functions) - tangent function (AFL 1.0)
tanh ( Math functions) - hyperbolic tangent function (AFL 2.80)
TEMA ( Moving averages, summation) - triple exponential moving average (AFL 2.0)
ThreadSleep ( Miscellaneous functions) - suspend thread for specified number of milliseconds (AFL 3.50)
TimeFrameCompress (Time Frame functions) - compress single array to given time frame (AFL 2.5)
TimeFrameExpand (Time Frame functions) - expand time frame compressed array (AFL 2.5)
TimeFrameGetPrice (Time Frame functions) - retrieve O, H, L, C, V values from other time frame (AFL 2.5)
TimeFrameMode (Time Frame functions) - switch time frame compression mode (AFL 2.80)
TimeFrameRestore (Time Frame functions) - restores price arrays to original time frame (AFL 2.5)
TimeFrameSet (Time Frame functions) - switch price arrays to a different time frame (AFL 2.5)
TimeNum ( Date/Time) - get current bar time (AFL 2.0)
Trin ( Composites) - traders (Arms) index (AFL 1.2)
TRIX ( Indicators) - triple exponential smoothed price
Trough ( Basic price pattern detection) - trough (AFL 1.1)
TroughBars ( Basic price pattern detection) - bars since trough (AFL 1.1)
TSF ( Statistical functions) - time series forecast (AFL 2.2)
Ultimate ( Indicators) - ultimate oscillator
UncIssues ( Composites) - unchanged issues (AFL 1.2)
UncVolume ( Composites) - unchaged issues volume (AFL 1.2)
ValueWhen ( Trading system toolbox) - get value of the array when condition met (AFL 1.1)
VarGet ( Miscellaneous functions) - gets the value of dynamic variable (AFL 2.60)
VarGetText ( Miscellaneous functions) - gets the text value of dynamic variable (AFL 2.80)
VarSet ( Miscellaneous functions) - sets the value of dynamic variable (AFL 2.60)
VarSetText ( Miscellaneous functions) - sets dynamic variable of string type (AFL 2.80)
Version ( Miscellaneous functions) - get version info (AFL 1.9)
Wilders ( Moving averages, summation) - Wilder's smoothing (AFL 1.4)
WMA ( Moving averages, summation) - weighted moving average (AFL 2.0)
WriteIf (Exploration / Indicators) - commentary conditional text output
WriteVal (Exploration / Indicators) - converts number to string
Year ( Date/Time) - year (AFL 1.4)
ZIG ( Basic price pattern detection) - zig-zag indicator (AFL 1.1)
_DEFAULT_NAME (Exploration / Indicators) - retrive default name of the plot (AFL 2.70)
_DT ( Date/Time) - convert string to datetime (AFL 3.40)
_N (Exploration / Indicators) - no text output (AFL 2.1)
_PARAM_VALUES (Exploration / Indicators) - retrieve param values string (AFL 2.70)
_SECTION_BEGIN (Exploration / Indicators) - section begin marker (AFL 2.70)
_SECTION_END (Exploration / Indicators) - section end marker (AFL 2.70)
_SECTION_NAME (Exploration / Indicators) - retrieve current section name (AFL 2.70)
_TRACE ( Miscellaneous functions) - print text to system debug viewer (AFL 2.4)
 

yasu222

Active Member
#53
ALERT_PRICE_brkot

//2CHANNEL BREAKOUT//
_SECTION_BEGIN("Dual Band");
UB = Param( "Alert Price", .05, .05, 80000, .05 ) ;
Points = Param( "Alert Stoploss", 0, 0, 1000, .05) ;
LB = (UB-Points) ;

DonchianUpper1 = Cross(ref(C,-1),UB);
DonchianLower1 = Cross(LB,ref(C,-1));

Buy1 = ExRem(DonchianUpper1,DonchianLower1);
Sell1 = ExRem(DonchianLower1,DonchianUpper1);
Plot(UB,"UB",colorWhite,styleLine|styleNoLabel|styleNoRescale) ;
Plot(LB,"LB",colorWhite,styleLine|styleNoLabel|styleNoRescale) ;

Buy = ExRem(Buy1,Sell1) ;
Sell = ExRem(Sell1,Buy1) ;
Short = Sell;
Cover = Buy;

PlotShapes(Buy*shapeUpTriangle,colorYellow,0,L,-25);
PlotShapes(Sell*shapeDownTriangle,colorYellow,0,H,-20);

AlertIf(Buy,"exec tsalertif.exe","BUY",1);
AlertIf(Sell,"exec tsalertif.exe","SELL",1);
_SECTION_END();
 
Last edited:

yasu222

Active Member
#55
Best super trend

_SECTION_BEGIN("BestSuperTrend");

SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 217, 197, 137 ) ), ParamColor( "BottomColor", ColorRGB( 254, 244, 224 ) ) );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));


SetChartOptions(0, chartShowDates | chartWrapTitle);
Plot(C,"",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
kk = Optimize( "mult", Param( "mult", 2.75, 1, 6, 0.25 ), 1, 2, 0.25 );
Per = Optimize( "period", Param( "period", 10, 5, 50, 1 ), 5, 50, 1 );
sdfact = Param( "Standard Deviation Factor", 2, 0.5, 5, 0.1 );
offset = Param( "Offset", 2, 1, 50, 1 );
tc = ParamList( "Channel Display", List = "No Channel|Channel|ChannelRT|Both
Channels", 1 );
ms = ParamToggle( "Trend", "Regular|Smoothed", 1 );

x = Cum( 1 );
HaClose = ( O + H + L + C ) / 4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

if ( ms == 0 )
{
nm = ( H - L );
j = ( O + H + L + C ) / 4;
}
else
{
nm = ( HaHigh - HaLow );
j = ( HaOpen + HaHigh + HaLow + HaClose ) / 4;
}

rfsctor = WMA( nm, Per );

revers = kk * rfsctor;
Trend = 1;
NW[0] = 0;

for ( i = 1;i < BarCount;i++ )
{
if ( Trend[i-1] == 1 )
{
if ( j < NW[i-1] )
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;

if ( ( j - Revers ) > NW[i-1] )
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}

if ( Trend[i-1] == -1 )
{
if ( j > NW[i-1] )
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;

if ( ( j + Revers ) < NW[i-1] )
{
NW = j + Revers;
}
else
{
NW = NW[i-1];
}
}
}
}

cp = ( H + L ) / 2;

Plot( IIf( NW < j, NW, Null ), "\ntrailLong", ParamColor( "ColorTrailLong",
colorBlue ), styleStaircase | styleDots );
Plot( IIf( NW > j, NW, Null ), "\ntrailShort", ParamColor( "ColorTrailShort",
colorRed ), styleStaircase | styleDots );

Buy = NW < j;
Short = NW > j;

Buy = ExRem(Buy, Short);
Short = ExRem(Short, Buy);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,NW);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,NW);

_SECTION_END();
 

yasu222

Active Member
#56
Super trend

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(1,chartShowArrows|chartShowDates|chartWrapTitle);


GraphXSpace = 15;

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 217, 197, 137 ) ), ParamColor( "BottomColor", ColorRGB( 254, 244, 224 ) ) );

//SetTradeDelays(1,1,1,1);
Period = Param("Period", 150, 1, 2400, 1);
mult = Param("Multiplier", 4, 1.1, 20.0, 0.1); // set for 5 minutes chart.

f=ATR(period);

VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;

for( i = period+1; i < BarCount; i++ )
{

vs = vs[i-1];
trend = trend[i-1];
highC = HighC[i-1];
lowc = lowc[i-1];

if ((trend>=0) && ( C <VS ))
{
trend =-1;
HighC = C;
lowc = C;
}

if ((trend<=0) && (C >VS))
{
trend=1;
HighC = C;
lowc = C;
}

if (trend==-1)
{
if (C<lowc) lowc = C;
VS= lowc+ (mult*f);
}


if (trend==1)
{
if (C>HighC) HighC = C;
VS= HighC-(mult*f);
}

}

Plot(VS, "Vol Stop",IIf(trend==1,colorRed,colorYellow ),styleThick);

Buy=Cross(Trend,0);
Short=Cross(0, Trend);
Buy = Ref(Buy, -1);
Short = Ref(Short, -1);

Hp = HHV( H, 40 );
Lp = LLV( L, 40 );

BarsSincebuy = BarsSince( Buy );
BarsSinceshort = BarsSince( Short );
LastSignal = IIf( BarsSincebuy < BarsSinceshort, 1, -1 );
Sig = WriteIf( BarsSincebuy < BarsSinceshort, "BUY", "SELL" );

slPrice = IIf( LastSignal == 1, HighestSince( Buy, Lp ), LowestSince( Short, Hp ) );
initialrisk = IIf( LastSignal == 1, BuyPrice - SLPrice, SLPrice - ShortPrice );
CurrentPL = IIf( LastSignal == 1, C - BuyPrice, SellPrice - C );

BuyPrice=ValueWhen(Buy,O);
ShortPrice=ValueWhen(Short,O);

entry = IIf( LastSignal == 1, BuyPrice, ShortPrice );

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


bars = LastValue( IIf(BarsSincebuy < BarsSinceshort, BarsSincebuy, BarsSinceshort));
Offset = 15;
Clr = IIf(LastValue(LastSignal) == 1, colorGreen, colorRed);


if ( ParamToggle( "Message Board ", "Show|Hide", 1 ) )
{
GfxSelectFont( "Tahoma", 11, 700 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( SelectedValue( LastSignal ) == 1 )
{
GfxSelectSolidBrush( colorBrightGreen );
Datetim = "" + ValueWhen( Buy, Day(), 1 ) + "/" + ValueWhen( Buy, Month(), 1 ) + "/" + ValueWhen( Buy, Year(), 1 ) + " " + ValueWhen( Buy, Hour(), 1 ) + ":" + ValueWhen( Buy, Minute(), 1 );
}
else
{
GfxSelectSolidBrush( colorOrange );
Datetim = "" + ValueWhen( Short, Day(), 1 ) + "/" + ValueWhen( Short, Month(), 1 ) + "/" + ValueWhen( Short, Year(), 1 ) + " " + ValueWhen( Short, Hour(), 1 ) + ":" + ValueWhen( Short, Minute(), 1 );
}

pxHeight = Status( "pxchartheight" ) ;

xx = Status( "pxchartwidth" );
Left = 1100;
width = 310;
x = 1.5;
x2 = 235;

y = pxHeight / 1;

GfxSelectPen( colorLightBlue, 1 );
GfxRoundRect( x, y - 105, x2, y , 7, 7 ) ;
GfxTextOut( ( " ..........................................." ), 18, y - 90 );
GfxTextOut( ( "Last Signal" ), 10, y - 65 ) ;
GfxTextOut( ( ": " + Datetim ), 110, y - 65 ) ;
GfxTextOut( ( "" + sig + " Entry @" ), 10, y - 45 );
GfxTextOut( ( ": " + entry ), 110, y - 45 );
GfxTextOut( ( "Current P/L" ), 10, y - 25 );
GfxTextOut( ( ": " + WriteVal( IIf( sig == "BUY", ( C - entry ), ( entry - C ) ), 2.2 ) ), 110, y - 25);;
x = 290;
x2 = 500;

}
 

yasu222

Active Member
#57
Profit earner

SetChartOptions(2,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartOptions(0,chartShowArrows|chartShowDates);


//GfxGradientRect( 180, 30, 1759, 735, ColorRGB(40,40,40), ColorRGB(0,0,40) );
GfxSetOverlayMode(1);
GfxSelectPen( ColorRGB(150,0,0), 1 );
GfxSelectSolidBrush( ColorRGB(0,0,40) );
GfxRectangle( 0,750, 1807, 35 );

GfxSelectPen( ColorRGB(150,0,0), 2 );
GfxSelectSolidBrush( ColorRGB(65,65,65) );
GfxPolygon(250,200,200,250,250,20,200,50);

//GfxSelectPen( ColorRGB(125,0,0), 1 );
//GfxSelectSolidBrush( ColorRGB(0,0,40) );
//GfxRectangle( 10,100, 190, 160 );

GfxSelectPen( ColorRGB(0,0,0), 1 );
GfxSelectSolidBrush( ColorRGB(0,0,0) );
//GfxSetTextAlign( 250 );// center alignment

GfxSetOverlayMode(1);
GfxSelectFont("Times New Roman", 30, 400, True );
GfxSetTextColor( ColorRGB( 105, 105, 105 ) );
GfxSetBkMode(0); // transparent
GfxTextOut("Pathfinder", 15 , 35 );


_SECTION_BEGIN("Flower");
si=Param("Zoom/In Out",5,-50,100,1);
GraphXSpace=si;

r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );

m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(155,155,155),IIf(m1>0 AND m1>s1,ColorRGB(0,125,0),IIf(m1>0 AND m1<s1,ColorRGB(180,30,160),ColorRGB(100,0,0))));

Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
barColor=IIf(Close>Open,ColorRGB(0,245,0),ColorRGB(255,0,0));

//Ctmpl = E_TSKP_COLORTMPL(Open,High,Low,Close,Volume);
total = 0;
//total = total + IIf(tskp_colortmplcnd0 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd1 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd2 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd3 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd4 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd5 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd6 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd7 > 0, 1, -1);
//total = total + IIf(tskp_colortmplcnd8 > 0, 1, -1);


for( i = 0; i < BarCount; i++ )
{

if( total >= 5 )
Color = colorLime;
else if( total <= -5 )
Color = colorRed;
else
Color = colorWhite;
}

Candle=ParamList("Candle","Modified Candlestick,Modified Heikin Ashi,Normal Candlestick",1);
if(Candle=="Modified Candlestick")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
Plot (Close,"- Modified Candlestick", Color,ParamStyle( "Style", styleCandle|styleLine | styleThick, maskAll));
}
if(Candle=="Modified Heikin Ashi")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Modified Heikin Ashi", Color, styleCandle|styleLine);
}
if(Candle=="Normal Candlestick")
{
//ColorHighliter = myColor;
//SetBarFillColor( ColorHighliter );
PlotOHLC(O,H,L,C,"Normal Candlestick",barcolor,styleCandle|styleLine);
}


_SECTION_END();



_SECTION_BEGIN("Resistance");
supres=ParamToggle("Sup_Res","No|Yes",1);
if(supres)
{

Prd1=Param("Res_Period1",2,0,200,1);

test = TEMA ( High , Prd1 ) ;

PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,flowerHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,flowerHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,flowerHigh,2);//PeakValue2

MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak

RsColor=ParamColor("ResistColor",ColorRGB(225,0,0));
BrCount=Param("ResistBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
RsColor = colorBlack;
}



MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1", ColorRGB(200,0,0),ParamStyle("ResStyle1",styleDashed|styleNoTitle,maskAll));

RsColor2=ParamColor("Resist2Color",ColorRGB(225,0,0));
BrCount=Param("Resist2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
RsColor2 = colorBlack;
}

MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", RsColor2,ParamStyle("ResStyle2",styleDashed|styleNoTitle,maskAll));

RsColor3=ParamColor("Resist3Color",ColorRGB(225,0,0));
BrCount=Param("Resist3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
RsColor3 = colorBlack;
}


MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", RsColor3,ParamStyle("ResStyle3",styleThick|styleDots|styleNoTitle,maskAll));



_SECTION_END();


_SECTION_BEGIN("Support");

Prd2=Param("Sup_Period1",2,0,200,1);

test2 = TEMA ( Low , Prd2 ) ;

SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,flowerLow,0);//PeakValue0
SPV1 = ValueWhen(SP,flowerLow,1);//PeakValue1
SPV2 = ValueWhen(SP,flowerLow,2);//PeakValue2

MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak

SpColor=ParamColor("SupColor",ColorRGB(0,225,0));
BrCount=Param("SupBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
SpColor = colorBlack;
}


MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1",SpColor,ParamStyle("SupportLine1",styleDashed|styleNoTitle,maskAll));

SpColor2=ParamColor("SupColor2",ColorRGB(0,200,0));
BrCount=Param("Sup2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
SpColor2 = colorBlack;
}


MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2",Spcolor2,ParamStyle("SupportLine2",styleDashed|styleNoTitle,maskAll));

SpColor3=ParamColor("SupColor3",ColorRGB(0,175,0));
BrCount=Param("Sup3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
SpColor3 = colorBlack;
}


MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3",SpColor3,ParamStyle("SupportLine3",styleThick|styleDots|styleNoTitle,maskAll));
}
_SECTION_END();


_SECTION_BEGIN("TSKPPUSHDOTS");
if(Candle=="Modified Heikin Ashi")
{
//Combo = E_TSKPCOMBO(Open,High,Low,Close,Volume);
//NewUpDown = E_TSKPNEWUPDOWN(Open,High,Low,Close,Volume);
//UpDown7 = 0.5*(High+Low) - E_TSKPSTOPLINE(High,Low,Close);
//r=Param("Red",0,0,255,1);
//g=Param("Green",0,0,255,1);
//b=Param("Blue",0,0,255,1);

if(Candle=="Normal Candlestick" OR Candle=="Modified Candlestick")
{
PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), ColorRGB(0,125,255),0, Low, -8);
PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), ColorRGB(225,0,0),0, High, 8);
}

else
{
//PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), ColorRGB(0,255,0),0, flowerlow, -12);
//PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), ColorRGB(255,0,0),0, flowerhigh, 12);
}
}
_SECTION_END();

Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +", {{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 )) );


_SECTION_BEGIN("TSKPPIVOT");

if(Candle=="Modified Heikin Ashi")
{
CHiPr = 0;
CLoPr = 9999999;
blsLong = 0;
PrevCOBar = 0;
NumBars = 0;
PrePP = 0;
PrevLowVal = 9999999;
BuySig = 0;
blsShort = 0;
PrevHiVal = 0;
blsNewCO = 0;
BarDif = 0;

//KPA900Val = E_TSKPA900(Close);
//KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);

// -- Create 0-initialized arrays the size of barcount
aHPivs = flowerHigh - flowerHigh;
aLPivs = flowerLow - flowerLow;
aHiVal = flowerHigh - flowerHigh;
aLoVal = flowerLow - flowerLow;


//Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
//sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);


for (curBar=0; curBar < BarCount-1; curBar++)
{

if ( curBar == 0 )
{
CHiPr = flowerHigh[curBar];
CHiBar = curBar;
CLoPr = flowerLow[curBar];
CLoBar = curBar;
blsLong = 0;
blsShort = 0;
blsNewCO = 0;
PrePP = 0;
PrevCOBar = 0;
PrevHiVal = flowerHigh[curBar];
PrevLowVal = flowerLow[curBar];
BuySig = 0;
SellSig = 0;
blsLL = 0;
}

if (flowerHigh[CurBar] >= CHiPr) {
CHiPr = flowerHigh[CurBar];
ChiBar = CurBar;
}

if (flowerLow[CurBar] <= CLoPr) {
CLoPr = flowerLow[CurBar];
CLoBar = CurBar;
}

//if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
BarDif = CurBar - PrevCOBar;
if (BarDif >= NumBars) {
blsLong = 1;
blsShort = 0;
blsNewCO = 1;
PrevCOBar = CurBar;
}
}

//if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
BarDif = CurBar - PrevCOBar;
if (BarDif >= NumBars) {
blsLong = 0;
blsShort = 1;
blsNewCO = 1;
PrevCOBar = CurBar;
}
}

if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
LVal = CurBar - CLoBar;
for (j= CLoBar-1; j <= CLoBar+1; j++)
{
if (j >=0) {
aLPivs[j] = 1;
aLoVal[j] = CLoPr;
}
}
PrePP = -1;
blsNewCO = 0;
CHiPr = flowerHigh[CurBar];
CHiBar = CurBar;
CLoPr = flowerLow[Curbar];
CLoBar = CurBar;
}
// else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
HVal = CurBar - CHiBar;
for (j= CHiBar-1; j <= CHiBar+1; j++)
{
if (j >=0) {
aHPivs[j] = 1;
aHiVal[j] = CHiPr;
}
}
PrePP = 1;
blsNewCO = 0;
CHiPr = flowerHigh[CurBar];
CHiBar = CurBar;
CLoPr = flowerLow[Curbar];
CLoBar = CurBar;
//}
//}

PlotShapes(IIf(aHPivs == 1, 21,shapeNone), ColorRGB(255,0,145),0, aHiVal,Offset = 20);
PlotShapes(IIf(aHPivs == 1, 15,shapeNone), ColorRGB(200,50,75),0, aHiVal,Offset = 20);
PlotShapes(IIf(aLPivs == 1, 21,shapeNone), ColorRGB(0,125,225),0, aLoVal, Offset = -20);
PlotShapes(IIf(aLPivs == 1, 15,shapeNone), ColorRGB(0,125,255),0, aLoVal, Offset = -20);
//}


_SECTION_END();



_SECTION_BEGIN("TSKPMoMo");

if(Candle=="Modified Heikin Ashi")
{
blsLong = 0;
//KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
// tskp_upsell, tskp_triggerline, tskp_triggerlinevma
//sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
//KPTriggerLine = tskp_triggerline;
//KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
//tskp_fast2val1, tskp_fast2val2
//dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
//KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1);



//Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
//sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
//sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);

// tskp_mediumma,tskp_mediumup,tskp_mediumdown
//dummy = E_TSKPMEDIUM(Close);
//KPMediumUP = tskp_mediumup;
//KPMediumDwn = tskp_mediumdown;
//KPMediumMA = tskp_mediumma;

// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
aHiVal = H - H;
aLoVal = L - L;


for (curBar=5; curBar < BarCount-1; curBar++)
{


if( (blsLong == -1) OR (blsLong == 0))
{
if ((sctotal[CurBar] >= 5) AND (KPMediumUP[CurBar] > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == 1) AND
(KPFast2Val[CurBar] == 1) AND (KPTriggerLine[CurBar] >= KPStopLine[CurBar] ))
{
blsLong = 1;
aLPivs[CurBar] = 1;
aLoVal[CurBar] = Low[CurBar];
}
}

if( (blsLong == 1) OR (blsLong == 0))
{
if ((sctotal[CurBar] <= -5) AND (KPMediumDwn[CurBar] < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == -1) AND
(KPFast2Val[CurBar] == -1) AND (KPTriggerLine[CurBar] <= KPStopLine[CurBar] ))
{
blsLong = -1;
aHPivs[Curbar] = 1;
aHiVal[Curbar] = High[Curbar];
}
}

if ((blsLong == 1) AND ((sctotal[CurBar] < 5) OR (KPMediumUP[CurBar] < KPMediumMA[CurBar] ) OR
(KPFast2Val[CurBar] < 1) OR (KPFast3Val[CurBar] < 1) OR (KPTriggerLine[CurBar] < KPStopLine[CurBar] )) )
{
blsLong= 0;
}

if ((blsLong == -1) AND ((sctotal[CurBar] > -5) OR (KPMediumDwn[CurBar] > KPMediumMA[CurBar] ) OR
(KPFast2Val[CurBar] > -1) OR (KPFast3Val[CurBar] > -1) OR
(KPTriggerLine[CurBar] > KPStopLine[CurBar] )) )
{
blsLong = 0;
}
}

PlotShapes (IIf(aHPivs == 1, shapeHollowSmallSquare, shapeNone) ,colorRed, layer = 0, yposition = flowerHigh, offset = 12 );
PlotShapes (IIf(aLPivs == 1, shapeHollowSmallSquare, shapeNone) ,colorLime, layer = 0, yposition = flowerLow, offset = -12 );

}
_SECTION_END();

_SECTION_BEGIN("TSKPEBand");
/* Standard Error Bands */
Periods = Param("Standard Error", 20, 3, 200, 1);
Smooth = Param("Smooth",12,2,100,1);


LRCurve = LinearReg( C, periods );
MALRCurve = MA(LRCurve, Smooth);
SEValue = StdErr( C, periods );
SErrorAvg = MA(SEValue, Smooth);

LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;

Plot( MALRCurve , "MidBand", ParamColor("ColorMB",ColorRGB(0,200,0)) , ParamStyle("StyleMB", style=styleDashed, Mask=maskDefault ));
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorTeal) , ParamStyle("StyleUp", style=styleDashed, Mask=maskDefault ));
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorTeal), ParamStyle("StyleLo", style=styleDashed, Mask=maskDefault ));
_SECTION_END();


_SECTION_BEGIN("Cloud Setting");
//Cloud
ParmCloud = ParamToggle("Cloud", "No|Yes", 1);

CloudResColor=ParamColor("CloudResColor",ColorRGB(15,15,15));
CR=Upperband;
CS=Lowerband;

if(parmCloud == 1)
{
PlotOHLC( CS, CS, CR,CR, "Band", CloudResColor, styleCloud | styleNoLabel|styleNoTitle);
}

_SECTION_END();

_SECTION_BEGIN("KPL Swing");
//Copyright Kamalesh Langote. Email:[email protected]. More details at http://www.vfmdirect.com/kplswing
//Save indicator as "kplswing.afl" in C: program files > Amibroker > Formulas > Custom folder and then drap and drop on price chart
no=Param( "Swing", 20, 1, 55 );
tsl_col=ParamColor( "Color", colorCycle );

res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); // or styleaArea

Buy=Cross(C,tsl);
Short=Cross(tsl,C);
shape=Buy*shapeUpArrow + Short*shapeDownArrow;
PlotShapes(shape,IIf(Buy,tsl_col,tsl_col),0,IIf(Buy,Low,High));
Execute_RoboTrade("Profit Earner");
_SECTION_END();


///////////This system has kpl swing with ishimaku clouds and targets and stop loss

/////////////////////////////////// Programs Begins

//////////////////with near days high low scanner



////////////////////////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
no=10;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
s5d=IIf(avn==1,sup,res);

if (showsl == 0)
//{Plot(s5d,"Stop Loss",colorCustom14,styleDots);}
exitlong = Cross(s5d, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, s5d);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);

Buy1 = exitshort;
Sell1 = exitlong;
//Short = Sell;
//Cover = Buy;
Buy1 = ExRem(Buy1,Sell1);
Sell1 = ExRem(Sell1,Buy1);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy1, "", "BUY @ " + C, 1 );
AlertIf( Sell1, "", "SELL @ " + C, 2 );

for(i=BarCount-1;i>1;i--)
{
if(Buy1 == 1)
{
entry = C;
sig = "BUY";
sl = s5d;
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(sell1 == 1)
{
sig = "SELL";
entry = C;
sl = s5d;
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -1));
sl = ssl[BarCount-1];

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);

Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);

}


printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));

if (messageboard == 0 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color

GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
GfxTextOut( ( " Trading System "),88,y-165);
GfxTextOut( (" "),27,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-140) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-120);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 88, y-22);;

}
//////////////////////////////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBlack) );
Hor=Param("Horizontal Position",750,800,800,800);
Ver=Param("Vertical Position",27,27,27,27);
GfxTextOut(""+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();

////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////////////////





/*Plot EMA*/
Plot( EMA( Close,13), "13 EMA", colorRed,styleLine);
Plot( EMA( Close,34), "34 EMA", colorBlue,styleLine);
Plot( EMA( Close,55), "55 EMA", colorBlack,styleLine);
Plot( EMA( Close,89), "89 EMA", colorYellow,styleLine);

//////////////////////Clouds
_SECTION_BEGIN("Ichimoku Cloud Charts");
GraphXSpace =1;
prds = Param("Standard Line Periods?", 13,5,26,1);
prds1 = Param("Turning Line Periods?", 3,3,10,1);
prds2 = Param("Delayed Line Periods?", 12,4,25,1);
prds3 = Param("Spans Periods?", 16,10,52,1);
TL = ( HHV( H, prds1) + LLV( L, prds1) )/2;
SL = ( HHV( H, prds) + LLV( L, prds) )/2;
DL = Ref( C, prds2);
Sp1 = Ref( ( SL + TL )/2, -prds2);
Sp2 = Ref( (HHV( H, prds3) + LLV(L, prds3))/2, -prds2);
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
if ( ParamToggle( "Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip = StrFormat( "Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: " + NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
}
PlotOHLC (Sp1,Sp1,Sp2,Sp2,"Cloud",IIf(Sp1>Sp2,ParamColor("Span1 Color", ColorRGB(0,255,0)),ParamColor("Span2 Color",ColorRGB(255,104,32))),styleCloud);

_SECTION_END();

/////////////////////////////////////Kpl Swing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//kpl swing formula here
//---- heikin ashi
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), .40);
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * IIf(StrFind(Name(),"JPY"),100,10000);
// Plot(EMA(HaClose,9),"",colorWhite, styleLine);
// Plot(EMA(HaClose,18),"",colorBlack, styleLine);
_SECTION_BEGIN("KPL Swing");
no=Param( "Swing", 10, 1, 55 );
tsl_col=ParamColor( "Color", colorCycle );

res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); // or styleaArea

_SECTION_END();





////////////////////details of stock at the title

_SECTION_BEGIN("Price");
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 ) ) ));

_SECTION_END();



/////////////////////weekly high low

/////////////////Stock near days high and low scanner
TimeFrameSet(inHourly);
H1 = HHV(H, 1) ;

H2= (H1-C)< .001*C;

L1 = LLV(L,1) ;


L2 = (C-L1) < .001*C ;

TimeFrameRestore() ;

SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);



Filter = H2 OR L2 ;

Buy1 = H2 ;
sell1 = L2 ;


///////////////////////////candle stick reader


_SECTION_BEGIN("Candle Identification");
O1 = Ref(O,-1);O2 = Ref(O,-2);
H1 = Ref(H,-1);H2 = Ref(H,-2);
L1 = Ref(L,-1);L2 = Ref(L,-2);
C1 = Ref(C,-1);C2 = Ref(C,-2);
function CandlePattern(P)
{
global PatternName;
if(P == 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND
(O-C)/(.001+H-L)>.6); }
else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND
((H-L)>(3*(O-C)))); }
else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND
((C-O)/(.001+H-L)>.6)); }
else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND
((H-L)>(3*(C-O)))); }
else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND
C==L); }
else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND
O==L); }
else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND
C==L); }
else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND
C==H); }
else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND
O==H); }
else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND
O==L); }
else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND
((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND
((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))
AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))
AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND
((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND
(((C-L)/(.001+H-L))<.4)); }
else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND
((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND
(((O-L)/(.001+H-L))<.4)); }
else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1)
AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)
AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND
((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND
((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND
(O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND
(C<C1)); }
else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1)
AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND
((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND
(C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND
(C>C1)); }
else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O)
AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND
(C>C1) AND (O>O1)); }
else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND
(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6)); }
else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)
AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND
(C<C1) AND (O<O1)); }
else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)
AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND
(O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND
(((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND
(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND
(MA(C,13)-Ref(MA(C,13),-4)>0); }
else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND
(O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1)
AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2); }
else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
else if(P == 37) { PatternName = "GapUp"; Pv = GapUp(); }
else if(P == 38) { PatternName = "GapDown"; Pv = GapDown(); }
else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
else if(P == 43) { PatternName = "DoubleGapUp"; Pv = GapUp() AND
Ref(GapUp(),-1); }
else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND
Ref(GapDown(),-1); }
return Pv;
}

PatternNameList = "";
for(Cp=0; Cp<=44; Cp++)
{
VarSet("Pattern"+NumToStr(Cp,1.0),CandlePattern(cP));
PatternNameList = PatternNameList +PatternName+",";
}

BI = BarIndex();
SelectedBar = SelectedValue(BI) -BI[0];
//Selectedbar = Status("lastvisiblebar")-1;
PStr="";
for(Cp=0; Cp<=44; Cp++)
{
Temp = VarGet("Pattern"+NumToStr(Cp,1.0));
if(temp[SelectedBar]) Pstr=Pstr+"#"+NumToStr(Cp,1.0)+" - "+StrExtract(PatternNameList,Cp)+"\n";
}


FS=Param("Font Size",11,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",237,1,1200,1);
Ver=Param("Vertical Position",50,1,830,1);
GfxTextOut("Candle Reader= "+Pstr, Hor , Ver );




_SECTION_END();
 
#58
HI yasu222,
THE LAST AFL PROFIT EARNER REPORT THIS ERROR ON THIS LINE:

Execute_RoboTrade("Profit Earner");

do you mean the robotrade supertrend afl? Is the execute function operational in ami?

regards
 

yasu222

Active Member
#60
International Pivots in Rupees-MY_PIVOTS

_SECTION_BEGIN("MY_PIVOTS");
GraphXSpace = 5 ;
SetChartOptions(0,chartShowArrows|chartShowDates);
ppl = ParamToggle("Plot Pivot Levels","Off|On",1);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = -33.5;

/* This code calculates the My high, low and close (in $s or Euros) */

Currency = Param("Today Currency Open Price",1, 1,300, 1);
Hi1 = Param("My_High_Value",10, 1,30000, 1);
Hi = Hi1*Currency;
Lo1 = Param("My_Low_Value",10, 1,30000, 1);
Lo = Lo1*Currency;
Cl1 = Param("My_Close_Value",10, 1,30000, 1);
C1 = Cl1*Currency;


/* This code calculates My Piovts */

rg = (Hi - Lo);
bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
r12 = (bp+r1)/2;
s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
s12 = (bp+s1)/2;
r2 = bp + r1 - s1; r2I = LastValue (r2,1);
r23 = (r1+r2)/2;
s2 = bp - r1 + s1; s2I = LastValue (s2,1);
s23 = (s1+s2)/2;
//r3 = bp + r2 - s1; r3I = LastValue (r3,1);
//s3 = bp - r2 + s1; s3I = LastValue (s3,1);
//r4 = bp + r2 - s2; r4I = LastValue (r4,1);
//s4 = bp - r2 + s2; s4I = LastValue (s4,1);

//Condition for BUY Signals at Lines//
Bcond1 = Cross(s12,L);
Bcond2 = Cross(S1,L);
Bcond3 = Cross(s23,L);
//Condition for Sell Signals at Lines//
Scond1 = Cross(H,r12);
Scond2 = Cross(H,r1);
Scond3 = Cross(H,r23);
Buy1 = (Bcond1+Bcond2+Bcond3);
Sell1 = (Scond1+Scond2+Scond3);
Buy=ExRem(Buy1,Sell1);
Sell=ExRem(Sell1,Buy1);
Short=Sell ;
Cover=Buy;
PlotShapes(Buy1*shapeUpArrow,colorPink,0,L,-20);
PlotShapes(Sell1*shapeDownArrow,colorBrightGreen,0 ,H,-35);
if(ppl==1) {
Plot(bp,"",colorWhite,styleLine|styleDots|styleNoRescale);
Plot(s1,"",colorWhite,styleLine|styleNoRescale);
Plot(s12,"",colorWhite,styleLine|styleNoRescale);
//Plot(s2,"",colorWhite,styleLine|styleNoRescale);
Plot(s23,"",colorWhite,styleLine|styleNoRescale);
//Plot(s3,"",colorRed,styleLine|styleNoRescale);
//Plot(s4,"",colorRed,styleLine|styleNoRescale);
Plot(r1,"",colorYellow,styleLine|styleNoRescale);
Plot(r12,"",colorYellow,styleLine|styleNoRescale);
//Plot(r2,"",colorYellow,styleLine|styleNoRescale);
Plot(r23,"",colorYellow,styleLine|styleNoRescale);
//Plot(r3,"",colorGreen,styleLine|styleNoRescale);
//Plot(r4,"",colorGreen,styleLine|styleNoRescale);
PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +0.05, colorWhite);
PlotText(" r12 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorBrightGreen);
PlotText(" r1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorBrightGreen);
PlotText(" r23 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorBrightGreen);
//PlotText(" r2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorBrightGreen);
PlotText(" s12 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorPink);
PlotText(" s1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorPink);
PlotText(" s23 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorPink);
//PlotText(" s2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorPink);
//PlotText(" r3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
//PlotText(" s3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
//PlotText(" r4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
//PlotText(" s4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
}

//--end----------------------------------------------------------------------------
_SECTION_END();
 

Similar threads