Converting AFL to MQ4

#1
HI all

I am using Amibroker and i want to convert the following AFL code to MQ4
as beginner in Forex

can any one help me in this regards




/*
This is a modified version of the Heikin-Ashi HaDiffCO indicator.
This modification gives interesting results which are still being
examined. The best signals seem to come from weekly stock charts.
Other investment products have not yet been thoroughly tested.

Buy signals (reverse these signals to go short):
1) Green line crosses above upper bollinger (red). Stronger signal
if green line has departed from dark red line (which should be lower).

2) Green line crosses above lower bollinger (red). Stronger signal
if green line has departed from dark red line (which should be higher).

3) Dark red and also green line cross above zero (0) line (black)

Reversal signals:
1) Dark red line and also green line "kiss" the upper bollinger (red).
Both dark red and green line need to be nearly on top of each other for
this signal to be clear.

2) Dark red line and also green line "kiss" the lower bollinger (red).
Both dark red and green line need to be nearly on top of each other for
this signal to be clear.

Trend signals (long-term buy and short signals):
1) Green line crossing above zero (0) line (black) indicates new uptrend.
Stronger signal if dark red line is above zero.

2) Green line crossing below zero (0) line (black) indicates new downtrend.
Stronger signal if dark red line is below zero.
*/

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

HaDiffCO = (HaClose-HaOpen);
VarRedLine = WMA(HaDiffCO,5);
VarBlueLine = MA(HaDiffCO,8);
Per = Param("MA Periods",8,3,50,1);
Plot(HaDiffCO,"HaDiffCO",colorDarkRed);

P = ParamField("Price field",-1);
HDCPeriods = 15;
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, HDCPeriods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style
);
Plot( BBandBot( P, HDCPeriods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style
);

VarAMA = Param("varAMA",0.1,0,2,0.01);
HaClose2=(H+L+C)/3;
HaOpen2=AMA(Ref(HaClose2,-1),VarAMA);
HaHigh2=Max(H,Max(HaClose2,HaOpen2));
HaLow2=Min(L,Min(HaClose2,HaOpen2));
HaDiffCO2 = HaClose2-HaOpen2;

Plot(HaDiffCO2,"HaDiffCO2",colorGreen);
Plot(0,"0",colorBlack,styleDots);

(color=IIf(HaDiffCO2<0 AND HaDiffCO2>HaDiffCO,colorGreen,IIf(HaDiffCO2>0 AND HaDiffCO2>HaDiffCO,colorBrightGreen,IIf(HaDiffCO2>0 AND HaDiffCO2<HaDiffCO,colorOrange,colorRed))));
Plot(HaDiffCO2,"HaDiffCO2",color,styleLine);


_SECTION_END();
 
#2
Re: I Need Converting MQ4 to AFL for super scalper

/*
Generated by EX4-TO-MQ4 decompiler LITE V4.0.409.1e [-]
Website: https://purebeam.biz
E-mail : [email protected]
*/

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Yellow

extern int SignalPeriod = 144;
int gi_80 = 0;
extern int NR_SLIPE = 3;
int gi_88 = PRICE_CLOSE;
extern double FilterNumber = 1.0;
bool gi_100 = TRUE;
int gi_104 = 0;
extern int lineWidth = 3;
extern int barsToDrawLine = 300;
extern bool skipSingleBarSignal = FALSE;
extern int aTake_Profit = 500;
extern int aStop_Loss = 200;
extern bool aAlerts = TRUE;
extern bool EmailOn = TRUE;
datetime gt_136;
string gs_148;
string gs_156 = "fx_NR_Scalping";
double gda_164[];
double gda_168[];
double gda_172[];
double gda_176[];
int gi_180;
string gs_184;
int gi_192 = 0;

string GetTimeFrameStr() {
string ls_4;
switch (Period()) {
case PERIOD_M1:
ls_4 = "M1";
break;
case PERIOD_M5:
ls_4 = "M5";
break;
case PERIOD_M15:
ls_4 = "M15";
break;
case PERIOD_M30:
ls_4 = "M30";
break;
case PERIOD_H1:
ls_4 = "H1";
break;
case PERIOD_H4:
ls_4 = "H4";
break;
case PERIOD_D1:
ls_4 = "D1";
break;
case PERIOD_W1:
ls_4 = "W1";
break;
case PERIOD_MN1:
ls_4 = "MN1";
break;
default:
ls_4 = Period();
}
return (ls_4);
}

void DisplayAlert(string as_0, double ad_8, double ad_16, double ad_24) {
string ls_32;
string ls_40;
string ls_48;
string ls_56;
if (Time[0] != gt_136) {
gt_136 = Time[0];
if (gs_148 != as_0) {
gs_148 = as_0;
if (ad_8 != 0.0) ls_48 = " @ Price " + DoubleToStr(ad_8, 4);
else ls_48 = "";
if (ad_16 != 0.0) ls_40 = ", TakeProfit " + DoubleToStr(ad_16, 4);
else ls_40 = "";
if (ad_24 != 0.0) ls_32 = ", StopLoss " + DoubleToStr(ad_24, 4);
else ls_32 = "";
ls_56 = gs_184 + "Scalping " + aRperiodf() + " Alert " + as_0
+ "\n"
+ as_0 + ls_48 + ls_40 + ls_32
+ "\nDate & Time = " + TimeToStr(TimeCurrent(), TIME_DATE) + " " + TimeHour(TimeCurrent()) + ":" + TimeMinute(TimeCurrent()) + " ";
Alert(ls_56, Symbol(), ", ", Period(), " minutes chart");
PlaySound("alert.wav");
if (EmailOn) SendMail(gs_184, ls_56);
}
}
}

int init() {
IndicatorBuffers(4);
if ((!SetIndexBuffer(0, gda_164)) && !SetIndexBuffer(1, gda_168) && (!SetIndexBuffer(2, gda_172)) && (!SetIndexBuffer(3, gda_176))) Print("cannot set indicator buffers!");
if (gi_100) {
SetIndexStyle(0, DRAW_ARROW, EMPTY, lineWidth - 3);
SetIndexStyle(1, DRAW_ARROW, EMPTY, lineWidth - 3);
SetIndexStyle(2, DRAW_ARROW, EMPTY, lineWidth - 3);
SetIndexArrow(0, 159);
SetIndexArrow(1, 159);
SetIndexArrow(2, 159);
} else {
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexStyle(2, DRAW_LINE);
}
gi_180 = SignalPeriod + MathFloor(MathSqrt(SignalPeriod));
SetIndexDrawBegin(0, gi_180);
SetIndexDrawBegin(1, gi_180);
SetIndexDrawBegin(2, gi_180);
IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1.0);
IndicatorShortName("Scalping(" + SignalPeriod + ")");
SetIndexLabel(0, "Scalping");
gs_184 = Symbol() + " (" + GetTimeFrameStr() + "): ";
gs_148 = "";
ArrayInitialize(gda_164, EMPTY_VALUE);
ArrayInitialize(gda_172, EMPTY_VALUE);
ArrayInitialize(gda_168, EMPTY_VALUE);
return (0);
}

int deinit() {
DelObj();
return (0);
}

int start() {
double ld_20;
int li_28;
int li_8 = IndicatorCounted();
if (li_8 < 1) {
for (int li_4 = 0; li_4 <= gi_180; li_4++) gda_176[Bars - li_4] = 0;
for (li_4 = 0; li_4 <= SignalPeriod; li_4++) {
gda_164[Bars - li_4] = EMPTY_VALUE;
gda_168[Bars - li_4] = EMPTY_VALUE;
gda_172[Bars - li_4] = EMPTY_VALUE;
}
}
int li_0 = Bars - li_8;
for (li_4 = 1; li_4 < li_0; li_4++) gda_176[li_4] = 2.0 * iMA(NULL, 0, MathFloor(SignalPeriod / FilterNumber), gi_80, NR_SLIPE, gi_88, li_4) - iMA(NULL, 0, SignalPeriod, gi_80, NR_SLIPE, gi_88, li_4);
double ld_12 = iMAOnArray(gda_176, 0, MathFloor(MathSqrt(SignalPeriod)), 0, NR_SLIPE, 1);
for (li_4 = 2; li_4 < li_0 + 1; li_4++) {
ld_20 = iMAOnArray(gda_176, 0, MathFloor(MathSqrt(SignalPeriod)), 0, NR_SLIPE, li_4);
li_28 = 0;
if (ld_20 > ld_12) {
gda_172[li_4 - 1] = ld_12 - gi_104 * Point;
li_28 = 1;
} else {
if (ld_20 < ld_12) {
gda_164[li_4 - 1] = ld_12 + gi_104 * Point;
li_28 = 2;
} else {
gda_164[li_4 - 1] = EMPTY_VALUE;
gda_168[li_4 - 1] = ld_12;
gda_172[li_4 - 1] = EMPTY_VALUE;
li_28 = 3;
}
}
if (li_8 > 0) {
}
ld_12 = ld_20;
}
if (li_0 > barsToDrawLine) li_0 = barsToDrawLine;
for (li_4 = 2; li_4 <= li_0; li_4++) {
if (gda_164[li_4 - 1] != EMPTY_VALUE) {
if (gda_164[li_4] != EMPTY_VALUE) drawLineSegment(li_4 - 1, li_4, 1);
else drawLineSegment(li_4 - 1, li_4, 10);
}
if (gda_172[li_4 - 1] != EMPTY_VALUE) {
if (gda_172[li_4] != EMPTY_VALUE) {
drawLineSegment(li_4 - 1, li_4, -1);
continue;
}
drawLineSegment(li_4 - 1, li_4, -10);
}
}
if (aAlerts) {
if ((skipSingleBarSignal == FALSE && gda_172[1] != EMPTY_VALUE && gda_172[2] == EMPTY_VALUE) || (skipSingleBarSignal == TRUE && gda_172[1] != EMPTY_VALUE && gda_172[2] != EMPTY_VALUE &&
gda_172[3] == EMPTY_VALUE)) DisplayAlert("Sell signal", Close[1], aGetTPs(), aGetSLs());
if ((skipSingleBarSignal == FALSE && gda_164[1] != EMPTY_VALUE && gda_164[2] == EMPTY_VALUE) || (skipSingleBarSignal == TRUE && gda_164[1] != EMPTY_VALUE && gda_164[2] != EMPTY_VALUE &&
gda_164[3] == EMPTY_VALUE)) DisplayAlert("Buy signal", Close[1], aGetTPl(), aGetSLl());
}
return (0);
}

double aGetTPs() {
return (Bid - aTake_Profit * Point);
}

double aGetTPl() {
return (Ask + aTake_Profit * Point);
}

double aGetSLs() {
return (Bid + aStop_Loss * Point);
}

double aGetSLl() {
return (Ask - aStop_Loss * Point);
}

int aRperiodf() {
return (10000.0 * (SignalPeriod * Point));
}

void DelObj() {
string ls_0;
int li_12;
for (int li_8 = ObjectsTotal() - 1; li_8 >= 0; li_8--) {
ls_0 = ObjectName(li_8);
li_12 = StringLen(gs_156);
if (StringSubstr(ls_0, 0, li_12) == gs_156) ObjectDelete(ls_0);
}
}

void drawLineSegment(int ai_0, int ai_4, int ai_8) {
double ld_20;
double ld_28;
color li_36;
if (ai_8 > 0) {
ld_20 = gda_164[ai_0];
if (ai_8 == 1) ld_28 = gda_164[ai_4];
else ld_28 = gda_172[ai_4];
li_36 = Blue;
} else {
ld_20 = gda_172[ai_0];
if (ai_8 == -1) ld_28 = gda_172[ai_4];
else ld_28 = gda_164[ai_4];
li_36 = Yellow;
}
int li_12 = Time[ai_0];
int li_16 = Time[ai_4];
if (ld_20 == EMPTY_VALUE || ld_28 == EMPTY_VALUE) {
Print("Empty value for price line encountered!");
return;
}
string ls_40 = gs_156 + "_segment_" + li_36 + li_12 + "_" + li_16;
ObjectDelete(ls_40);
ObjectCreate(ls_40, OBJ_TREND, 0, li_12, ld_20, li_16, ld_28, 0, 0);
ObjectSet(ls_40, OBJPROP_WIDTH, lineWidth);
ObjectSet(ls_40, OBJPROP_COLOR, li_36);
ObjectSet(ls_40, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(ls_40, OBJPROP_RAY, FALSE);
}
 
#3
Re: Converting MQ4 to AFL

HI Programmer

I am using Amibroker and i Need to convert the following MQ4 code to AFL
can any one help me in this regards



//+------------------------------------------------------------------+
//| ZIG ZAG NON REPAINT.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright©2010"
#property link ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Aqua
extern int Candle=100;
extern int Length=1;
double ExtMapBuffer1[];

int init()
{
SetIndexEmptyValue(0,0.0);
SetIndexStyle(0,DRAW_SECTION, 4,4);
SetIndexBuffer(0,ExtMapBuffer1);

return(0);
}
int deinit()
{
return(0);
}
int start()
{
int cnt,ticket,counted_bars=IndicatorCounted();
int shift,Swing,Swing_n,uzl,i,zu,zd,mv;
double LL,HH,BH,BL,NH,NL;
double Uzel[10000][3];
string text;

if (High[1]> High[0]) {Comment("SELL !!");}

else if (High[1]< High[0]) {Comment("BUY !!");}
Swing_n=0;Swing=0;uzl=0;
BH =High[Candle];BL=Low[Candle];zu=Candle;zd=Candle;

for (shift=Candle;shift>=0;shift--) {
LL=10000000;HH=-100000000;
for (i=shift+Length;i>=shift+1;i--) {
if (Low< LL) {LL=Low;}
if (High>HH) {HH=High;}
}
if (Low[shift]<LL && High[shift]>HH){
Swing=2;
if (Swing_n==1) {zu=shift+1;}
if (Swing_n==-1) {zd=shift+1;}
} else {
if (Low[shift]<LL) {Swing=-1;}
if (High[shift]>HH) {Swing=1;}
}

if (Swing!=Swing_n && Swing_n!=0) {
if (Swing==2) {
Swing=-Swing_n;BH = High[shift];BL = Low[shift];
}
uzl=uzl+1;
if (Swing==1) {
Uzel[uzl][1]=zd;
Uzel[uzl][2]=BL;
}
if (Swing==-1) {
Uzel[uzl][1]=zu;
Uzel[uzl][2]=BH;
}
BH = High[shift];
BL = Low[shift];
}

if (Swing==1) {
if (High[shift]>=BH) {BH=High[shift];zu=shift;}}
if (Swing==-1) {
if (Low[shift]<=BL) {BL=Low[shift]; zd=shift;}}
Swing_n=Swing;
}
for (i=1;i<=uzl;i++) {
mv=StrToInteger(DoubleToStr(Uzel[1],0));
ExtMapBuffer1[mv]=Uzel[2];
}

return(0);
}
 
#4
hi

i am using buy / sell arrow in amibroker afl

can anybody convert to mq4

SECTION_BEGIN("");
SetBarsRequired(200,0);
SetChartBkColor(ParamColor("Outer panel color ",colorLightGrey));
SetChartBkGradientFill( ParamColor("Inner panel color upper half", colorLightGrey),ParamColor("Inner panel color lower half", colorPaleBlue)); // color of inner panel
SetChartOptions(0, chartShowDates, chartGridMiddle);
GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",2,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",20,3,20,1),3,20,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 ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );
j=Haclose;


f=ATR(15);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;
NW[0] = 0;
NW[BarCount-1] = Null;


for(i = 1; i < BarCount-1; 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];
}
}
}
}



Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
Buy=NW<HACLOSE;
Sell=NW>HACLOSE;
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy );

Short=Sell;
Cover=Buy;


NMAB= NW<HACLOSE;
NMAS= NW>HACLOSE;

NMA_status= WriteIf(NMAB, "BUY MODE", WriteIf(NMAS, "SELL MODE", "NEUTRAL"));
NMAS_Col=IIf(NMAB, colorBlue, IIf(NMAS, colorRed, colorLightGrey));
Filter=1;
AddColumn( NW[BarCount-1], "SAR", 1.2 );
AddColumn( HACLOSE, "HA Close", 1.2 );
AddColumn( C, "Close", 1.2 );
AddTextColumn(NMA_status, "MODE", 1, colorWhite, NMAS_Col);
AddColumn( DateTime(), "Date / Time", formatDateTime );
_SECTION_END();

_SECTION_BEGIN("");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorBlue)+ Name() + " - " + EncodeColor(colorBlue)+ Interval(2) + EncodeColor(colorBlue) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorBlue)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"",""));
//WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
//WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
//WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
//WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorAqua, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorAqua, 0,L, Offset=-48);
PlotShapes(IIf(Buy, shapeStar, shapeNone),colorAqua, 0,L, Offset=-55);
PlotShapes(IIf(Buy, shapeSmallCircle, shapeNone),colorBlue, 0,L, Offset=-55);
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorYellow, 0,H, Offset=60);
PlotShapes(IIf(Sell, shapeSmallCircle, shapeNone),colorRed, 0, H, Offset=60);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorYellow, 0,H, Offset=53);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorYellow, 0,H, Offset=-45);
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );


for(i=BarCount-1;i>1;i--)
{
if(Buy == 1)
{
entry = H;
sig = "BUY";
sl = Ref(NW,-1);
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(Sell == 1)
{
sig = "SELL";
entry = L;
sl = Ref(NW,-1);
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorBlue, colorRed);
ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -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);



messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue );
}
else
{
GfxSelectSolidBrush( colorRed );
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorBlue, 1);
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*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)), 13, y-22);

}

_SECTION_END();



_SECTION_BEGIN("");

//Magfied Market Price
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBlue) );
Hor=Param("Horizontal Position",800,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );

_SECTION_BEGIN("ema_crossover");
//x = EMA(Close,5);
y = EMA(Close,21);
//Plot(EMA(Close,5),"",colorRed,styleLine);
Plot(EMA(Close,21),"",colorBlack,styleLine);

//Buy=Cross(x,y);
//PlotShapes(shapeUpArrow*Buy,colorGreen);
//XR=(EMA(Close,5) * (2 / 6 - 1) - EMA(Close,21) * (2 / 11 - 1)) / (2 / 6 - 2 / 11);
//Title = Name() + " " + Date()+" " + EncodeColor( colorBlue ) +"5/21 EMA " +EncodeColor( colorRed )
//+ " O " + O + " H " + H + " L " + L + " C "+ C + "\n";

//Sell=Cross(y,x);
//PlotShapes(shapeDownArrow*Sell,colorRed);
//AlertIf( Sell, "SOUND C:\\Windows\\Media\\chord.wav", "Audio alert", 2 );
//XR=(EMA(Close,21) * (2 / 6 - 1) - EMA(Close,5) * (2 / 11 - 1)) / (2 / 6 - 2 / 11);
//Title = Name() + " " + Date()+" " + EncodeColor( colorBlue ) +"5/21 EMA " +EncodeColor( colorRed )
//+ " O " + O + " H " + H + " L " + L + " C "+ C + "\n";

_SECTION_END();

_SECTION_END();

/*_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

x=Param("xposn",50,0,1000,1);
y=Param("yposn",350,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
//GfxRoundRect( x+45, y+40, x-3, y-2, 0, 0 );
//GfxSetBkMode(1);
GfxSelectFont( "Arial", 14, 700, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Time Left :"+SecsToGo+"", x, y );
_SECTION_END(); */
















_SECTION_BEGIN("");
no=Param( "Swing", 10, 1, 55 );
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( 2, "Ribbon",IIf(C>tsl,colorGreen,colorRed),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
VCol = ParamColor("Vol. Color", colorLime );
VH = Param("Volume Height", 5,1,15,1 );
SetBarFillColor( IIf( V > Ref(V,-1), colorGreen, colorRed) );
PlotOHLC(0,V,0,V,"Volume",VCol,styleCandle|styleOwnScale,VH );

_SECTION_END();
 

Similar threads