Gamestudio Links
Zorro Links
Newest Posts
Blog Post: Get Historical Data from Darwinex REST API w/ Zorro
by AndrewAMD
Yesterday at 22:19
Reseting a static variable - the next day
by OptimusPrime
Yesterday at 19:48
Correlation -1.#IND00
by AndrewAMD
Yesterday at 17:44
Basic thread safety question
by Superku
Yesterday at 17:43
Train algorithms separatery
by 3dgamelight
01/18/19 10:37
+BALANCED machine learning option
by jcl
01/18/19 08:37
IntraBar fluctuation
by jcl
01/18/19 08:31
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
4 registered (AndrewAMD, Superku, 2 invisible), 499 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
laz, ramonne, SibJac, Evael, NRW
18156 Registered Users
Topic Options
Rate This Topic
#475788 - 01/08/19 03:29 QQE Indicator Conversion from MT4
PriceAlgoTrader Offline
Newbie

Registered: 12/17/18
Posts: 5
I'm not to familiar with MT4 code. I'm trying to convert this to Zorro Lite C - can anyone help??

:

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Navy
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2

#property indicator_color2 Red
#property indicator_style2 STYLE_DOT


extern int RSI_Period = 14;
extern int SF = 5;
extern double WF = 4.236;

int Wilders_Period;
int StartBar;

double TrLevelSlow[];
double AtrRsi[];
double MaAtrRsi[];
double Rsi[];
double RsiMa[];

int init()
{
Wilders_Period = RSI_Period * 2 - 1;
if (Wilders_Period < SF)
StartBar = SF;
else
StartBar = Wilders_Period;

IndicatorBuffers(6);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexLabel(0, "Value 1");
SetIndexDrawBegin(0, StartBar);
SetIndexStyle(1, DRAW_LINE, STYLE_DOT);
SetIndexLabel(1, "Value 2");
SetIndexDrawBegin(1, StartBar);
IndicatorShortName(StringConcatenate("QQE(", SF, ")"));

SetIndexBuffer(0, RsiMa);
SetIndexBuffer(1, TrLevelSlow);
SetIndexBuffer(2, Rsi);
SetIndexBuffer(3, AtrRsi);
SetIndexBuffer(4, MaAtrRsi);

return(0);
}


int start()
{
int counted, i;
double rsi0, rsi1, dar, tr, dv;

if(Bars <= StartBar)
return (0);

counted = IndicatorCounted();
if(counted < 1)
for(i = Bars - StartBar; i < Bars; i++)
{
TrLevelSlow[i] = 0.0;
AtrRsi[i] = 0.0;
MaAtrRsi[i] = 0.0;
Rsi[i] = 0.0;
RsiMa[i] = 0.0;
}

counted = Bars - counted - 1;

for (i = counted; i >= 0; i--)
Rsi[i] = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);

for (i = counted; i >= 0; i--)
{
RsiMa[i] = iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);
AtrRsi[i] = MathAbs(RsiMa[i + 1] - RsiMa[i]);
}

for (i = counted; i >= 0; i--)
MaAtrRsi[i] = iMAOnArray(AtrRsi, 0, Wilders_Period, 0, MODE_EMA, i);

i = counted + 1;
tr = TrLevelSlow[i];
rsi1 = iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);
while (i > 0)
{
i--;
rsi0 = iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);
dar = iMAOnArray(MaAtrRsi, 0, Wilders_Period, 0, MODE_EMA, i) * WF; //* 4.236;

dv = tr;
if (rsi0 < tr)
{
tr = rsi0 + dar;
if (rsi1 < dv)
if (tr > dv)
tr = dv;
}
else if (rsi0 > tr)
{
tr = rsi0 - dar;
if (rsi1 > dv)
if (tr < dv)
tr = dv;
}
TrLevelSlow[i] = tr;
rsi1 = rsi0;
}

return(0);
}

Top
#475831 - 01/09/19 15:01 Re: QQE Indicator Conversion from MT4 [Re: PriceAlgoTrader]
jmlocatelli Offline
Newbie

Registered: 10/12/17
Posts: 30
Loc: Brazil
Hi,
I'm also looking for a QQE indicator for Zorro.
MetaTrader coding is not a simple task.
Yesterday I found a QQE version for Amibroker.
I will try to convert it to Zorro.

QQE_Periods = 14;
QQE_SF = 5;

QQE_RSI_MA = EMA(RSI(QQE_Periods),QQE_SF);
QQE_ATR_RSI = abs(Ref(QQE_RSI_MA,-1)-QQE_RSI_MA);
QQE_MA_ATR_RSI = EMA(QQE_ATR_RSI, 2*QQE_Periods-1);
QQE_DAR = EMA(QQE_MA_ATR_RSI, 2*QQE_Periods-1)*4.236;
QQE_DAR_Fast = EMA(QQE_MA_ATR_RSI, 2*QQE_Periods-1)*2.618;

function QQE_TR(RSIMA, DARFACTOR)
{
result[0] = 0;
for(i=1; i<BarCount; i++)
{
if(RSIMA[i] < result[i-1])
{
result[i] = RSIMA[i]+DARFACTOR[i];
if((RSIMA[i-1] < result[i-1]) AND (result[i] > result[i-1]))
{
result[i] = result[i-1];
}
}
else
{
if(RSIMA[i] > result[i-1])
{
result[i] = RSIMA[i]-DARFACTOR[i];
if ((RSIMA[i-1] > result[i-1]) AND (result[i] < result[i-1]))
{
result[i] = result[i-1];
}
}
}
}
return result;
}

QQE_FastSignal = QQE_TR(QQE_RSI_MA,QQE_DAR_Fast);
QQE_SlowSignal = QQE_TR(QQE_RSI_MA,QQE_DAR);

Plot(QQE_RSI_MA,"QQE"+_PARAM_VALUES(),ParamColor("QQE color",colorRed),ParamStyle("QQE style",styleThick));
Plot(QQE_FastSignal,"FastSignal",ParamColor("FastSignal color",colorOrange),ParamStyle("FastSignal style",styleDashed));
Plot(QQE_SlowSignal,"SlowSignal",ParamColor("SlowSignal color",colorBlue),ParamStyle("SlowSignal style",styleDashed));


Edited by jmlocatelli (01/09/19 15:04)

Top
#475838 - 01/09/19 21:13 Re: QQE Indicator Conversion from MT4 [Re: jmlocatelli]
jmlocatelli Offline
Newbie

Registered: 10/12/17
Posts: 30
Loc: Brazil
Maybe better to work from the scratch based on QQE definition:
The QQE indicator consists of a smoothed Relative Strength Index (RSI) indicator and two volatility-based trailing levels (fast and slow). The Fast Trailing Level (TL) and Slow TL are constructed by calculating the ATR of the smoothed RSI over n-periods and then further smoothing the ATR using an additional n-periods Wilders smoothing function. This smoothed ATR of RSI is then multiplied by the Fast and Slow ATR Multipliers to calculate the final Fast and Slow Trailing Levels.

Top
#475843 - 01/10/19 02:21 Re: QQE Indicator Conversion from MT4 [Re: jmlocatelli]
PriceAlgoTrader Offline
Newbie

Registered: 12/17/18
Posts: 5
On tradingview they had this:

//By Glaz
study("QQE MT4")
RSI_Period = input(14,title='RSI')
SF = input(5,title='Slow Factor')
QQE=input(4.236)

Wilders_Period = RSI_Period * 2 - 1


Rsi = rsi(close,RSI_Period)
RsiMa = ema(Rsi, SF)
AtrRsi = abs(RsiMa[1] - RsiMa)
MaAtrRsi = ema(AtrRsi, Wilders_Period)
dar = ema(MaAtrRsi,Wilders_Period) * QQE


