iMACD problem

[Deleted]  
Hello,

i have a question :

i am working on my own ea. One of my indicators are the MACD and with that i have some problems:

I want to know when the red signal line cross the 0 line:


SignalCurrent=iMACD(NULL,0,12,26,1,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,1,PRICE_CLOSE,MODE_SIGNAL,1);

if(SignalPrevious>0 && SignalCurrent<0)
{
.......
}

but it doesnt work ! Is this the red signal line ?

i hope someone can help me

Mo1k
Brian Dee - Random Trader
1757
Brian Dee - Random Trader  

M
You want to know whaen the MODE_MAIN line has crossed the MODE_SIGNAL, see this

   MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
   MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
   SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
   SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);


Good Luck
-BB-

[Deleted]  
ok the problem is not the indicator but my order:

not working:
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-50*Point,"test",12345,0,Red);

working:
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"test",12345,0,Red);

what is wrong with my take profit ?
Brian Dee - Random Trader
1757
Brian Dee - Random Trader  

M
If this is a sub-pip account, then 50 may be too close to the opening price for a stop to be allowed, you probably meant 50 (full) pips so that would be 500 here?
-BB-

[Deleted]  
thats right my test account has 5 numbers 1.45487 but the there is no limit for stop !
rv
461
rv  
Mo1k wrote >>
Hello,

i have a question :

i am working on my own ea. One of my indicators are the MACD and with that i have some problems:

I want to know when the red signal line cross the 0 line:


SignalCurrent=iMACD(NULL,0,12,26,1,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,1,PRICE_CLOSE,MODE_SIGNAL,1);

if(SignalPrevious>0 && SignalCurrent<0)
{
.......
}

but it doesnt work ! Is this the red signal line ?

i hope someone can help me

Mo1k


SignalCurrent is double or int?

Piotr
1277
Piotr  
EADeveloper:


SignalCurrent is double or int?

All the iMACD Signals should be as the DOUBLE

William Roeder
25064
William Roeder  
Mo1k:
not working:
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-50*Point,"test",12345,0,Red);

Don't use Point, adjust for 5 digit brokers both your stop and slippage:

//++++ These are adjusted for 5 digit brokers.
double  pips2points,    // slippage  3 pips    3=points    30=points
        pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int init() {
    if (Digits == 5 || Digits == 3) {   // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
On a sell your stops are relative to the Ask. Therefor even 5 pips-2(spread) could be less than (3pips) MarketInfo( Symbol(), MODE_STOPLEVEL )
#define 50pips 50
#define 3pips 3
double minGap=MarketInfo( Symbol(), MODE_STOPLEVEL )*Point;
double TP = MathMin(Ask-minGap, Bid-50PIPS*pips2dbl);
ticket=OrderSend(Symbol(), OP_SELL, Lots, Bid, 3PIPS*pips2points, 0, 
                 TP, "test", 12345, 0, Red);