I'm sorry but what is m ?
if(n<1) // n = 0 so it's smaller then 1
{
n=0; // n = forever 0
}
counter=n; // now counter is also 0
n=counter+m; // n = 0 + m
}
{
n=0; // n = forever 0
}
counter=n; // now counter is also 0
n=counter+m; // n = 0 + m
}
Marco vd Heijden:
It on the hedge condition as per my code, different condition, different value of m.I'm sorry but what is m ?
if(n<1) // n = 0 so it's smaller then 1
{
n=0; // n = forever 0
}
counter=n; // now counter is also 0
n=counter+m; // n = 0 + m
}
{
n=0; // n = forever 0
}
counter=n; // now counter is also 0
n=counter+m; // n = 0 + m
}
but then, its not work at all..
- No idea what that code is trying to do. Zero a variable before the loop and increment the variable in the loop. Move the rest outside the loop.
- for(int i=0; i<OrdersHistoryTotal();i++){Perhaps you should read the manual. OrderSelect does not return a ticket number.
OTicket = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); - There are other things in history besides closed buys and sells.
- Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
whroeder1:
- No idea what that code is trying to do. Zero a variable before the loop and increment the variable in the loop. Move the rest outside the loop.
- for(int i=0; i<OrdersHistoryTotal();i++){Perhaps you should read the manual. OrderSelect does not return a ticket number.
OTicket = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); - There are other things in history besides closed buys and sells.
- Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
1. I want to used counter "n" to represent extra condition for my hedge, different value of n would be different condition as per code. The equation should be like n=n+m and n=n-m, m would be different value on the condition which take next order to next condition. However, it seem not count at all, i try to put everywhere but still not count at all. Can you help me on this?
2. Thanks for remind me on the OrderSelect(), almost forgot to put the condition that you mention. Thanks.
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
Hi Guys,
Need help on my EA code, currently I'm trying to define the condition using counter formula, so each time the counter increase or decrease would be my extra condition to perform. But somehow this counter not work.
Can someone please help me to solve this problem. Thanks.
//| Start Trade and Check Order Conditions |
//+-------------------------------------------------------------------------------------------+
void CheckForTrade()
{
//------------------ Check OrderType in History
for(int i=0; i<OrdersHistoryTotal();i++)
{
OTicket = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
OProfit = OrderProfit();
OType = OrderType();
OLot = OrderLots();
//----- counter <-----------------------------------this counter not work, please help me to solve this problem
if(n<1)
{
n=0;
}
counter=n;
n=counter+m;
}
//------------------ Hedge Lot Calculation
Hedge_Lot = NormalizeDouble((OLot*2),2)+Lot_Size;
//------------------ Order is closed
if(OrdersTotal()==0)
{
//------------------ Initial trades
if(OProfit==0)
{
Lot = Lot_Size;
Selling();
return;
}
//------------------ Hedge condition
if(OType==OP_SELL && OProfit>0)
{
if(n==0)
{
Lot=Lot_Size;
Buying();
}
else
{
m=-1;
Lot = Lot_Size;
Buying();
return;
}
}
if(OType==OP_BUY && OProfit>0)
{
if(n==0)
{
Lot=Lot_Size;
Selling();
}
else
{
m=-1;
Lot = Lot_Size;
Selling();
return;
}
}
if(OType==OP_SELL && OProfit<0)
{
if(OLot>1.3)
{
if(n==0)
{
m=2;
}
else
{
m=1;
}
OLot=OLot;
Buying();
return;
}
else
{
Lot = Hedge_Lot;
Buying();
return;
}
}
if(OType==OP_BUY && OProfit<0)
{
if(OLot>1.3)
{
if(n==0)
{
m=2;
}
else
{
m=1;
}
OLot=OLot;
Selling();
return;
}
else
{
Lot = Hedge_Lot;
Selling();
return;
}
}
}
}