unknown
Fun Poster
- Messages
- 293
- Joined
- Mar 12, 2007
- Messages
- 293
- Reaction score
- 0
- Points
- 10
tq.. sy cuma penin logik dia tu je.. ada mql help sy bukukan.. sampai 400 muka surat print.. tapi tak paham.. english 
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
jumlah semua pos guna OrdersTotal(). tapi dia akan beri jumlah semua pos termasuk lain2 pair dan pending order
kalau nak kira current chart aje kena iterate guna for dan filter yang mana tak nak
contoh ea boleh jadi macam ni
Code:int start () { [COLOR="Gray"]// kira total pos untuk current chart[/COLOR] int totalPos = 0; [COLOR="gray"]// declare variable untuk total pos[/COLOR] for (int i=0; i<OrdersTotal(); i++) [COLOR="gray"]// loop 1 per 1 [/COLOR] { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); [COLOR="Gray"]// select pos ikut turutan ticket #[/COLOR] if (OrderSymbol()!=Symbol) continue; [COLOR="Gray"]// sekiranya pair bukan current chart.... skip[/COLOR] if (OrderType()!=OP_BUY || OrderType()!=OP_SELL) continue; [COLOR="gray"]// kalau bukan BUY atau SELL.... skip[/COLOR] totalPos++; [COLOR="gray"]// totalPos tambah 1[/COLOR] } if (totalPos==0) [COLOR="gray"]// sekiranya totalpos = 0 [/COLOR] { for (int i=0; i<10; i++) [COLOR="Gray"]// repeat 10 kali[/COLOR][COLOR="Lime"] <--- camne komand ni aktif? padahal bro hanya tulis ordersend skali??[/COLOR] { OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+10*Point,"My order buy",0,0,Green); [COLOR="gray"]// buy 1 lot tp 10[/COLOR] Sleep (1000); [COLOR="gray"]// delay 1 saat[/COLOR] OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-10*Point,"My order sell",0,0,Red); [COLOR="gray"]// sell 1 lot tp 10[/COLOR] Sleep (1000); [COLOR="gray"]// delay 1 saat[/COLOR] } } return (0); }
Untuk open pos, guna function OrderSend. OrderSend boleh diguna banyak cara, boleh jugak untuk PO. Sila refer ke help library dalam metaeditor untuk syntax OrderSend
Kalau nak set variable, contoh nilai lot dan tp jadi variable
Code:extern double [COLOR="Red"]lot [/COLOR]= 1.0; extern int [COLOR="red"]takeProfit [/COLOR]= 10.0;
lepas tu dalam OrderSend jadi
Code:[COLOR="Red"]double tpBuy=0; double tpSell=0; if (takeprofit>0) { tpBuy = Ask+takeProfit*Point; tpSell = Bid-takeProfit*Point; }[/COLOR] OrderSend(Symbol(),OP_BUY,[COLOR="Red"]lot[/COLOR],Ask,3,0,[COLOR="Red"]tpBuy[/COLOR],"My order buy",0,0,Green); OrderSend(Symbol(),OP_SELL,[COLOR="Red"]lot[/COLOR],Bid,3,0,[COLOR="Red"]tpSell[/COLOR],"My order sell",0,0,Red);

for ([COLOR="SeaGreen"]int i=0[/COLOR]; [COLOR="Purple"]i<10;[/COLOR] [COLOR="Blue"]i++[/COLOR])
{
[COLOR="Gray"]// code anda akan diulang 10 kali[/COLOR]
}
for (int i=0; i<[COLOR="Red"]5[/COLOR]; i++)
{
[COLOR="Gray"]// code anda akan diulang 5 kali[/COLOR]
}
for (int i=10; i>0; i--)
{
[COLOR="gray"]// code anda akan diulang 10 kali[/COLOR]
}

untuk EA 5 dicimel mcm maner pulak

extern bool buy = true;
extern bool sell = true;
int start ()
{
int totalBuy = 0; [COLOR="Gray"][COLOR="gray"]// buy counter bermula 0[/COLOR][/COLOR]
int totalSell = 0; [COLOR="gray"][COLOR="gray"]// sell counter bermula 0[/COLOR][/COLOR]
for (int i=0; i<OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()!=Symbol) continue;[COLOR="gray"] // bukan current pair... skip[/COLOR]
if (OrderType()==OP_BUY) totalBuy++; [COLOR="gray"]// sekiranya buy, buy counter tambah 1[/COLOR]
if (OrderType()==OP_SELL) totalSell++;[COLOR="gray"] // sekiranya sell, sell counter tambah 1[/COLOR]
}
if (totalBuy ==0 && buy==true) [COLOR="gray"]// sekiranya buy 0 dan buy variable true[/COLOR]
{
for (int i=0; i<10; i++) [COLOR="gray"]// 10 kali buy[/COLOR]
{
OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+10*Point,"My order buy",0,0,Green); [COLOR="gray"]// buy 1 lot tp 10[/COLOR]
Sleep (1000);
}
}
if (totalSell==0 && sell==true) [COLOR="gray"]// sekiranya sell dan sell variable true[/COLOR]
{
for (int i=0; i<10; i++)[COLOR="gray"] // 10 kali sell[/COLOR]
{
OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-10*Point,"My order sell",0,0,Red); [COLOR="gray"]// sell 1 lot tp 10[/COLOR]
Sleep (1000);
}
}
return (0);
}
