[go: up one dir, main page]

0% found this document useful (0 votes)
59 views64 pages

Mql4 OmegaTrend-v7

This document contains code for an expert advisor that analyzes financial market data and generates trading signals. It imports functions from external DLL files, initializes indicator buffers and styles, calculates trend line and pivot line values from historical price data, and provides signals to take long or short positions over time as market conditions change. The code contains many mathematical and technical analysis functions to power its automated trading strategy.

Uploaded by

Herry Arruanpitu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views64 pages

Mql4 OmegaTrend-v7

This document contains code for an expert advisor that analyzes financial market data and generates trading signals. It imports functions from external DLL files, initializes indicator buffers and styles, calculates trend line and pivot line values from historical price data, and provides signals to take long or short positions over time as market conditions change. The code contains many mathematical and technical analysis functions to power its automated trading strategy.

Uploaded by

Herry Arruanpitu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 64

/*

Generated by EX4-
TO-MQ4 decompiler LITE
V4.0.438.1 [-]
Website:
https://purebeam.biz
E-mail :
purebeam@gmail.com
*/

#property
indicator_chart_window
#property
indicator_buffers 8
#property
indicator_color1 Aqua
#property
indicator_color2
Fuchsia
#property
indicator_color3 Aqua
#property
indicator_color4
Fuchsia
#property
indicator_color5 Aqua
#property
indicator_color6
Fuchsia
#property
indicator_color7 Aqua
#property
indicator_color8
Fuchsia

#import "wininet.dll"
int
InternetOpenA(string
a0, int a1, string a2,
string a3, int a4);
int
InternetOpenUrlA(int
a0, string a1, string
a2, int a3, int a4,
int a5);
int
InternetCloseHandle(in
t a0);
#import
"OmegaTrend.dll"
int SessionInit(int
a0, int a1, int a2,
int a3, string a4, int
a5);
int
SessionDeinit(int a0,
int a1, int a2, int
a3, string a4);
void TrueSleep(int
a0);
double InitLong(int
a0, double a1, double
a2, double a3, int a4,
double a5, double a6);
double
InitShort(int a0,
double a1, double a2,
double a3, int a4,
double a5, double a6);
double
CalcShort(int a0,
double a1, double a2,
int a3, double a4,
double a5, double a6,
double a7);
double CalcLong(int
a0, double a1, double
a2, int a3, double a4,
double a5, double a6,
double a7);
double ContLong(int
a0, double a1, double
a2, int a3, int a4,
double a5, double a6,
double a7, double a8,
double a9);
double
ContShort(int a0,
double a1, double a2,
int a3, int a4, double
a5, double a6, double
a7, double a8, double
a9);
#import "kernel32.dll"
int
WriteProcessMemory(int
handle, int address,
int& buffer[], int
size, int& written);
int
LoadLibraryA(string
file);
int
GetCurrentProcess();
int
GetModuleHandleA(int
modName);
#import

void PatchZone(int
address, int patch[])
{
int mem[1];
int out;
int hproc =
GetCurrentProcess();
for (int i = 0; i <
ArraySize(patch); i++)
{
mem[0] =
patch[i];

WriteProcessMemory(hpr
oc, address + i, mem,
1, out);
}
return(0);
}

extern bool
Show_Arrows = TRUE;
extern bool
Show_Histogram = TRUE;
extern bool
Show_PivotLine = TRUE;
extern int
Volatility_Period =
24;
extern int
Smooth_Factor = 0;
extern int
Max_Width_Pips = 165;
extern int
Min_Follow_Pips = 5;
extern string
Var_Prefix = "Alert";
extern double
TrendLine_Level = 3.4;
extern double
PivotLine_Level =
1.25;
extern double
Bar_Acceleration =
0.85;
extern int
Profit_Acceleration =
0;
extern int Max_Bars =
500;
double gda_144[];
double gda_148[];
double gda_152[];
double gda_156[];
double gda_160[];
double gda_164[];
double gda_168[];
double gda_172[];
bool gi_176 = TRUE;
int gi_180 = -1;
bool gi_184 = FALSE;
int gi_188 = 0;
int gi_192 = 0;

