You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Christoff
That way Decimals variable should be OK
In any case, check what error code are you getting in a case of unsuccessful order (partial) closeMladen,
Thank you for the hint.
The problem is that there is no error message. When it does not work, it seems as if PartialTP function has not even been called. Other times - usually at the first orders after the EA restarted - it works well.
I thought maybe one of the variables does not get back to zero value, or something like that, but I still cannot find the bug.
Mladen,
Thank you for the hint.
The problem is that there is no error message. When it does not work, it seems as if PartialTP function has not even been called. Other times - usually at the first orders after the EA restarted - it works well.
I thought maybe one of the variables does not get back to zero value, or something like that, but I still cannot find the bug.chrisstoff
Sorry, but with a partial code I can not help more
What you are describing means that there is a need to debug the code - and that can be done only by executing it while using some sort of control points
chrisstoff
Sorry, but with a partial code I can not help more
What you are describing means that there is a need to debug the code - and that can be done only by executing it while using some sort of control pointsThank you, Mladen.
It is reassuring that you did not see problems in the code.
I think all the relevant parts of the code was posted, so I have to find the bug elsewhere.
hock87
Please read the post above your post for a solution of that problem
The complete code for that is the following :
int TotalOrders = 0;
for (int i=0; i <= OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol() == Symbol())
TotalOrders++;
}
if (TotalOrders<1)
{
ticket=OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0);
stop=(Ask-stopsize*Point);
prof=(Ask+profsize*Point);
OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Blue);
}
Malden,
If I want to open lot sizes at a percentage of my account balance, how to code it?
Example:
My account balance $500,
i want to open a lot sizes with 5%, then it auto count and open the $0.25 lots, TP=10 SL=20.
How to code it?
Thanks.
Malden,
If I want to open lot sizes at a percentage of my account balance, how to code it?
Example:
My account balance $500,
i want to open a lot sizes with 5%, then it auto count and open the $0.25 lots, TP=10 SL=20.
How to code it?
Thanks.You can use a function like this for that :
{
RefreshRates();
double pPoint = MarketInfo(Symbol(),MODE_POINT);
double step = MarketInfo(Symbol(),MODE_LOTSTEP);
double minLot = MarketInfo(Symbol()l,MODE_MINLOT);
double maxLot = MarketInfo(Symbol(),MODE_MAXLOT);
double lots = minLot;
if (risk>0 && stopLoss>0)
{
lots = AccountFreeMargin()*(risk/100.0)/(stopLoss*MarketInfo(s_symbol,MODE_TICKVALUE)/pPoint);
}
}
return(MathMax(MathMin(lots,maxLot),minLot));
}
PS: stopLoss has to be passed to the function in pips/points already (not in integer values)
You can use a function like this for that :
{
RefreshRates();
double pPoint = MarketInfo(Symbol(),MODE_POINT);
double step = MarketInfo(Symbol(),MODE_LOTSTEP);
double minLot = MarketInfo(Symbol()l,MODE_MINLOT);
double maxLot = MarketInfo(Symbol(),MODE_MAXLOT);
double lots = minLot;
if (risk>0 && stopLoss>0)
{
lots = AccountFreeMargin()*(risk/100.0)/(stopLoss*MarketInfo(s_symbol,MODE_TICKVALUE)/pPoint);
}
}
return(MathMax(MathMin(lots,maxLot),minLot));
}
Thanks, Mladen.
But I failure to compound the code to buy order code.
It appear many errors and warning.
How to compound it?
Thanks.
extern double profsize = 10;
int err;
int ticket;
double stop;
double prof;
int start()
{
int TotalOrders = 0;
for (int i=0; i <= OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol() == Symbol())
TotalOrders++;
}
if (TotalOrders<1)
{
ticket=OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0, NULL,LimeGreen);
stop=(Ask-stopsize*Point);
prof=(Ask+profsize*Point);
OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Blue);
}
err=GetLastError();
// Comment("This is a test ", err, " ", stop, " ", prof);
Comment(" ");
}Thanks, Mladen.
But I failure to compound the code to buy order code.
It appear many errors and warning.
How to compound it?
Thanks.
extern double profsize = 10;
int err;
int ticket;
double stop;
double prof;
int start()
{
int TotalOrders = 0;
for (int i=0; i <= OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol() == Symbol())
TotalOrders++;
}
if (TotalOrders<1)
{
ticket=OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0, NULL,LimeGreen);
stop=(Ask-stopsize*Point);
prof=(Ask+profsize*Point);
OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Blue);
}
err=GetLastError();
// Comment("This is a test ", err, " ", stop, " ", prof);
Comment(" ");
}Try it like this (I tested it now and it works) :
extern double profsize = 10;
int err;
int ticket;
double stop;
double prof;
int init() { return(0); }
int deinit() { return(0); }
int start()
{
int TotalOrders = 0;
for (int i=0; i <= OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol() == Symbol())
TotalOrders++;
}
if (TotalOrders<1)
{
ticket=OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0, NULL,LimeGreen);
stop=(Ask-stopsize*Point*MathPow(10,Digits%2));
prof=(Ask+profsize*Point*MathPow(10,Digits%2));
OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Blue);
}
err=GetLastError();
// Comment("This is a test ", err, " ", stop, " ", prof);
Comment(" ");
}dear mladen and mr. tools pls,
is it possible to create an ea that gives signal based on certain conditions like the signals of 3 or 4 indicators meeting predefined conditions.
e.g
i want the ea to signal a buy hwen:
ema 8 cross ema 21
qqe above 0
non lag ma is green
and candle is above the ichimoku cloud
the EA should not open trades but just give the signal when the stated conditions are met
Thank you, Mladen.
I have try it.
but it still open the lots with $0.1
I want toopen lot sizes at a percentage of my account balance.
EX:account balance have $500.
open a lot sizes with 5%, then it auto count and open the $0.25 lots, TP=10 SL=20.
LotSizeSlot1 = AccountBalance() * (RiskSlot1 / 100)
LotSizeSlot1 = $500*(5%/100)
LotSizeSlot1 = $ 0.25
Then it auto open $0.25 lots and TP=10 SL=20.
How to create it?
Thanks.
Thank you, Mladen.
I have try it.
but it still open the lots with $0.1
I want toopen lot sizes at a percentage of my account balance.
EX:account balance have $500.
open a lot sizes with 5%, then it auto count and open the $0.25 lots, TP=10 SL=20.
LotSizeSlot1 = AccountBalance() * (RiskSlot1 / 100)
LotSizeSlot1 = $500*(5%/100)
LotSizeSlot1 = $ 0.25
Then it auto open $0.25 lots and TP=10 SL=20.
How to create it?
Thanks.Like in the one attached