Coding help - page 471

 
systemfault:
Hello Everyone,

i need a help... i have a simple ea, but programmed for 4 digit. (For example: EUR/USD: 1,1234)

How can i use my ea 5 digit? (For example: EUR/USD: 1,12345)

Thanks:)

simpleea.mq4

You can add this :

*MathPow(10,_Digits%2)

where ever you use _Point and then it will work in pips equally on 4 and 5 digit brokers

____________________

 

Hi mladen,

Thanks for post.

I do it this.

int CheckForOpen()

{

double L = Low;

double H = High;

double Lots = MathRound(AccountBalance()/100)/1000;

if((H-Bid>Limit*Point))

{OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,0,"",MAGICMA,0,CLR_NONE);

for(int i=1; i<5; i++){OrderSend(Symbol(),OP_BUYLIMIT,MathPow(2,i)*Lots,Ask-i*Grid*Point*MathPow(10,_Digits%2),1,0,0,"",MAGICMA,0,CLR_NONE);}

}

if((Bid-L>Limit*Point))

{OrderSend(Symbol(),OP_SELL,Lots,Bid,1,0,0,"",MAGICMA,0,CLR_NONE);

for(int j=1; j<5; j++){OrderSend(Symbol(),OP_SELLLIMIT,MathPow(2,j)*Lots,Bid+j*Grid*Point*MathPow(10,_Digits%2),1,0,0,"",MAGICMA,0,CLR_NONE);}

}

}

its true?

 
systemfault:
Hi mladen,

Thanks for post.

I do it this.

int CheckForOpen()

{

double L = Low;

double H = High;

double Lots = MathRound(AccountBalance()/100)/1000;

if((H-Bid>Limit*Point))

{OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,0,"",MAGICMA,0,CLR_NONE);

for(int i=1; i<5; i++){OrderSend(Symbol(),OP_BUYLIMIT,MathPow(2,i)*Lots,Ask-i*Grid*Point*MathPow(10,_Digits%2),1,0,0,"",MAGICMA,0,CLR_NONE);}

}

if((Bid-L>Limit*Point))

{OrderSend(Symbol(),OP_SELL,Lots,Bid,1,0,0,"",MAGICMA,0,CLR_NONE);

for(int j=1; j<5; j++){OrderSend(Symbol(),OP_SELLLIMIT,MathPow(2,j)*Lots,Bid+j*Grid*Point*MathPow(10,_Digits%2),1,0,0,"",MAGICMA,0,CLR_NONE);}

}

}

its true?

Yes

But then also change the Grid parameter from 1500 to 150 or else it will try to set the price 1500 pips away from the Bid or Ask

 

Im using that configuration;

extern int PeriodX = 60;

extern int Limit = 50;

extern int Grid = 14;

extern int Amount = 1;

extern int LockDown = 20;

How is that configuration?

 
systemfault:
Im using that configuration;

extern int PeriodX = 60;

extern int Limit = 50;

extern int Grid = 14;

extern int Amount = 1;

extern int LockDown = 20;

How is that configuration?

It will open buy and sell limits 14 pips away from ask and bid

Try it out

 
mladen:
It will open buy and sell limits 14 pips away from ask and bid Try it out

i try... seems this...

Files:
adsz.png  35 kb
 
systemfault:
i try... seems this...

As far as I see it is doing what it is intended to do

 
mladen:
As far as I see it is doing what it is intended to do

Yeah mladen..

But i dont want to close the orders without profit and stoploss 14 pips

 
systemfault:
Yeah mladen.. But i dont want to close the orders without profit and stoploss 14 pips

Then add take profit and stop loss too

 
mladen:
Then add take profit and stop loss too

im added this code;

int CheckForClose()

{

if(getProfit()>=Amount){CloseAll();}

if(LockDown>0)

{

for(int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--)

{

if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES)&&(LockDown>0))

{ int Pos=OrderType();

if((Pos==OP_BUY)&&(Bid-OrderOpenPrice()>Point*MathPow(10,_Digits%2)*LockDown)&&(OrderStopLoss() == 0))

{OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE);}

if((Pos==OP_SELL)&&(OrderOpenPrice()-Ask>Point*MathPow(10,_Digits%2)*LockDown)&&(OrderStopLoss() == 0))

{OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point,OrderTakeProfit(),0,CLR_NONE);}

}

}

}

}

For example; EUR/USD order price 1.12345 sl/tp 1.12346

i want to sl/tp 1.12355

im not understanding whats going wrong?

Reason: