MQL4 Learning - page 20

 

When,

I press F1, I get HUGE font. How can I change it?

 

Okay,

if I wanted to know what is the code for closing a ceratin order, not all of them, how would I find it?

Go to MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader ? And type in "Closing a certain order"?

Thanks,

 

Hello again ^^

for a MM-algorithm i need the following, maybe someone has an idea:

standardlotsize = 1

when the last trade was a winner (positive profit) : newlotsitze = 0.5*standardlotsize

when the last trade was a looser (negative profit) : newlotsize = 2*standardlotsize

Is there any command to get the profitinformation of the last trade? With it would be simple to generate this algorithm.

Thanks readers

PS: Attachment was a mistake...

Files:
failure.jpg  53 kb
 

Lastorder profit

The only way of getting the last orders profit is by going through the complete orderhistory like the example below.

After the loop exit, Lastorderprofit will contain the value you need to make the Lotsize decision.

datetime LastTradeTime = 0;

double LastOrderProfit = 0;

for (int cnt=0; cnt<OrdersHistoryTotal(); cnt++) // Do an inventory on history trades status

{

if (OrderSelect(cnt, SELECT_BY_POS,MODE_HISTORY))

{

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

{

if (OrderOpenTime() > LastTradeTime)

{

LastTradeTime = OrderOpenTime();

LastOrderProfit = OrderProfit();

}

}

}

}

Good luck.

 

Hi,

MQL4 user just sent me a PM.

I see that there are too many questions around here. Why won't someone just make an EA for MQL4 user? I checked all his posts, and I think i got what he wants:

-StopLoss=10

-Limit=500

-Lots=AccountBalance/120(the result should be rounded, ie., 8.9 should be 8

-At 22:30:00, he wants a buystop set 10 pips above the current price, and a sellstop set 10 pips below the current price.

-If the market goes 1 PIP up, he wants the buystop and sellstop to go up 1 PIP too. Converesly, if the market goes 1 PIP down, he wants the buystop and sellstop to go 1 PIP down. He wants this to keep on modifying the pending orders like this until the Expert Advisor is diabled.

-He wants the Expert Advisor to be automatically disabled at 23:30:00, and automatically enabled at 17:00:00.

-Then, he wants to exit any pending orders/cancel any open positions at the open of the bar at 16:30:00. Not the time, but when the market recognizes the open of the bar of 16:30:00.

-He also wants the Expert Advisor to be spread calulated.

-He also wants to trade this forever. He wants everything that needs to be in the Expert Advisor to be traded forever, or for at least a very long time. Like Daylight savings time would be good, and more stuff.

I took the time to put this all together, and now it's time for someone else to just code this, and get it over with! He'll keep on asking questions like this on and on! He'll stop when he has his Expert Advisor. Also, he would like some explanations of each line of the code..like using this,

//Write explanations on each line of codes

Then, I gurantee, he'll stop asking questions.

 

OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*Point,3,A sk-StopLoss*Point+10*Point,Ask+

Why this buy stop pending order after making buy, closed after some seconds

I could not find syntax in the help menu

OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*Point,3,Ask-StopLoss*Point+10*Point,Ask+

Profit*Point+10*Point," EA",12345,0,Blue);

 
If the market goes 1 PIP up, he wants the buystop and sellstop to go up 1 PIP too. Converesly, if the market goes 1 PIP down, he wants the buystop and sellstop to go 1 PIP down

How the StopOrders will ever be triggered ? on a 10 pips gap ?

Seeing his posts and the PMs I also received, Mql4 is not able to write a simple EA nor even to understand several simple trading concepts.

But while his strategy seems simple nonsense, it should be better for him to first discuss here about his strategy with more experienced traders.

BTW, the 1 pip move does remind me the last Dan's grail... Should it be possible that Mql4 == Dan ?

@ Fandago :

MQL4 user just sent me a PM.

It's your first post ! How Mql4 did you send a PM before you write your first post ???

Mql4 == Dan == Fandago ???

Then, I gurantee, he'll stop asking questions.

Yeap, a classic Dan's promise ...

 

what? what r u takin 'bout?

who's dan?

i just came to this site, and your already think'n that i'm someone i'm not.

do u do this for every1 that is new to this sitee?

 

Michel,

You are not helping anyone.

Why won't You just stop complaining and just help???

This is what happens when people have nothing to do!!!

They just complain, and complain!!!

Why can't You just answer the simple questions, for a simple MQL4 coder beginner. I bet You were just as desperate as me when You were a beginner.

You know, it's very hard!

 

Pending Orders Adjustment

Hello, felow programmers,

I just start participation in the forum.

Years ago I learned C++ programming in the college.

The time passed and some things I forgot.

It is look like MQL language.

I have here a code that have a bug, I spent half a day.

This code is moving only BUY STOP order downwards only.

I need both BUY STOP and SELL STOP moving up and down in unison with

the bid line.

Also, when I run my program, sometimes only BUY STOP pops up, sometimes

only SELL STOP, and sometimes both. I guess this is because of slippage limit or too high market volatility.

Will somebody please help me.

Thanks a lot.

void AdjustingPendingOrders()

{

Print ("Adjusting the MT pending orders");

bool signal;

double price,MarketInformation;

int type,total, expiration;

total=OrdersTotal();

MarketInformation=MarketInfo(Symbol(),MODE_POINT);

for(int N=0; N<total; N++)

{

if(OrderSelect(N,SELECT_BY_POS,MODE_TRADES))

{

type=OrderType();

//---- working with pending orders only

if(type!=OP_BUY && type!=OP_SELL)

{

//---- modifying

price =OrderOpenPrice()-1*MarketInformation;

signal=OrderModify(OrderTicket(),price,Bid - Point * StopLoss,OrderTakeProfit(),0,CLR_NONE);

//price =OrderOpenPrice()+1*MarketInformation;

signal=OrderModify(OrderTicket(),price,Bid - Point * StopLoss,OrderTakeProfit(),0,CLR_NONE);

//Print ("Total is = ", total," MarketInformation = ",MarketInformation," type = ", type,

//" price = ", price, " signal = ", signal );///*" OrderSelect = ", OrderSelect()*/

//break;

}

}

}

}
Reason: