jejantas
CG Top Poster Club

- Messages
- 24,708
Paid Membership
- Joined
- Sep 1, 2007
- Messages
- 24,708
- Reaction score
- 926
- Points
- 161
contoh sekiranya saya target 10% gain from balance
code saya lebih kurang macam ni
Code:
if (AccountEquity() >= AccountBalance() * 1.1)
{
//-- function close all di sini
}
target macam ne tu?guna 10% margin ke?
if (AccountEquity() >= AccountBalance() * 0.1)
nak mudah gunakan OrderProfit();
int Profit;
for (int ix2=0;ix2<=OrdersTotal(); ix2++){
if (OrderSelect(ix2, SELECT_BY_POS)==true) {
if(OrderSymbol()==Symbol()){
if(OrderType()==OP_BUY){
LastBuyPrice = OrderOpenPrice();
Profit+=(OrderProfit()+OrderSwap()+OrderCommission());
}
if(OrderType()==OP_SELL){
LastSellPrice = OrderOpenPrice();
Profit+=(OrderProfit()+OrderSwap()+OrderCommission());
}
}
}
}
if(Profit>=AccountBalance()*0.1){
for (int ix2a=OrdersTotal();ix2a>=0; ix2a--){
if (OrderSelect(ix2a, SELECT_BY_POS)==true) {
if (OrderSymbol()==Symbol()) {
if(OrderType()==OP_BUY){OrderClose(OrderTicket(),OrderLots(),Bid,5,Blue);}
if(OrderType()==OP_SELL){OrderClose(OrderTicket(),OrderLots(),Ask,5,Red);}
if (OrderType()==OP_BUYLIMIT){OrderDelete(OrderTicket(),CLR_NONE);}
if( OrderType()==OP_SELLLIMIT){OrderDelete(OrderTicket(),CLR_NONE);}
if( OrderType()==OP_BUYSTOP){OrderDelete(OrderTicket(),CLR_NONE);}
if( OrderType()==OP_SELLSTOP){OrderDelete(OrderTicket(),CLR_NONE);}
Comment("Force to Close All Posts......");
}
}
}
}
}
Harap Membantu
Last edited: