You are on page 1of 4

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/344383650

Multivariate Forex Calculus Robot

Preprint · September 2020

CITATIONS READS

0 1,574

1 author:

Wojciech Fialkiewicz

2 PUBLICATIONS 0 CITATIONS

SEE PROFILE

All content following this page was uploaded by Wojciech Fialkiewicz on 27 May 2021.

The user has requested enhancement of the downloaded file.


Multivariate Forex Calculus Robot

Wojciech Krzysztof Fiałkiewicz

ABSTRACT Forex Market is complex financial system with many variables depended on each other,
it is nowadays easily accessible for anyone with connection to the internet, therefore it is easy for anyone to test
proposed solution.The underlying hypothesis is that on Forex Market are hidden regularities, that once established can
be used to correctly forecast values of different instruments. Document describes algorithms used in implementation of
Forex Robot. It was tested that Robot implementing those algorithms is able to be profitable on Forex. If those
algorithms are able in some situations to correctly predict Market movements and there haven't been found any
formulas governing relations of different instruments on Forex Market, that means that those algorithms will work
better in complex physical systems(in which there are known laws governing those systems), where there are many
variables measured and having historical data of those measurements there is need to predict future values of those
variables .

KEYWORDS Forex, Forex Forecasting, Forex Robot, Neural Networks, Time Series, Time Series
Forecasting

I. INTRODUCTION

Basics of EA Forex Robot has been described in [1], Open Source of Robot using algorithms described in this
paper is available at [2]. It was stated in [3], [4], [5], [6] that using Neural Networks in Forecasting Forex can lead to
positive results. Implemented Robot uses Feedforward Neural Network trained with Back propagation algorithm with
Neurons with Multidimensional Activation Function, which basic architecture was described in [7].

Robot works in three main steps. In first step robot access history of Symbols prices, by default last 3 days.
For every Symbol robot analyzes minute by minute change of price value in the past and doing that robot establishes
past local Minimas, Maximas for every Symbol. In second step Robot tries all combination of StopLoss and TakeProfit
values for every Symbol and determines StopLoss and TakeProfit value that yielded most positive overall outcome for
every Symbol under analysis. Robot determines how many Gains and Loses where present in analyzed history using as
reference points to analyze and proceed with the trade local Minimas, Maximas and points of determining past local
Minimum, Maximum. Using values of Gains and Loses robot determines tradable Symbols. In third step Robot trains
Neural Network with data determined during collecting Gains and Loses, this Neural Network will be used after
establishing local Minimum, Maximum for any of the Symbols during analyzing live future data. This three steps are
repeated by default every 12 hours of robots work. If for last 3 days it was possible to make profit using robots
algorithm then there is possibility that during future 12 hours it will be also possible to make profit using the same
algorithm and its established parameters (as Traders say "Trend is Your Friend.").

II. ALGORITHMS

II.I. DETERMINING LOCAL MINIMAS, MAXIMAS ON SYMBOL CHARTS.

Code of class performing analysis of Symbol price values for every of the Symbols :

+--------------------------------------------------------+
class CAnalyzer{
private:
double m_MinValue;
double m_MaxValue;
bool m_SearchingForMaximum;

double m_ValueChange;
double m_MinValueDiffrence;
double m_MaxValueDiffrence;

double m_LastMinimumMaximumValue;

void CheckValues(double val)


{
double diff = MathAbs(val - m_LastMinimumMaximumValue);

if(m_MinValueDiffrence > diff)


{
m_MinValueDiffrence = diff;
}
if(m_MaxValueDiffrence < diff)
{
m_MaxValueDiffrence = diff;
}
}

public:
static double NO_RESULT = -1.0;

void SetDefaultMinimumMaximum(double val, double valueChange)


{
m_MinValue = val;
m_MaxValue = val;
m_ValueChange = valueChange;
m_LastMinimumMaximumValue = val;
m_MinValueDiffrence = 100;
m_MaxValueDiffrence = 0;
}

double CheckForMinimumMaximum(double val)


{
double ret = NO_RESULT;

if(m_SearchingForMaximum == false && (val - m_MinValue) > m_ValueChange)


{
ret = m_MinValue;
m_SearchingForMaximum = true;
m_MinValue = val;
m_MaxValue = val;
CheckValues(ret);
m_LastMinimumMaximumValue = ret;
}
else if(m_SearchingForMaximum == true && (val - m_MaxValue) < -m_ValueChange)
{
ret = m_MaxValue;
m_SearchingForMaximum = false;
m_MinValue = val;
m_MaxValue = val;
CheckValues(ret);
m_LastMinimumMaximumValue = ret;
}

if (m_MinValue > val)


{
m_MinValue = val;
}
if (m_MaxValue < val)
{
m_MaxValue = val;
}
return ret;
}
};
+--------------------------------------------------------+

Class is initialized with call to function SetDefaultMinimumMaximum with parameters being starting Symbol
value and value of needed change of price to local Minimum, Maximum being established. Value of needed change is
being defined by multiplication of starting Symbol value and some configuration defined constant defining percent. By
Default Robot calls every second function CheckForMinimumMaximum with current Symbol price value being
provided. Function returns NO_RESULT value or value of price of established past local Minimum, Maximum.

II.II. DETERMINING VALUES OF STOPLOSS, TAKEPROFIT FOR SYMBOLS.

For every symbol there are determined best values(StopLossMulti, TakeProfitMulti) that will be used to
calculate StopLoss, TakeProfit for every situation in which there has been determined local Minimum, Maximum, there
is defined its value and value of Symbol in time of establishing local Minimum, Maximum called val. Value diff is
equal to difference of those values. Algorithm checks all history for all possible combinations of StopLossMulti and
TakeProfitMulti, by default from range 0.0:4.0, with step 0.1. For every established past local Minimum, Maximum. If
BUY operation is being checked than values of StopLoss, TakeProfit are determined as (val - StopLossMulti * diff),
(val + TakeProfitMulti * diff). If SELL operation is being checked than values of StopLoss, TakeProfit are determined
as (val + StopLossMulti * diff), (val - TakeProfitMulti * diff).

II.III. DETERMINING IN WHICH CONDITION TO PROCEED WITH THE TRADE OPERATION.

For every Symbol, for its determined StopLoss and TakeProfit values, for all determined Minimas, Maximas
and points of determining Minimas, Maximas. There are created Learn Vectors, containing values of prices from the
range of all values between determine Minimum, Maximum and point of determining that Minimum, Maximum. To the
Learn Vector are also added values before determined Minimum, Maximum, by default in range equal 2 times of the
range equal to distance between determined Minimum, Maximum and point of determining that Minimum, Maximum.
To Learn Vector are also added values of StopLoss and TakeProfit, on output Learn Vector has one value specifying if
trade was successful or failed. With those Learn Vectors Neural Network with Neurons with Multidimensional
Activation Function is being trained.

REFERENCES

[1] Luciana Abednego, Cecilia Esti Nugraheni, Irvan Rinaldy, "Forex Trading Robot with Technical and Fundamental
Analysis", 2018

[2] Wojciech Fiałkiewicz, "https://sourceforge.net/projects/forex-calculus-robot/", 2020

[3] V.V.Kondratenko and Yu. A Kuperin, "Using Recurrent Neural Networks To Forecasting of Forex", 2003

[4] Nijolė Maknickienė, Algirdas Maknickas, "APPLICATION OF NEURAL NETWORK FOR FORECASTING OF
EXCHANGE RATES AND FOREX TRADING", 2012

[5] Gene I. Sher, "Evolving Chart Pattern Sensitive NeuralNetwork Based Forex Trading Agents", 2011

[6] Zhiwen Zeng, Matloob Khushi , "Wavelet Denoising and Attention-based RNN-ARIMA Model to Predict Forex
Price", 2020

[7] Wojciech Fiałkiewicz, "Hypercube Neuron", 2009

View publication stats

You might also like