Re: XARD - Simple Trend Following Trading System

19653
Lenovo wrote: Fri Apr 25, 2025 4:23 pm Which broker tells the truth?
None. 1 minute timeframe charts are like watching an old western movie. Anything goes, especially if you're in the B Book.
These users thanked the author Jimmy for the post (total 3):
boytoy, Cagliostro, Musashi
Myfxbook live trading results 📊

List of our most powerful reversal indicators + Guide to the "All Averages" Filters (ADXvma, Laguerre etc.)
Fibonacci numbers for indicator settings + How to draw Fibonacci Extensions + How to draw Support & Resistance


Re: XARD - Simple Trend Following Trading System

19657
valeryi wrote: Thu Apr 24, 2025 10:07 pm Good afternoon! Please share your template and indicators. Thank you in advance.
here.
These users thanked the author Neroloft for the post:
valeryi
"That which is, already has been; that which is to be, already has been;"

Re: XARD - Simple Trend Following Trading System

19658
hi xard, iwas trying to convert 2nd dot into mt5 version but i cant fix his 2 warnings:

possible loss of data due to type conversion 2nd Dot revised.mq5 110 44
possible loss of data due to type conversion 2nd Dot revised.mq5 111 44

help please...TIA
//+------------------------------------------------------------------+
//| XU-XARD_2ndDOT.mq5 |
//| Copyright 2023, XARD UNIVERSE |
//| https://forex-station.com |
//+------------------------------------------------------------------+
#property copyright "THIS IS A FREE INDICATOR"
#property link "viewtopic.php?p=1295409935#p1295409935"
#property version "1.00"
#property description "Welcome to XARD UNIVERSE"
#property description "Let light shine out of darkness and illuminate your world"
#property description "and with this freedom leave behind your cave of denial"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots 4

//--- Input parameters
input bool ShowDots=true; // Show Main Dots
input bool Show2ndDOT=false; // Show 2nd DOT Signals
input bool FillUp=false; // Fill Background
input bool ShowMarks=false; // Show Marks
input bool ShowAlert=false; // Show Alerts
input bool ShowAlertTr=false; // Show Triangle Alerts
input int W1=2; // Line Width 1
input int W2=3; // Line Width 2
input int BarsCount=1000; // Bars to Calculate
input int DATA1=0; // Data Filter
input string copy="1"; // Copy Identifier
input color BuyTriangle=clrBlack; // Buy Triangle Color
input color SellTriangle=clrBlack; // Sell Triangle Color
input color BuyMark=clrBlack; // Buy Mark Color
input color SellMark=clrBlack; // Sell Mark Color

//--- Indicator buffers
double Level1UP[], Level1DN[], Level2UP[], Level2DN[];
double DotPer1=9, DotPer2=36;
int Dev=1, Stp=1, SYM1=159, SYM2=164, Type;
datetime key=D'1970.01.01 00:00', keyTr=D'1970.01.01 00:00'; // Fixed initialization
int DATA2;
string symbol=Symbol();

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
int Buf=-1;

if(ShowDots) Type=DRAW_ARROW;
else Type=DRAW_NONE;

//--- Set Level1UP buffer
Buf+=1;
SetIndexBuffer(Buf,Level1UP,INDICATOR_DATA);
PlotIndexSetInteger(Buf,PLOT_DRAW_TYPE,Type);
PlotIndexSetInteger(Buf,PLOT_ARROW,SYM1);
PlotIndexSetInteger(Buf,PLOT_LINE_WIDTH,W1);
PlotIndexSetInteger(Buf,PLOT_LINE_COLOR,clrBlack);

//--- Set Level1DN buffer
Buf+=1;
SetIndexBuffer(Buf,Level1DN,INDICATOR_DATA);
PlotIndexSetInteger(Buf,PLOT_DRAW_TYPE,Type);
PlotIndexSetInteger(Buf,PLOT_ARROW,SYM1);
PlotIndexSetInteger(Buf,PLOT_LINE_WIDTH,W1);
PlotIndexSetInteger(Buf,PLOT_LINE_COLOR,clrBlack);

//--- Set Level2UP buffer
Buf+=1;
SetIndexBuffer(Buf,Level2UP,INDICATOR_DATA);
PlotIndexSetInteger(Buf,PLOT_DRAW_TYPE,Type);
PlotIndexSetInteger(Buf,PLOT_ARROW,SYM2);
PlotIndexSetInteger(Buf,PLOT_LINE_WIDTH,W2);
PlotIndexSetInteger(Buf,PLOT_LINE_COLOR,clrNONE);

//--- Set Level2DN buffer
Buf+=1;
SetIndexBuffer(Buf,Level2DN,INDICATOR_DATA);
PlotIndexSetInteger(Buf,PLOT_DRAW_TYPE,Type);
PlotIndexSetInteger(Buf,PLOT_ARROW,SYM2);
PlotIndexSetInteger(Buf,PLOT_LINE_WIDTH,W2);
PlotIndexSetInteger(Buf,PLOT_LINE_COLOR,clrNONE);

DATA2 = (DATA1 == 0) ? 5000 : DATA1;

return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
ChartCleaner();
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
if(DotPer1>0) CountZZ(Level1UP,Level1DN,DotPer1,Dev,Stp,rates_total,time,high,low);
if(DotPer2>0) CountZZ(Level2UP,Level2DN,DotPer2,Dev,Stp,rates_total,time,high,low);

if(ShowAlert && key!=time[0])
{
if(Level2UP[0]!=0.0) Alert(" "+symbol+" "+IntegerToString(Period())+" "+DoubleToString(close[0],_Digits));
if(Level2DN[0]!=0.0) Alert(" "+symbol+" "+IntegerToString(Period())+" "+DoubleToString(close[0],_Digits));
}
key=time[0];

if(!Show2ndDOT) ChartCleaner();
if(Show2ndDOT) Triangles(rates_total,time,high,low);

return(rates_total);
}

//+------------------------------------------------------------------+
//| Draw Triangles function |
//+------------------------------------------------------------------+
void Triangles(const int rates_total, const datetime &time[], const double &high[], const double &low[])
{
bool up;
double OpenPrice=0.0,semafor2d=0.0,semafor2u=0.0,semafor1d=0.0,semafor1u=0.0,upper=0.0,lower=0.0,price1=0.0,price2=0.0,price3=0.0,semafor2dn=0.0,semafor2up=0.0;
int zz,lev1;
datetime time1=0,time2=0,time3=0;

if(keyTr!=time[0])
{
ChartCleaner();
double spread=SymbolInfoInteger(_Symbol,SYMBOL_SPREAD)*_Point;

for(zz=BarsCount;zz>=1;zz--)
{
if(zz >= rates_total) continue;

price1=0.0; price2=0.0; price3=0.0;
semafor2d=Level2UP[zz];
semafor2u=Level2DN[zz];
time1=time[zz];

if(semafor2d>0.0)
{
price1=semafor2d; up=false; OpenPrice=0.0; upper=0.0;
for(lev1=zz-1;lev1>=1;lev1--)
{
if(lev1 >= rates_total) continue;

semafor2dn=Level2UP[lev1];
semafor2up=Level2DN[lev1];
if(semafor2up>0.0 || semafor2dn>0.0) break;
if(!up)
{
semafor1u=Level1DN[lev1];
if(semafor1u>0.0) upper=semafor1u;
if(upper>0.0&&upper>=semafor2d)
{
price2=upper;
time2=time[lev1];
up=true;
}
}
else
{
lower=Level1UP[lev1+1];
if(lower>0.0&&lower>=semafor2d)
{
time3=time[lev1+1];
price3=lower;
}
}
if(price1>0.0&&price2>0.0&&price3>0.0)
{
OpenPrice=10.0;
if(lev1==1 && ShowAlertTr) Alert(Symbol()," ",IntegerToString(Period())," Buy!!! ",DoubleToString(price2+2*2*_Point+spread,_Digits));
break;
}
}
if(OpenPrice>0.0 && price2-price1<DATA2*_Point)
{
DrawTriangle(copy+"123h"+IntegerToString(zz),time1,price1,time2,price2,time3,price3,BuyTriangle);
DrawArrow(copy+"123b"+IntegerToString(lev1),time3+Period()*60,price3-2*_Point,BuyMark);
}
}

if(semafor2u>0.0)
{
price1=semafor2u; up=false; OpenPrice=0.0; lower=0.0; upper=0.0;
for(lev1=zz-1;lev1>=1;lev1--)
{
if(lev1 >= rates_total) continue;

semafor2dn=Level2UP[lev1];
semafor2up=Level2DN[lev1];
if(semafor2up>0.0 || semafor2dn>0.0) break;
if(!up)
{
semafor1d=Level1UP[lev1];
if(semafor1d>0.0) lower=semafor1d;
if(lower>0.0&&lower<=semafor2u)
{
price2=lower;
time2=time[lev1];
up=true;
}
}
else
{
upper=Level1DN[lev1+1];
if(upper>0.0&&upper<=semafor2u)
{
time3=time[lev1+1];
price3=upper;
}
}
if(price1>0.0&&price2>0.0&&price3>0.0)
{
OpenPrice=10.0;
if(lev1==1 && ShowAlertTr) Alert(Symbol()," ",IntegerToString(Period())," Sell!!! ",DoubleToString(price2-2*_Point,_Digits));
break;
}
}
if(OpenPrice>0.0 && price1-price2<DATA2*_Point)
{
DrawTriangle(copy+"123s"+IntegerToString(zz),time1,price1,time2,price2,time3,price3,SellTriangle);
DrawArrow(copy+"123_X"+IntegerToString(lev1),time3+Period()*60,price3-2*_Point,SellMark);
}
}
}
keyTr=time[0];
}
}

//+------------------------------------------------------------------+
//| Draw Arrow function |
//+------------------------------------------------------------------+
void DrawArrow(string name,datetime time,double price,color ops_color)
{
if(!ShowMarks) return;

if(ObjectFind(0,name)<0)
{
ObjectCreate(0,name,OBJ_ARROW_RIGHT_PRICE,0,time,price);
}
else
{
ObjectMove(0,name,0,time,price);
}

ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
ObjectSetInteger(0,name,OBJPROP_BACK,FillUp);
ObjectSetInteger(0,name,OBJPROP_COLOR,ops_color);
ObjectSetInteger(0,name,OBJPROP_ARROWCODE,241);
}

//+------------------------------------------------------------------+
//| Draw Triangle function |
//+------------------------------------------------------------------+
void DrawTriangle(string name2,datetime time1,double price1,datetime time2,double price2,datetime time3,double price3,color ops_color)
{
if(ObjectFind(0,name2)<0)
{
ObjectCreate(0,name2,OBJ_TRIANGLE,0,time1,price1,time2,price2,time3,price3);
}
else
{
ObjectMove(0,name2,0,time1,price1);
ObjectMove(0,name2,1,time2,price2);
ObjectMove(0,name2,2,time3,price3);
}

ObjectSetInteger(0,name2,OBJPROP_WIDTH,1);
ObjectSetInteger(0,name2,OBJPROP_BACK,FillUp);
ObjectSetInteger(0,name2,OBJPROP_COLOR,ops_color);
}

//+------------------------------------------------------------------+
//| Count ZigZag function |
//+------------------------------------------------------------------+
int CountZZ(double &ExtMapBuffer[],double &ExtMapBuffer2[],int ExtDepth,int ExtDeviation,int ExtBackstep,
const int rates_total, const datetime &time[], const double &high[], const double &low[])
{
int shift, back,lasthighpos=-1,lastlowpos=-1, limit;
double val=0.0,res=0.0,curlow=0.0,curhigh=0.0,lasthigh=-1.0,lastlow=-1.0;

limit=rates_total-ExtDepth;
if(limit>BarsCount) limit=BarsCount;

for(shift=limit; shift>=0; shift--)
{
val=low[ArrayMinimum(low,ExtDepth,shift)];
if(val==lastlow) val=0.0;
else
{
lastlow=val;
if((low[shift]-val)>(ExtDeviation*_Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer[shift+back];
if((res!=0.0)&&(res>val)) ExtMapBuffer[shift+back]=0.0;
}
}
}
ExtMapBuffer[shift]=val;

val=high[ArrayMaximum(high,ExtDepth,shift)];
if(val==lasthigh) val=0.0;
else
{
lasthigh=val;
if((val-high[shift])>(ExtDeviation*_Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer2[shift+back];
if((res!=0.0)&&(res<val)) ExtMapBuffer2[shift+back]=0.0;
}
}
}
ExtMapBuffer2[shift]=val;
}

lasthigh=-1.0; lasthighpos=-1; lastlow=-1.0; lastlowpos=-1;

for(shift=limit;shift>=0;shift--)
{
curlow=ExtMapBuffer[shift];
curhigh=ExtMapBuffer2[shift];
if((curlow==0.0)&&(curhigh==0.0)) continue;

if(curhigh!=0.0)
{
if(lasthigh>0.0)
{
if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0.0;
else ExtMapBuffer2[shift]=0.0;
}
if(lasthigh<curhigh || lasthigh<0.0)
{
lasthigh=curhigh;
lasthighpos=shift;
}
lastlow=-1.0;
}

if(curlow!=0.0)
{
if(lastlow>0.0)
{
if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0.0;
else ExtMapBuffer[shift]=0.0;
}
if((curlow<lastlow)||(lastlow<0.0))
{
lastlow=curlow;
lastlowpos=shift;
}
lasthigh=-1.0;
}
}

for(shift=limit;shift>=0;shift--)
{
if(shift>=limit) ExtMapBuffer[shift]=0.0;
else
{
res=ExtMapBuffer2[shift];
if(res!=0.0) ExtMapBuffer2[shift]=res;
}
}
return(0);
}

//+------------------------------------------------------------------+
//| Chart Cleaner function |
//+------------------------------------------------------------------+
void ChartCleaner()
{
for(int a=0;a<BarsCount;a++)
{
ObjectDelete(0,copy+"123h"+IntegerToString(a));
ObjectDelete(0,copy+"123b"+IntegerToString(a));
ObjectDelete(0,copy+"123s"+IntegerToString(a));
ObjectDelete(0,copy+"123_X"+IntegerToString(a));
ResetLastError();
}
}
//+------------------------------------------------------------------+
XARD: Try this...
These users thanked the author Neroloft for the post (total 4):
knglerxst, valeryi, mazibee, WN25
"That which is, already has been; that which is to be, already has been;"

Re: XARD - Simple Trend Following Trading System

19660
Dear XARD,

Thank you for your amazing work and for sharing your great systems.

I’m not an active trader yet, but I’m very interested in the field and have been learning a lot from your work.

I’ve been using XU-XARD UNIVERSE with VWAP+EMAs+ZZ v1.21, and it’s excellent. However, I noticed that the ZigZag indicator doesn’t allow changing its parameters via the Inputs tab. If possible, could you please make it adjustable in a future update?

Also, if there are any newer versions of the system—especially with updates related to ZigZag or VWAP—I would be very grateful if you could kindly share them.

Thanks again for all your efforts.

Best regards,
Nengirso