
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
Dear Mrtools/Mladen
Cud u plz set the max distance parameter to be distance of closing price of a bar from the slow ma
the curr setting is meaningless imho
Thanks
SachinSachin
Simply find the line that goes like this :
MaxDistance = MathFloor(MathAbs((FastMACurrent-SlowMACurrent)/pPoint));
and replace the FastMACurrent with either Close[1] (for the close of first closed bar) or Close[0] (for the close of the still opened bar)
ok i have done that now testing..cheers
cud u plz also assist here : https://www.mql5.com/en/forum/general
Sachin
Simply find the line that goes like this :
MaxDistance = MathFloor(MathAbs((FastMACurrent-SlowMACurrent)/pPoint));
and replace the FastMACurrent with either Close[1] (for the close of first closed bar) or Close[0] (for the close of the still opened bar)Dear Mladen cud u please check why time filter isn't working . see red vertical lines on chart where it is not supposed to trade but traded. In Ea i set trade only certain hours. Many Thanks
Sachin
Simply find the line that goes like this :
MaxDistance = MathFloor(MathAbs((FastMACurrent-SlowMACurrent)/pPoint));
and replace the FastMACurrent with either Close[1] (for the close of first closed bar) or Close[0] (for the close of the still opened bar)Hi Mladen,
I could not compile mql4 code because of following errors:
extern string Pivot.Setting = "---------- Pivot Filter Setting";
extern bool Use.Pivot.Filter = false;
==> '.' - semicolon expected MACrossEAV1.5.mq4 77 28 if(Use.Pivot.Filter==true)
==> 'Use' - undeclared identifier MACrossEAV1.5.mq4 458 7
'Pivot' - struct or class type expected MACrossEAV1.5.mq4 458 11
'Filter' - struct or class type expected MACrossEAV1.5.mq4 458 17
What did I do wrong?
Thanks for your help
Hi Mladen,
I could not compile mql4 code because of following errors:
extern string Pivot.Setting = "---------- Pivot Filter Setting";
extern bool Use.Pivot.Filter = false;
==> '.' - semicolon expected MACrossEAV1.5.mq4 77 28 if(Use.Pivot.Filter==true)
==> 'Use' - undeclared identifier MACrossEAV1.5.mq4 458 7
'Pivot' - struct or class type expected MACrossEAV1.5.mq4 458 11
'Filter' - struct or class type expected MACrossEAV1.5.mq4 458 17
What did I do wrong?
Thanks for your helpStephFX
Remove the "." from the variable name
You can replace it with "_" for example and then you will have :
extern string Pivot_Setting = "---------- Pivot Filter Setting";
extern bool Use_Pivot_Filter = false;
and this
if(Use_Pivot_Filter==true)
and then all will compile OK
Hi everybody,
Since I am trying out a martingale strategy, I tried to make it so that "STOP AND REVERSE" only works when the last trade was a win.
{
for(int count=histotal-1;count>=0;count--)
{
if(OrderSelect(count,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderProfit()>0)
{
if(StopAndReverse==true && subTotalTrade()>0)
{
if((LastTrade=="BUY" && SellCondition==true) || (LastTrade=="SELL" && BuyCondition==true))
{
subCloseOrder();
if(subTotalTrade()>0) subCloseOrder();
if(subTotalTrade()>0) subCloseOrder();
if(IsTesting() && PrintControl==true) Print("STOP AND REVERSE !");
}
}
}
}
}
}
}
It doesn't seem to be working, however. It will stop and reverse even if the last trade was a loss. Any suggestions?
Thanks!
Hi everybody,
Since I am trying out a martingale strategy, I tried to make it so that "STOP AND REVERSE" only works when the last trade was a win.
It doesn't seem to be working, however. It will stop and reverse even if the last trade was a loss. Any suggestions?
Thanks!You are not checking the time of the order. You must check the close time of the order too, and the order with the greatest close time is the one you want to check for profit
You are not checking the time of the order. You must check the close time of the order too, and the order with the greatest close time is the one you want to check for profit
The thing is I use a very similar code for the martingale system which works perfectly:
//|---------martingale
int martingalefactor()
{
int histotal=OrdersHistoryTotal();
if (histotal>0)
{
for(int cnt=histotal-1;cnt>=0;cnt--)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderProfit()<0)
{
lotsfactor=lotsfactor*multiplier;
return(lotsfactor);
}
else
{
lotsfactor=initiallotsfactor;
if(lotsfactor<=0)
{
lotsfactor=1;
}
return(lotsfactor);
}
}
}
}
}
return(lotsfactor);
}
Since it works for martingale, shouldn't it work now also?
The thing is I use a very similar code for the martingale system which works perfectly: Since it works for martingale, shouldn't it work now also?
Try using something like this :
{
double TempLastOrderProfit = 0;
datetime CloseTime = 0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderCloseTime()>CloseTime)
{
CloseTime = OrderCloseTime();
TempLastOrderProfit = OrderProfit() + OrderSwap()+ OrderCommission();
}
}
return(TempLastOrderProfit);
}
It will return you the exact amount of the profit (or loss) of the last order
Try using something like this : It will return you the exact amount of the profit (or loss) of the last order
Thank you for you're help, Mladen. I tweaked with the code a little until I got it compiling without any errors, but the EA still stops and reversed after a loss. This is the exact code I'm using now:
{
double TempLastOrderProfit = 0;
datetime CloseTime = 0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderCloseTime()>CloseTime)
{
CloseTime = OrderCloseTime();
}
}
if(StopAndReverse==true && subTotalTrade()>0 && OrderProfit()>0)
{
if((LastTrade=="BUY" && SellCondition==true) || (LastTrade=="SELL" && BuyCondition==true))
{
subCloseOrder();
if(subTotalTrade()>0) subCloseOrder();
if(subTotalTrade()>0) subCloseOrder();
if(IsTesting() && PrintControl==true) Print("STOP AND REVERSE !");
}
}
}
double GetLastPL() Gives me the following error: '(' - function definition unexpected.