Forex Optimal Risky Portfolio

Brother of a friend could help. In case not, i’ve a plan to do it on my own :smiley:

:wink:

and Hey you see how the standard deviation rise dramatically when consiedring hi-lo? from 2,50% to 60% ish xD

Yeah, I cee that!

Whats up with EURCHF though? 125% :open_mouth: (maybe those crazy interventions from the swiss )

Yep that’s it, That’s why EURCHF is a too risky pair to trade on ! :slight_smile:
This is the mathematical confirmation :wink:

@ABOWNIAK - I read what you mentioned, and It’s interesting, but I should have to test it… any clue where I could get his data?

in case you are referring to me (ABOKWAIK). Actually no, however you can check his website (2hedge.com).

On the technical side, I found an indicator that shows Strength/Weakness of a currency compared to other currencies. 7 out of the 8 major currencies are included (only NZD is not there). This can be used to buy the strongest currency against the weakest one.

I hope this can help. below is the source code.

Khalil

==========
/*
I like to moving, moving
v1.21s (1.0 + smoothing (+level) + shifting)
by ALeX
*/

#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Black
#property indicator_color5 RosyBrown
#property indicator_color6 Orange
#property indicator_color7 BlueViolet

extern int candles = 100;
extern int shift = 0;
extern int smooth_level = 1;

double bufIUSD[];
double bufIEUR[];
double bufIGBP[];
double bufICHF[];
double bufIJPY[];
double bufIAUD[];
double bufICAD[];

//string names[7] = {“USD”, “EUR”, “GBP”, “CHF”, “JPY”, “AUD”, “CAD”};

int init()
{
SetIndexBuffer (0, bufIUSD);
SetIndexBuffer (1, bufIEUR);
SetIndexBuffer (2, bufIGBP);
SetIndexBuffer (3, bufICHF);
SetIndexBuffer (4, bufIJPY);
SetIndexBuffer (5, bufIAUD);
SetIndexBuffer (6, bufICAD);

SetIndexLabel (0, “USD”);
SetIndexLabel (1, “EUR”);
SetIndexLabel (2, “GBP”);
SetIndexLabel (3, “CHF”);
SetIndexLabel (4, “JPY”);
SetIndexLabel (5, “AUD”);
SetIndexLabel (6, “CAD”);

SetIndexStyle (0, DRAW_LINE, EMPTY, 2);
SetIndexStyle (1, DRAW_LINE, EMPTY, 2);
SetIndexStyle (2, DRAW_LINE, EMPTY, 2);
SetIndexStyle (3, DRAW_LINE, EMPTY, 2);
SetIndexStyle (4, DRAW_LINE);
SetIndexStyle (5, DRAW_LINE);
SetIndexStyle (6, DRAW_LINE);

return (0);
}

int start()
{
int i, j;
int to;
double USD, maxUSD=0.0, maxEUR=0.0, maxGBP=0.0, maxCHF=0.0, maxJPY=0.0, maxAUD=0.0, maxCAD=0.0;

to = candles+shift;
if (to > Bars-10)
to = Bars-10;

for (i = shift; i < to; i++)
{
USD = MathPow (iClose(“USDCHF”,0,i)iClose(“USDJPY”,0,i)iClose(“USDCAD”,0,i)/iClose(“EURUSD”,0,i)/iClose(“GBPUSD”,0,i)/iClose(“AUDUSD”,0,i), 1.0/7.0);
maxUSD = MathMax (maxUSD, USD);
maxEUR = MathMax (maxEUR, USD
iClose(“EURUSD”,0,i));
maxGBP = MathMax (maxGBP, USD
iClose(“GBPUSD”,0,i));
maxCHF = MathMax (maxCHF, USD/iClose(“USDCHF”,0,i));
maxJPY = MathMax (maxJPY, USD/iClose(“USDJPY”,0,i));
maxAUD = MathMax (maxAUD, USD*iClose(“AUDUSD”,0,i));
maxCAD = MathMax (maxCAD, USD/iClose(“USDCAD”,0,i));
}

for (i = shift; i < to; i++)
{
USD = MathPow (iClose(“USDCHF”,0,i)iClose(“USDJPY”,0,i)iClose(“USDCAD”,0,i)/iClose(“EURUSD”,0,i)/iClose(“GBPUSD”,0,i)/iClose(“AUDUSD”,0,i), 1.0/7.0);
bufIUSD[i] = 100
USD/maxUSD;
bufIEUR[i] = 100
USDiClose(“EURUSD”,0,i)/maxEUR;
bufIGBP[i] = 100
USDiClose(“GBPUSD”,0,i)/maxGBP;
bufICHF[i] = 100
USD/iClose(“USDCHF”,0,i)/maxCHF;
bufIJPY[i] = 100USD/iClose(“USDJPY”,0,i)/maxJPY;
bufIAUD[i] = 100
USDiClose(“AUDUSD”,0,i)/maxAUD;
bufICAD[i] = 100
USD/iClose(“USDCAD”,0,i)/maxCAD;
}

// smoothing
for (j = 0; j < smooth_level; j++)
{
for (i = shift+1; i < to-1; i++)
{
bufIUSD[i] = (bufIUSD[i]+bufIUSD[i+1]+bufIUSD[i-1]) / 3.0;
bufIEUR[i] = (bufIEUR[i]+bufIEUR[i+1]+bufIEUR[i-1]) / 3.0;
bufIGBP[i] = (bufIGBP[i]+bufIGBP[i+1]+bufIGBP[i-1]) / 3.0;
bufICHF[i] = (bufICHF[i]+bufICHF[i+1]+bufICHF[i-1]) / 3.0;
bufIJPY[i] = (bufIJPY[i]+bufIJPY[i+1]+bufIJPY[i-1]) / 3.0;
bufIAUD[i] = (bufIAUD[i]+bufIAUD[i+1]+bufIAUD[i-1]) / 3.0;
bufICAD[i] = (bufICAD[i]+bufICAD[i+1]+bufICAD[i-1]) / 3.0;
}
}

return (0);
}

Many thx :smiley:

Hey guys,

Working on excel issue :wink:
process is slowing down due to Uni start of second semester but no worries!
I found 2 interesting videos:
Markowtiz’s Portfolio Risk Minimization with Excel Solver - YouTube
Sharpe Ratio Maximization with Excel Solver - YouTube

And If the calculus gets too complicated, I’m thinking of an alternative which I dislike given the few numbers of assets, but it would semplify it all quite a lot (index-models) but it would let pop up other issues lol.

Stay tuned

We’re are almsot there yay!

@RICHARD: you think you could give me the following datas?
% variation of a pair every 5 days (for whole 2012).
eg: today price 100, within 5 days is 60 -> -40%. within 5 days price is 62->+3,33% etc etc

Note that I need the % change to be calculate on the newest value, NOT the original one (check example above)

Once we have this information I need the mean of it, so eg: (-40+3)/2

You think you can do it? It’s required to estimate expected return. I’m waiting for feedbacks from my Finance Professor but I think this could be a reliable indicator :wink:

Cry

Hi, Ill take a look at it tomorrow, great to see your still working on it :slight_smile:

Of course I am :wink:

Thx for your help

Hi, I just started looking at your “needs” :wink: So basically you want rate of change from Monday Opening to Friday close?

so you need a matrix of 52 rows, and weekly rate of change for all the pairs? comming upshortly :slight_smile:

hope this works, I have used the open for each week…


roc_weekly <- matrix(rep(0,52*26),nrow=52,ncol=26)
roc_weekly<- as.data.frame(roc_weekly)
colnames(roc_weekly) <- symbols
for (y in 1:26) {
	data <- to.weekly(get(symbols[y])["2012"])[,1]
	data <- ROC(data)
	roc_weekly[,y] <- data
}
roc_weekly[1,] <- 0
roc_weekly <- roc_weekly +1

wich produced this:

The mean of all the data is:


   USDJPY   GBPUSD    USDCHF   EURCHF   AUDUSD   NZDCAD   NZDJPY    AUDNZD
 1.001771 1.000784 0.9994925 0.999854 1.000339 1.000611 1.002887 0.9992206

     EURNZD   GBPCAD   AUDJPY   CADJPY    EURGBP   CHFJPY    USDCAD   NZDUSD
 0.9992427 1.000275 1.002111 1.002279 0.9995754 1.002277 0.9994918 1.001119

    GBPCHF   EURAUD   EURJPY   GBPJPY    EURCAD    AUDCAD CADCHF    AUDCHF
 1.000275 1.000023 1.002131 1.002552 0.9998566 0.9998314      1      0.9998312

    NZDCHF   EURUSD
 1.000611 1.000362

That’s awesome but I need it in % :wink:

Richard you still with me? :slight_smile:

Hi! Im still with you :slight_smile: I have just had a lot of stuff happening the last week, so I havnt been able to work much forex :confused:

But I thought this data was percentage? (I have +1 to every cell to make it easier for my own use) I will look into transforming the data the hard way, but I wont be able to take a look at it before(probably) tuesday :confused:

Hang in there, the data is comming! :slight_smile:

Well if like this is in % than it’s all good. so example: 1.01 -> +1% ? But then why are they all positive? I’m sure lot of them have a negative mean of return :wink:

Take your time