DeltaFastAtrRsi= dar
RSIndex=RsiMa
newshortband= RSIndex + DeltaFastAtrRsi
newlongband= RSIndex - DeltaFastAtrRsi
longband=RSIndex[1] > longband[1] and RSIndex > longband[1]?
max(longband[1],newlongband):newlongband
shortband=RSIndex[1] < shortband[1] and RSIndex < shortband[1]?
min(shortband[1], newshortband):newshortband
trend=cross(RSIndex, shortband[1])?1:cross(longband[1], RSIndex)?-1:nz(trend[1],1)
FastAtrRsiTL = trend==1? longband: shortband

plot(FastAtrRsiTL,color=red)
plot(RsiMa,color=yellow)

Top
#475844 - 01/10/19 02:22 Re: QQE Indicator Conversion from MT4 [Re: PriceAlgoTrader]
PriceAlgoTrader Offline
Newbie

Registered: 12/17/18
Posts: 5
Will be interesting to see what you come up with, I'm trying to give it a go myself

Top
#475970 - 01/16/19 04:03 Re: QQE Indicator Conversion from MT4 [Re: PriceAlgoTrader]
PriceAlgoTrader Offline
Newbie

Registered: 12/17/18
Posts: 5
This is what I have so far, isn't working properly yet... not sure why.




var QQE_TR(vars RSIMA, vars DARFACTOR) ;

function run(){

StartDate = 2018;
BarPeriod = 60;
LookBack = 1000;

set( PLOTNOW);



int QQE_Periods = 14;
int QQE_SF = 5;
int QQE_Wilders_Period = QQE_Periods * 2 - 1;


vars Price = series( price() );

vars QQE_RSI = series( RSI( Price, QQE_Periods));
vars QQE_RSI_MA = series( EMA(QQE_RSI,QQE_SF));
vars QQE_ATR_RSI = series( abs( QQE_RSI_MA[1]-QQE_RSI_MA[0] ));
vars QQE_MA_ATR_RSI = series( EMA(QQE_ATR_RSI, QQE_Wilders_Period));
vars QQE_DAR = series( EMA(QQE_MA_ATR_RSI, QQE_Wilders_Period)*4.236 );
vars QQE_DAR_Fast = series( EMA(QQE_MA_ATR_RSI, QQE_Wilders_Period)*2.618);


var QQE_FastSignal = QQE_TR(QQE_RSI_MA,QQE_DAR_Fast) ;
var QQE_SlowSignal = QQE_TR(QQE_RSI_MA,QQE_DAR) ;



plot("QQE Fast Signal", QQE_FastSignal, NEW, BLUE );
plot("QQE Slow Signal", QQE_SlowSignal, 0, RED);

plot("QQE_RSI", QQE_RSI, NEW, BLUE );
plot("QQE_RSI MA", QQE_RSI_MA, 0, RED );

plot("QQE_ATR_RSI", QQE_ATR_RSI, NEW, BLUE );
plot("QQE_MA_ATR_RSI MA", QQE_MA_ATR_RSI, 0, RED );

plot("QQE_DAR", QQE_DAR, NEW, BLUE );
plot("QQE_DAR_Fast MA", QQE_DAR_Fast, 0, RED );
}


var QQE_TR(vars RSIMA, vars DARFACTOR)
{


vars result = series();
result[0] = result[1] = 0;

int i;

for(i=1; i<3; i++)
{

if(RSIMA[i] < result[i-1])
{
result[i] = RSIMA[i]+DARFACTOR[i];
if((RSIMA[i-1] < result[i-1]) && (result[i] > result[i-1]))
{
result[i] = result[i-1];
}
}
else
{
if(RSIMA[i] > result[i-1])
{
result[i] = RSIMA[i]-DARFACTOR[i];
if ((RSIMA[i-1] > result[i-1]) && (result[i] < result[i-1]))
{
result[i] = result[i-1];
}
}
}

}

return result[1];


}


Edited by PriceAlgoTrader (01/16/19 04:06)

Top


Moderator:  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de