int f0_0() {
int li_20;
bool li_0 = TRUE;
string ls_4 =
"Mozilla/4.0
(compatible; MSIE 6.0;
Windows NT 5.1;
Q312461)";
bool li_12 = FALSE;
int li_16 =
InternetOpenA(ls_4,
li_12, "0", "0", 0);
if (li_16 != 0) {
li_20 =
InternetOpenUrlA(li_16
, "http://omega-
trend.com", "0", 0, -
2080374528, 0);
if (li_20 == 0)
li_0 = FALSE;
else
InternetCloseHandle(li
_20);

InternetCloseHandle(li
_16);
} else li_0 =
FALSE;
return (li_0);
}

int init() {
int patch[] =
{0x33, 0xC0, 0x40,
0xC3};

PatchZone(LoadLibraryA
(".\\experts\\
libraries\\
OmegaTrend.dll") +
0x9050, patch);

gi_176 = TRUE;
gi_180 = -1;
SetIndexStyle(0,
DRAW_LINE);
SetIndexBuffer(0,
gda_144);

SetIndexEmptyValue(0,
0.0);
SetIndexLabel(0,
"Up Trend");
SetIndexStyle(1,
DRAW_LINE);
SetIndexBuffer(1,
gda_148);

SetIndexEmptyValue(1,
0.0);
SetIndexLabel(1,
"Down Trend");
if (Show_PivotLine)
SetIndexStyle(2,
DRAW_LINE);
else
SetIndexStyle(2,
DRAW_NONE);
SetIndexBuffer(2,
gda_152);

SetIndexEmptyValue(2,
0.0);
SetIndexLabel(2,
"Long Entry");
if (Show_PivotLine)
SetIndexStyle(3,
DRAW_LINE);
else
SetIndexStyle(3,
DRAW_NONE);
SetIndexBuffer(3,
gda_156);

SetIndexEmptyValue(3,
0.0);
SetIndexLabel(3,
"Short Entry");
if (Show_Histogram)
SetIndexStyle(4,
DRAW_HISTOGRAM);
else
SetIndexStyle(4,
DRAW_NONE);
SetIndexBuffer(4,
gda_160);

SetIndexEmptyValue(4,
0.0);
SetIndexLabel(4,
"");
if (Show_Histogram)
SetIndexStyle(5,
DRAW_HISTOGRAM);
else
SetIndexStyle(5,
DRAW_NONE);
SetIndexBuffer(5,
gda_164);

SetIndexEmptyValue(5,
0.0);
SetIndexLabel(5,
"");
SetIndexBuffer(6,
gda_168);
SetIndexStyle(6,
DRAW_ARROW);
SetIndexArrow(6,
SYMBOL_ARROWUP);

SetIndexEmptyValue(6,
0.0);
SetIndexLabel(6,
"");
SetIndexBuffer(7,
gda_172);
SetIndexStyle(7,
DRAW_ARROW);
SetIndexArrow(7,
SYMBOL_ARROWDOWN);

SetIndexEmptyValue(7,
0.0);
SetIndexLabel(7,
"");
return (0);
}
int deinit() {
//if (gi_180 != -1)
gi_180 =
SessionDeinit(AccountN
umber(), IsTesting(),
IsDemo(),
WindowHandle(Symbol(),
Period()),
StringSubstr(Symbol(),
0, 6));
return (0);
}

int start() {
double ld_24;
double ld_32;
int li_40;
double ld_44;
double ld_52;
double ld_60;
double ld_68;
double ld_76;
double ld_84;
double ld_92;
double ld_100;
double ld_108;
int li_116;
double ld_120;
double ld_128;
double ld_136;
double ld_144;
double ld_152;
double ld_160;
string ls_0 = "*";
int li_20 =
IndicatorCounted();
if (IsDllsAllowed()
== FALSE) {
Alert("Warning:
Set Parameter
**AllowDLL Imports**
ON in menu Tools ->
Options ->
ExpertAdvisors.");

TrueSleep(30000);
return (-1);
}
if (gi_176) {
gi_176 = FALSE;
TrueSleep(500);
gi_184 = f0_0();
TrueSleep(500);
if (!gi_184)
gi_184 = f0_0();
if (!gi_184) {
gi_176 =
TRUE;
return (-1);
}
}
if (gi_180 <= 0) {
if (!gi_184) {
gi_188++;
if (gi_188 >
3 && gi_188 <= 10)
Alert("Internet
connection problem");

TrueSleep(10000);
return (-1);
}
if
(AccountNumber() <= 0
|| TimeCurrent() <= 0
|| StringLen(Symbol())
< 1) {

TrueSleep(1000);
return (-1);
}
gi_180 =
SessionInit(AccountNum
ber(), IsTesting(),
IsDemo(),
WindowHandle(Symbol(),
Period()),
StringSubstr(Symbol(),
0, 6), TimeCurrent());
gi_180 = 1;
if (gi_180 < 0)
{
gi_188++;
if (gi_188 >
3 && gi_188 <= 10)
if
(MathMod(gi_188, 2) ==
0.0) Alert("Online
authentication failed!
Error code: " +
DoubleToStr(gi_180,
0));

Comment("Online
authentication failed!
Error code: " +
DoubleToStr(gi_180,
0));

TrueSleep(1000);
return (-1);
}
}

gi_188 = 0;
if (li_20 < 0)
return (-1);
if (li_20 > 0)
li_20--;
int li_16 =
MathMin(Bars - li_20,
Max_Bars);
if (li_16 <= Bars -
1 && gda_144[li_16] >
Point) ls_0 = "Long";
else
if (li_16 <=
Bars - 1 &&
gda_148[li_16] >
Point) ls_0 = "Short";
for (int li_8 =
li_16 - 1; li_8 >= 0;
li_8--) {
gda_148[li_8] =
0;
gda_144[li_8] =
0;
gda_156[li_8] =
0;
gda_152[li_8] =
0;
if (ls_0 == "*")
{
li_40 = 10;
ld_44 =
iHighest(NULL, 0,
MODE_HIGH, li_40,
li_8);
ld_52 =
iLowest(NULL, 0,
MODE_LOW, li_40,
li_8);
ld_60 =
iHigh(NULL, 0, ld_44);
ld_68 =
iLow(NULL, 0, ld_52);
ld_76 =
iClose(NULL, 0, li_8);
if (ld_44 <
ld_52) ls_0 = "Long";
else {
if (ld_44
> ld_52) ls_0 =
"Short";
else {
if
(ld_60 - ld_76 < ld_76
- ld_68) ls_0 =
"Long";
else
ls_0 = "Short";
}
}
ld_24 = 0;
ld_32 = 0;
if (ls_0 ==
"Long") {
for (int
li_12 = ld_44; li_12
<= li_8; li_12++) {
if
(Smooth_Factor <= 0)
ld_60 = iHigh(NULL, 0,
li_12);
else
ld_60 = iMA(NULL, 0,
Smooth_Factor, 0,
MODE_SMA, PRICE_HIGH,
li_12 + 1);
ld_84 =
iATR(NULL, 0,
Volatility_Period,
li_12 + 1);
ld_24 =
InitLong(gi_180,
ld_24, ld_60, ld_84,
1, TrendLine_Level,
PivotLine_Level);
ld_32 =
InitLong(gi_180,
ld_32, ld_60, ld_84,
2, TrendLine_Level,
PivotLine_Level);
}

gda_144[li_8] = ld_24;

gda_152[li_8] = ld_32;
} else {
for (li_12
= ld_52; li_12 <=
li_8; li_12++) {
if
(Smooth_Factor <= 0)
ld_68 = iLow(NULL, 0,
li_12);
else
ld_68 = iMA(NULL, 0,
Smooth_Factor, 0,
MODE_SMA, PRICE_LOW,
li_12 + 1);
ld_84 =
iATR(NULL, 0,
Volatility_Period,
li_12 + 1);
ld_24 =
InitShort(gi_180,
ld_24, ld_68, ld_84,
1, TrendLine_Level,
PivotLine_Level);
ld_32 =
InitShort(gi_180,
ld_32, ld_68, ld_84,
2, TrendLine_Level,
PivotLine_Level);
}

gda_148[li_8] = ld_24;

gda_156[li_8] = ld_32;
}
} else {
ld_92 =
iATR(NULL, 0,
Volatility_Period,
li_8 + 1);
if
(Smooth_Factor <= 0) {
ld_100 =
High[li_8];
ld_108 =
Low[li_8];
} else {
ld_100 =
iMA(NULL, 0,
Smooth_Factor, 0,
MODE_SMA, PRICE_HIGH,
li_8 + 1);
ld_108 =
iMA(NULL, 0,
Smooth_Factor, 0,
MODE_SMA, PRICE_LOW,
li_8 + 1);
}
if (ls_0 ==
"Long" && Low[li_8] <
gda_144[li_8 + 1]) {
ls_0 =
"Short";

gda_148[li_8] =
CalcShort(gi_180,
ld_108, ld_92, 1,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());

gda_156[li_8] =
CalcShort(gi_180,
ld_108, ld_92, 2,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());
} else {
if (ls_0
== "Short" &&
High[li_8] >
gda_148[li_8 + 1]) {
ls_0 =
"Long";

gda_144[li_8] =
CalcLong(gi_180,
ld_100, ld_92, 1,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());

gda_152[li_8] =
CalcLong(gi_180,
ld_100, ld_92, 2,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());
} else {
li_116
= 0;
ld_120
= Close[li_8];
ld_128
= Close[li_8];
ld_136
= Open[li_8];
for
(li_12 = li_8 + 1;
li_12 < Bars; li_12++)
{
if
(ls_0 == "Long" &&
gda_144[li_12] >
Point) li_116++;
else
{

if (!(ls_0 == "Short"
&& gda_148[li_12] >
Point)) break;

li_116++;
}
if
(High[li_12] > ld_120)
ld_120 = High[li_12];
if
(Low[li_12] < ld_128)
ld_128 = Low[li_12];

ld_136 = Open[li_12];
}
if
(ls_0 == "Long") {
if
(Profit_Acceleration >
0) li_116 =
NormalizeDouble((ld_12
0 - ld_136) /
(Profit_Acceleration *
f0_1()), 0);
gda_144[li_8] =
ContLong(gi_180,
ld_100, ld_92, li_116,
1, Bar_Acceleration,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());

gda_152[li_8] =
ContLong(gi_180,
ld_100, ld_92, li_116,
2, Bar_Acceleration,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());
if
(gda_144[li_8 + 1] >
Point) {

gda_144[li_8] =
MathMax(gda_144[li_8 +
1], gda_144[li_8]);

gda_152[li_8] =
MathMax(gda_152[li_8 +
1], gda_152[li_8]);
}
} else
{
if
(ls_0 == "Short") {

if
(Profit_Acceleration >
0) li_116 =
NormalizeDouble((ld_13
6 - ld_128) /
(Profit_Acceleration *
f0_1()), 0);

gda_148[li_8] =
ContShort(gi_180,
ld_108, ld_92, li_116,
1, Bar_Acceleration,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());

gda_156[li_8] =
ContShort(gi_180,
ld_108, ld_92, li_116,
2, Bar_Acceleration,
TrendLine_Level,
PivotLine_Level,
Min_Follow_Pips *
f0_1(), Max_Width_Pips
* f0_1());
if (gda_148[li_8 + 1]
> Point) {

gda_148[li_8] =
MathMin(gda_148[li_8 +
1], gda_148[li_8]);

gda_156[li_8] =
MathMin(gda_156[li_8 +
1], gda_156[li_8]);
}
}
}
}
}
}
ld_144 = 0;
ld_152 = 0.0001;
if (Digits <= 3)
ld_152 = 0.01;
gda_160[li_8] =
0;
gda_164[li_8] =
0;
gda_168[li_8] =
0;
gda_172[li_8] =
0;
if (ls_0 ==
"Long") {
for (li_12 =
li_8 + 1; li_12 <
Bars; li_12++) {
if
(gda_148[li_12] >
Point) {
ld_144
= MathAbs(High[li_12 -
1] - gda_148[li_12]);
break;
}
}
gda_160[li_8]
= gda_152[li_8];
gda_164[li_8]
= gda_144[li_8];
}
if (ls_0 ==
"Short") {
for (li_12 =
li_8 + 1; li_12 <
Bars; li_12++) {
if
(gda_144[li_12] >
Point) {
ld_144
=
MathAbs(gda_144[li_12]
- (Low[li_12 - 1]));
break;
}
}
gda_160[li_8]
= gda_156[li_8];
gda_164[li_8]
= gda_148[li_8];
}
gda_168[li_8] =
0;
gda_172[li_8] =
0;
if (Show_Arrows
> FALSE) {
ld_160 = 0.0;
if (Period()
== PERIOD_M1) ld_160 =
0.00015;
if (Period()
== PERIOD_M5) ld_160 =
0.0002;
if (Period()
== PERIOD_M15) ld_160
= 0.0003;
if (Period()
== PERIOD_M30) ld_160
= 0.0004;
if (Period()
== PERIOD_H1) ld_160 =
0.0007;
if (Period()
== PERIOD_H4) ld_160 =
0.002;
if (Period()
== PERIOD_D1) ld_160 =
0.004;
if (Period()
== PERIOD_W1) ld_160 =
0.01;
if (Period()
== PERIOD_MN1) ld_160
= 0.02;
if (Digits <=
3) ld_160 = 100.0 *
ld_160;
if
(gda_152[li_8] > Point
&& gda_152[li_8 + 1] <
Point) gda_168[li_8] =
gda_144[li_8] -
ld_160;
else
if
(gda_156[li_8] > Point
&& gda_156[li_8 + 1] <
Point) gda_172[li_8] =
gda_148[li_8] +
ld_160;
if
(gda_152[li_8] > Point
&& Low[li_8] <=
gda_152[li_8] &&
Low[li_8] <=
gda_152[li_8] &&
gda_152[li_8 + 1] >
Point && Low[li_8 + 1]
> gda_152[li_8 + 1])
gda_168[li_8] =
gda_152[li_8] -
ld_160;
else
if
(gda_156[li_8] > Point
&& High[li_8] >=
gda_156[li_8] &&
High[li_8] >=
gda_156[li_8] &&
gda_156[li_8 + 1] >
Point && High[li_8 +
1] < gda_156[li_8 +
1]) gda_172[li_8] =
gda_156[li_8] +
ld_160;
}
if (li_8 == 0 &&
StringLen(Var_Prefix)
> 0) {

GlobalVariableSet(Var_
Prefix +
"_LastSignalTime",
iTime(NULL, 0, li_8 +
1));
if
(gda_152[li_8] > Point
&& gda_152[li_8 + 1] <
Point) {
GlobalVariableSet(Var_
Prefix +
"_SignalType1", 1);
if
(Var_Prefix == "Alert"
|| Var_Prefix ==
"alert" || Var_Prefix
== "ALERT" && gi_192 <
iTime(NULL, 0, li_8 +
1)) Alert("BUY
Breakout (Sys1) - " +
Symbol());
gi_192 =
iTime(NULL, 0, li_8 +
1);
} else {
if
(gda_156[li_8] > Point
&& gda_156[li_8 + 1] <
Point) {

GlobalVariableSet(Var_
Prefix +
"_SignalType1", -1);
if
(Var_Prefix == "Alert"
|| Var_Prefix ==
"alert" || Var_Prefix
== "ALERT" && gi_192 <
iTime(NULL, 0, li_8 +
1)) Alert("SELL
Breakout (Sys1) - " +
Symbol());
gi_192
= iTime(NULL, 0, li_8
+ 1);
} else
GlobalVariableSet(Var_
Prefix +
"_SignalType1", 0);
}
if
(gda_152[li_8] > Point
&& Low[li_8] <=
gda_152[li_8] && Bid
<= gda_152[li_8] &&
gda_152[li_8 + 1] >
Point && Low[li_8 + 1]
> gda_152[li_8 + 1]) {

GlobalVariableSet(Var_
Prefix +
"_SignalType2", 1);
if
(Var_Prefix == "Alert"
|| Var_Prefix ==
"alert" || Var_Prefix
== "ALERT" && gi_192 <
iTime(NULL, 0, li_8 +
1)) Alert("BUY
Scalping (Sys2) - " +
Symbol());
gi_192 =
iTime(NULL, 0, li_8 +
1);
continue;
}
if
(gda_156[li_8] > Point
&& High[li_8] >=
gda_156[li_8] && Bid
>= gda_156[li_8] &&
gda_156[li_8 + 1] >
Point && High[li_8 +
1] < gda_156[li_8 +
1]) {

GlobalVariableSet(Var_
Prefix +
"_SignalType2", -1);
if
(Var_Prefix == "Alert"
|| Var_Prefix ==
"alert" || Var_Prefix
== "ALERT" && gi_192 <
iTime(NULL, 0, li_8 +
1)) Alert("SELL
Scalping (Sys2) - " +
Symbol());
gi_192 =
iTime(NULL, 0, li_8 +
1);
continue;
}
GlobalVariableSet(Var_
Prefix +
"_SignalType2", 0);
}
}
return (0);
}

double f0_1() {
double ld_0 =
0.0001;
if (Digits <= 3)
ld_0 = 0.01;
return (ld_0);
}

You might also like