MQL4 Learning - page 51

 

newbie need help

hello !

I am learing how to make an EA,

but it does not work...

can you help me?

here is my EA :

extern string op;

int ticket;

double lastprice;

int init()

{

return(0);

}

int deinit()

{

return(0);

}

int start()

{

//----

if (op=="buy")

{

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,1,Ask-10*Point,Ask+250*Point,"My order #1",00001,0,Green);

lastprice=Ask;

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print("BUY order opened : ",OrderOpenPrice());

}

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

op="standby";

}

if (op=="sell")

{

ticket=OrderSend(Symbol(),OP_SELL,1,Bid,1,Bid+10*Point,Bid-250*Point,"My order #1",00002,0,Green);

lastprice=Bid;

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print("SELL order opened : ",OrderOpenPrice());

}

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

op="standby";

}

Print("Hello");

return(0);

}

The problem is :

if I enter sell, buy or nothing in the input parameter, my orders are not executed.

Nothing is printed, it even not print "Hello" !

Can you tell me what the problem is?

thanks.

 
FerruFx:
Is there a function in mql to move the order ???

Will test it asap next week

FerruFx

My fault , I ment ObjectMove

 
Beno:
I have found this in the money management tread what need to be done to it to make it work in real time.

Any help would be great.

Cheers

Beno

Very weird code. What do you expect?

What is mWinRate?

Why MathRound(CountWins/OrdersHistoryTotal())*10 ?

 
fracte:
hello !

I am learing how to make an EA,

but it does not work...

can you help me?

Could you see smile face in your chart? I mean Is your EA allowed?

 

MultiPositionExpert

luxinterior:
The attached EA has the functionality you're looking for. You should be able to figure it out from that and implement it in your own EA's

Good luck

Lux

Hi ,

I wonder how can I edit multipositionexpert when my profit reachs 100, to close all my orders.

Thanks in advance,

 

Just loop through all your open orders, calculate the profit then when it reaches or exceeds your target close them.

I'm assuming you know something about programming of course. If not take a look at the code in a few EA's and see if you can follow what's going on. Also take a look at the help file in Meta Editor. Look at the OrderProfit( ) function.

Good luck

Lux

 

Need Help coding short entry

I am looking for help coding this entry criteria for short entry. These are the conditions:

If High >= Highest High (20 bars) And RSI (Close , 8 , False) < Highest (RSI (Close , 8 , False) , 20 bars) And StochK (8 , 5) < 90 And StochK (8 , 5) 60 And StochD (8 , 5 , 3) > 87

then sell next bar at market

I am new to building expert Advisors. I am working with TradeSense. Can you have multiple entry conditions and multiple exit strategies in the same trade system?

Thanks for your help.

 
Beno:
I have found this in the money management tread what need to be done to it to make it work in real time.

Any help would be great.

Cheers

Beno

double WinRate()

{

double Ticket;

double CountWins = 0;

for(Ticket=0;Ticket<OrdersTotal();Ticket++)

{

OrderSelect(Ticket,SELECT_BY_TICKET,MODE_HISTORY);

if(MyAccount==AccountNumber() && OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)

{

//------>>>>

if(OrderType()==OP_BUY)

{

if(OrderClosePrice() >= OrderOpenPrice())

CountWins++;

}

else if(OrderType()==OP_SELL)

{

if(OrderClosePrice() <= OrderOpenPrice())

CountWins++;

}

}

}

if(CountWins > 0)

return(MathRound(CountWins/OrdersHistoryTotal())*10);

else

Print("Real Time WinRate not Available");

return(mWinRate);

}

hmmm seem interesting Beno, do u already try it out...?

regards,

MANSTIR

Files:
kelly2.mq4  6 kb
 

i need help to code a custom indicator into an ea

hi i am new, but i am not knew to fx trading,but i hav an indicator that is doing wonders,but i want to code it into an ea,i need help

 
tural:
Hi ,

I wonder how can I edit multipositionexpert when my profit reachs 100, to close all my orders.

Thanks in advance,

extern bool MaxProfit = True;

extern int MaxProfitPoint = 100;

int start() {

int i,type,err;

double price;

bool result;

//--

if (MaxProfit == TRUE){

if (Day()|| AccountProfit() >= MaxProfitPoint) {

for(i=OrdersTotal()-1;i>=0;i--)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

{

type=OrderType();

if(type==OP_BUY || type==OP_SELL)

{

while(true)

{

if(type==OP_BUY) price=MarketInfo(OrderSymbol(),MODE_BID);

else price=MarketInfo(OrderSymbol(),MODE_ASK);

result=OrderClose(OrderTicket(),OrderLots(),price,Slippage,CLR_NONE);

if(result!=true) {err=GetLastError(); Print("LastError = ",err);}

else err=0;

if(err==135) RefreshRates();

else break;

} } }

else Print( "When selecting a trade, error ",GetLastError()," occurred");

}

}

return(0);

}

this is for close all if reach your desire profit..make a wish...

regards,

MANSTIR

Reason: