Edit Your Comment
Best forums for discussing beginner-friendly MQL4 scripting?
Jan 25, 2017 zamanından beri üye
12 iletiler
Jan 29, 2017 at 08:16
(Jan 29, 2017 at 01:30 düzenlendi)
Jan 25, 2017 zamanından beri üye
12 iletiler
I'm trying to devise a way to calculate a Breakeven point across multiple orders, then update my orders once the threshold has been crossed across the multiple pair average.
I would also like to calculate a Take Profit across multiple orders, then update my take profit when new orders are entered.
This is something I intuitively do while manually trading, but I'm having some difficulty typing it out.
How would you break this down in pseudo-code? Are there some beginner-friendly MQL4 scripting forums to discuss this sort of thing?
I would also like to calculate a Take Profit across multiple orders, then update my take profit when new orders are entered.
This is something I intuitively do while manually trading, but I'm having some difficulty typing it out.
How would you break this down in pseudo-code? Are there some beginner-friendly MQL4 scripting forums to discuss this sort of thing?
Sep 20, 2014 zamanından beri üye
365 iletiler
Jan 29, 2017 at 13:02
Sep 20, 2014 zamanından beri üye
365 iletiler
Well, you can start by clearly defining what you want to do. I can see you haven't.
You're talking about apples and pears. First its BE on multiple orders (or is that positions as orders haven't been hit yet to create positions ?) and then it's multiple pairs average, so how does that work on say Eurusd at 1.20 v. UsdJpy on 121.00 something ? What's the average of a 100 units EurUsd at 1.20 and 112 units UsdJpy at 121.00?
To do what you want to do, if I read it correctly, you'd have to work out the weighted average on each pair you're trading, and then convert ALL OF THEM to a USD value, iow's create a USD weighted average of the weighted averages of your positions. If you intend to do it correctly that is. And to code that is a shit load of work. At least a thousand lines of code, maybe more.
It's not for an amateur. You need to know what you're doing to do this. But doing it will be absolutely invaluable to your trading. It is well worth doing even if it is difficult. And it's not valuable because of any result it gives you, it's valuable because it will teach you how to view fx positions as quantifiable assets and calculate their value at any given time.
In effect it also means you're trading USD against everything. Is that what you want to do ? Because that's what you're about to do. And USD moves around in value all the time, so your targets are moving.
So now that we've had a look at a few of the details, tell me clearly and concisely what you want to do and I will see if I can help.
In the meantime I suggest a bit of study on weighted averages, that's essentially your question: https://www.investopedia.com/terms/w/weightedaverage.asp
You're talking about apples and pears. First its BE on multiple orders (or is that positions as orders haven't been hit yet to create positions ?) and then it's multiple pairs average, so how does that work on say Eurusd at 1.20 v. UsdJpy on 121.00 something ? What's the average of a 100 units EurUsd at 1.20 and 112 units UsdJpy at 121.00?
To do what you want to do, if I read it correctly, you'd have to work out the weighted average on each pair you're trading, and then convert ALL OF THEM to a USD value, iow's create a USD weighted average of the weighted averages of your positions. If you intend to do it correctly that is. And to code that is a shit load of work. At least a thousand lines of code, maybe more.
It's not for an amateur. You need to know what you're doing to do this. But doing it will be absolutely invaluable to your trading. It is well worth doing even if it is difficult. And it's not valuable because of any result it gives you, it's valuable because it will teach you how to view fx positions as quantifiable assets and calculate their value at any given time.
In effect it also means you're trading USD against everything. Is that what you want to do ? Because that's what you're about to do. And USD moves around in value all the time, so your targets are moving.
So now that we've had a look at a few of the details, tell me clearly and concisely what you want to do and I will see if I can help.
In the meantime I suggest a bit of study on weighted averages, that's essentially your question: https://www.investopedia.com/terms/w/weightedaverage.asp
Sep 20, 2014 zamanından beri üye
365 iletiler
Jan 29, 2017 at 13:17
Sep 20, 2014 zamanından beri üye
365 iletiler
As a footnote. The people who can do these calcs are the ones who can trade fx. It's an absolute minimum requirement in my humble opinion.
Aug 20, 2009 zamanından beri üye
266 iletiler
Jan 30, 2017 at 08:11
Aug 20, 2009 zamanından beri üye
266 iletiler
Here you go........it is a function that takes a MagicNumber and Symbol and returns the Weighted-Cost Average entry price for all the orders. You simply add your TP to that price........
//+------------------------------------------------------------------+
double Get_WCA_Entry(int l_Magic, string l_Symbol)
{
double
Entry,
Price_x_Lots=0,
Sum_Lots=0,
WCA_TP=0;
int dig = (int)MarketInfo(l_Symbol,MODE_DIGITS);
//|............
for(int i = OrdersTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderType()>1)continue;
if(OrderMagicNumber()==l_Magic){
if(OrderSymbol()==l_Symbol){
Price_x_Lots += OrderOpenPrice() * OrderLots();
Sum_Lots += OrderLots();
}
}
}
}
if(Sum_Lots==0){
Print(OrderSymbol() + ' divide zero error trapped in Get_WCA_Entry. l_Symbol = ' + l_Symbol);
return(-1);
}
Entry = Price_x_Lots/Sum_Lots;
return(Entry);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
double Get_WCA_Entry(int l_Magic, string l_Symbol)
{
double
Entry,
Price_x_Lots=0,
Sum_Lots=0,
WCA_TP=0;
int dig = (int)MarketInfo(l_Symbol,MODE_DIGITS);
//|............
for(int i = OrdersTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderType()>1)continue;
if(OrderMagicNumber()==l_Magic){
if(OrderSymbol()==l_Symbol){
Price_x_Lots += OrderOpenPrice() * OrderLots();
Sum_Lots += OrderLots();
}
}
}
}
if(Sum_Lots==0){
Print(OrderSymbol() + ' divide zero error trapped in Get_WCA_Entry. l_Symbol = ' + l_Symbol);
return(-1);
}
Entry = Price_x_Lots/Sum_Lots;
return(Entry);
}
//+------------------------------------------------------------------+
Wealth Creation Through Technology
Sep 20, 2014 zamanından beri üye
365 iletiler
Jan 30, 2017 at 08:52
Sep 20, 2014 zamanından beri üye
365 iletiler
So @compuforexpamm, where exactly in this is the conversion to compare say a JPY position to a EURO position or a USD position to compare 'once the threshold has been crossed across the multiple pair average '?
Each pair has to go to a single value to be comparable. That code is useless for his purposes.
Each pair has to go to a single value to be comparable. That code is useless for his purposes.
forex_trader_367321
Oct 08, 2016 zamanından beri üye
58 iletiler
Feb 07, 2017 at 12:32
Oct 08, 2016 zamanından beri üye
58 iletiler
fxftw,
if you are fortunate to find a good software composer, please forward his contact information to me when you are finished with him.
I ask for good composer with good hygiene habits and good manners.
Thank you.
if you are fortunate to find a good software composer, please forward his contact information to me when you are finished with him.
I ask for good composer with good hygiene habits and good manners.
Thank you.
Sep 20, 2014 zamanından beri üye
365 iletiler
Feb 07, 2017 at 12:54
(Feb 07, 2017 at 12:55 düzenlendi)
Sep 20, 2014 zamanından beri üye
365 iletiler
Can't ban me in all threads Zero.
I have to ask, why do you even still try ?
I have to ask, why do you even still try ?
forex_trader_367321
Oct 08, 2016 zamanından beri üye
58 iletiler
Feb 08, 2017 at 03:04
Oct 08, 2016 zamanından beri üye
58 iletiler
Sep 20, 2014 zamanından beri üye
365 iletiler
Feb 08, 2017 at 04:51
Sep 20, 2014 zamanından beri üye
365 iletiler
Well, more the point why are you looking at people to code for you ? Fingers fall off or something ?
forex_trader_367321
Oct 08, 2016 zamanından beri üye
58 iletiler
Sep 20, 2014 zamanından beri üye
365 iletiler
Feb 08, 2017 at 06:03
(Feb 08, 2017 at 06:03 düzenlendi)
Sep 20, 2014 zamanından beri üye
365 iletiler
You can code. Why are you looking to get people to code for you ? What's really going on ? But then again it doesn't really matter, does it?
I think I'll go drink beer at the pool for a few hours. Good luck with whatever the latest scheme is.
I think I'll go drink beer at the pool for a few hours. Good luck with whatever the latest scheme is.
Feb 22, 2011 zamanından beri üye
4862 iletiler
Feb 09, 2017 at 16:05
Feb 22, 2011 zamanından beri üye
4862 iletiler
benchmarkpro posted:You dont seem to have
fxftw,
if you are fortunate to find a good software composer, please forward his contact information to me when you are finished with him.
I ask for good composer with good hygiene habits and good manners.
Thank you.
good hygiene habits
forex_trader_367321
Oct 08, 2016 zamanından beri üye
58 iletiler
Feb 09, 2017 at 16:08
Oct 08, 2016 zamanından beri üye
58 iletiler
I washed my socks tomorrow.
Dont worry, be happy.
Dont worry, be happy.
*Ticari kullanım ve istenmeyen e-postalara müsamaha gösterilmez ve hesabın feshedilmesine neden olabilir.
İpucu: Bir resim/youtube urlsi yayınlamak, onu otomatik olarak gönderinize gömer!
İpucu: Bu tartışmaya katılan bir kullanıcı adını otomatik olarak tamamlamak için @ işaretini yazın.