How to code? - page 228

 

MQL4 String Formatting

Never mind. It was the font I was using. Its working fine.

 

function to count loss trades in trading session

Can one of you skilled programmers clue me in on a good way to keep a running total of the loosing trades over a trading session?

I would like my EA to count the loosing trades from my trade history based on magic number and date. I can then have the EA stop trading for the remainder of the session when some number of loosing trades is reached.

Basically if someone can show me a code snippet that would return a aggregate count of the loosing trades based on magic number and date I would be elated.

Thanks

Will

 

Define

int session_start;[/PHP]

on init put this

init()

{

session_start= TimeCurrent();

}

Function Losses:

[PHP]int Losses(){

int total=0;

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

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic &&

OrderProfit()+OrderSwap()+OrderCommission()<0 &&

OrderCloseTime()>=session_start)

total++;

}

return (total);

}
 

using MA value in pending order

Hi everyone

here is the question

i want to use MA value in pending order

that means something like this

i am getting error uninit reason 0

dont know if it connected with putting MA inside

int start()

{

int ticket;

double point;

//----

point=MarketInfo(Symbol(),MODE_POINT);

//----

while(true)

{

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,iMA(NULL,0,20,8,MODE_SMA,PRICE_CLOSE,0)*point,0,0,0,"some comment",16384,0,Green);

if(ticket<=0) Print("Error = ",GetLastError());

else { Print("ticket = ",ticket); break; }

//---- 10 seconds wait

Sleep(10000);

}

//----

return(0);

}

 

easy question market info

here is easy stuff

here is code

whats wrong ???

should i be getting 0.0000000 something value?

thats demo account fxcm i dont know if that makes a difference?

int start()

{

RefreshRates();

double i;

i=MarketInfo("AUDUSD",MODE_POINT);

Alert("Point= " ,i , " !");// Alert

return; // Exit start()

}
Files:
 
 

Hi!

Please, i need that my EA double the order lot if the last order closes by the StopLoss. Please, how i can programe this?

Regards..

 
 

got a separate request HERE

(will that be impossible to do , or just easy)

>>

https://www.mql5.com/en/forum/180082

click click

 
Reason: