How to code? - page 3

 

about code of mql4

i want to put the hight and low price in current chart .

but i do not konw how to write the code in my indicator by MQL4.

thanks a lot!

 

Code to move stoploss?

Hi all,

Coding an EA at the moment to autotrade for me, it's getting towards completion but i can't figure out how to move the stoploss on an open trade. i am posting my code here, if anyone could point out what i'm doing wrong i would greatly appreciate

This is the part of code which opens a LONG position:

{

if(//long entry criteria met)

{

if (priorbartime == Time[0])

return(0);

priorbartime = Time[0];

Alert("Long Signal");

ObjectCreate(arrowlong, OBJ_ARROW, 0, Time[0], Open[0], 0, 0, 0, 0);

ObjectSet(arrowlong, OBJPROP_ARROWCODE, 233);

ObjectSet(arrowlong, OBJPROP_COLOR, Aqua);

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-StopLoss*Point,Ask+TakeProfit*Point,"am crossing",16677,0,Green); // HDB CHANGED Close TO Ask and SlipPage to 0

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

}

[/PHP]

then once the trade is open I want to manage it by moving stop to -5 when the trade is +15, and by moving stop to b/e when trade is +20. this is the code i have come up with so far but it doesnt seem to be working:

[PHP]

total=OrdersTotal();

if(total>0)

{

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol())

{

if(Bid-OrderOpenPrice()==Point*15)

{

OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*5,OrderTakeProfit(),0,Blue);

return(0);

}

if(Bid-OrderOpenPrice()==Point*20)

{

OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);

return(0);

}

}

}

}

As mentioned, this is all for LONG positions.

Thanks for any help!

divergence_trader

 

Many people asked about it already many times.

So read:

- this post,

- this one and

- this Codersguru thread.

 

thanks newdigital, i'ev looked round many threads at SBFX, metaquotes and here but managed to not find what i was looking for, hopefully these will help!

 

Try this:

total=OrdersTotal();

if(total>0){

for(cnt=0;cnt<total;cnt++){

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol()){

if(Bid-OrderOpenPrice()>=Point*15 && Bid-OrderOpenPrice()<Point*20 && OrderStopLoss()< OrderOpenPrice()-5*Point){

OrderModify(OrderTicket(),OrderOpenPrice()-Point*5,OrderTakeProfit(),Blue);

}

if(Bid-OrderOpenPrice()>=Point*20 && OrderStopLoss()< OrderOpenPrice()){

OrderModify(OrderTicket(),OrderOpenPrice(),OrderTakeProfit(),Blue);

}

}

}

}
 

like these

 

code of MA levels

hi

i try to write a code of MA levels but it's not working ...

any one can tell me how can i do it plz.

thanks

Files:
levels.png  20 kb
 
mas:
hi

i try to write a code of MA levels but it's not working ...

any one can tell me how can i do it plz.

thanks

You can use the Vegas Currancy Daily indicator as a guide. See attachement.

Keris

Files:
 
Nicholishen:
Try this:

Thanks Nicholishen, your code works perfectly. Didn't get an opportunuity to test it in a live market until now but all working fine. thanks again!

 

Request: EA code to double up lot size after a losing trade.

I want to know if there's any way to tell an EA to increase the lot size if the last trade closed in loss (martingale system), and use the normal lot size if the last trade closed in profit. It needs to be able to use micro lots. Is there any way to do this?

Reason: