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
I need to try a bit...
by the way, I did delete all the StopCycle filter from the first code, that is probably the main problem, but I thought it was useless with OpenBuySignal condition...
A normal mind, find the C + + language really stupid, now I know why it has been replaced by many other languages leaner and more dynamicDoc
I don't think tat the StopCycle is causing that problem. I think that the main problem is that metatrader 5 versions tend to be very complicated and that easily leads to problems. The way how that "macd" EA is written it hides most of the things we actually do not need to see and leaves the essential - that way only what is really important is left and can help in building an error free EA
Doc I don't think tat the StopCycle is causing that problem. I think that the main problem is that metatrader 5 versions tend to be very complicated and that easily leads to problems. The way how that "macd" EA is written it hides most of the things we actually do not need to see and leaves the essential - that way only what is really important is left and can help in building an error free EA
Thanks Mladen,
I have this doubt:
I need to place in your code this part for calculate my pips earning during a deal:
{
int total = PositionsTotal();
double profit = 0;
for(int cnt=0; cnt<total; cnt++)
{
string sSymbol=PositionGetSymbol(cnt);
if(PositionSelect(sSymbol) == true && sSymbol == _Symbol && PositionGetInteger(POSITION_MAGIC) == Magic)
{
double open = PositionGetDouble(POSITION_PRICE_OPEN);
double close = PositionGetDouble(POSITION_PRICE_CURRENT);
if(mode == 1)
{
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ) profit = (close - open)/_point;
else
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) profit = (open - close)/_point;
}
else
profit = PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP) + PositionGetDouble(POSITION_COMMISSION);
}
}
return(profit);
}Is there a simpler way to code it?
Thanks Mladen,
I have this doubt:
I need to place in your code this part for calculate my pips earning during a deal:
{
int total = PositionsTotal();
double profit = 0;
for(int cnt=0; cnt<total; cnt++)
{
string sSymbol=PositionGetSymbol(cnt);
if(PositionSelect(sSymbol) == true && sSymbol == _Symbol && PositionGetInteger(POSITION_MAGIC) == Magic)
{
double open = PositionGetDouble(POSITION_PRICE_OPEN);
double close = PositionGetDouble(POSITION_PRICE_CURRENT);
if(mode == 1)
{
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ) profit = (close - open)/_point;
else
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) profit = (open - close)/_point;
}
else
profit = PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP) + PositionGetDouble(POSITION_COMMISSION);
}
}
return(profit);
}Doc
No, there is no simpler way to do that
Doc No, there is no simpler way to do that
Mladen,
I tried but probably there is something wrong with the getLastOrderType function because it doesn't open any position
doc
Mladen,
I tried but probably there is something wrong with the getLastOrderType function because it doesn't open any position
docDoc
Just replace the "-1" in the following line :
trade.PositionOpen(_Symbol,-1,getLots(Lots,Risk,StopLossPips*pip),SymbolInfoDouble(_Symbol,signal==ORDER_TYPE_SELL ? SYMBOL_BID:SYMBOL_ASK),sl,tp);
with "signal" and it will work
Good morning Mladen,
I started to code what should be my close...but I don't know what condition is necessary here
{
int doWhat = checkExit(); if (doWhat==_doNothing) return;
//
//
//
//
ENUM_ORDER_TYPE signal2;
if (doWhat==_doCloseBuy) signal2 = ORDER_TYPE_SELL;
if (doWhat==_doCloseSell) signal2 = ORDER_TYPE_BUY;Could you please tell me the right and proper way?
Thanks
doc
Good morning Mladen,
I started to code what should be my close...but I don't know what condition is necessary here
{
int doWhat = checkExit(); if (doWhat==_doNothing) return;
//
//
//
//
ENUM_ORDER_TYPE signal2;
if (doWhat==_doCloseBuy) signal2 = ORDER_TYPE_SELL;
if (doWhat==_doCloseSell) signal2 = ORDER_TYPE_BUY;Could you please tell me the right and proper way? Thanks
docDoc
Try to do something like in the one attached
_________________
PS: even though it is closing the position when signaled so, maybe you should check for the conditions to close in the checkExit() function
Mladen,
I have a problem with the time filter...I cannot have 0 neither have minutes.
Another thing is that I cannot delete it from close opened because otherwise it doesn't work the checkexit condition.
How could I combine together ct.hour && ct.min ? I need to write something like double date(int Hour, int Min) etc.?
Thanks
doc
Mladen,
I have a problem with the time filter...I cannot have 0 neither have minutes.
Another thing is that I cannot delete it from close opened because otherwise it doesn't work the checkexit condition.
How could I combine together ct.hour && ct.min ? I need to write something like double date(int Hour, int Min) etc.?
Thanks
docDoc,
To effectively turn the time filter off set the start time to 0 and end time to 24
To add minutes, it would need to have minutes specified in the parameters and then used in the time filter
Mladen,
I have a problem with the time filter...I cannot have 0 neither have minutes.
Another thing is that I cannot delete it from close opened because otherwise it doesn't work the checkexit condition.
How could I combine together ct.hour && ct.min ? I need to write something like double date(int Hour, int Min) etc.?
Thanks
docDoc,
In order to allow combinations of hour like from 22 to 03 (just one example) and to include the starting and ending our in the time filter, the code for time checking should look like this :
if (EndingHour<StartHour)
allowedHours = (ct.hour>=StartHour || ct.hour<=EndingHour);
else allowedHours = (ct.hour>=StartHour && ct.hour<=EndingHour);
if you want to include minutes too then they should be declared in parameters and a ct.min>=SomeMinute or ct.min<=SomeOtherMinte can be added to conditions