//rüzgar//
Yeni Üye

Mesaj Sayısı: 31
|
 |
« Yanıtla #2 : Eylül 16, 2008, 20:59 » |
|
extern int kisa=5,orta=20,uzun=100; extern double stoploss=0,takeprofit=40,volume=50000;
double mystoploss=0,mytakeprofit=0; double myprice=0; double myvolume=0; int mycmd=0;
int init() { return(0); }
int deinit() { return(0); } int start() { static datetime change=0; int al_emir_sayisi=0; int sat_emir_sayisi=0; if(change==iTime(NULL,0,0)) return (0); change=iTime(NULL,0,0); double ort1,ort2,ort3,ort4; double eskiort1,eskiort2,eskiort3,eskiort4; // HideTestIndicators(false);
ort1=iMA(NULL,0,kisa,0,MODE_SMA,PRICE_TYPICAL,0); ort2=iMA(NULL,0,orta,0,MODE_SMA,PRICE_TYPICAL,0); ort3=iMA(NULL,0,uzun,0,MODE_SMA,PRICE_TYPICAL,0); eskiort1=iMA(NULL,0,kisa,0,MODE_SMA,PRICE_TYPICAL,1); eskiort2=iMA(NULL,0,orta,0,MODE_SMA,PRICE_TYPICAL,1); eskiort3=iMA(NULL,0,uzun,0,MODE_SMA,PRICE_TYPICAL,1); al_emir_sayisi=BuyOrderCount(); sat_emir_sayisi=SellOrderCount();
if(al_emir_sayisi<1) { if((ort3<ort2)&&(ort1>=ort2)&&(eskiort1<=eskiort2)) { AL(); } }
if(al_emir_sayisi<1) { if((ort3<ort2)&&(eskiort1<=eskiort3)&&(ort1>=ort3)) { AL(); } }
if(al_emir_sayisi<1) { if((ort3<ort1)&&(eskiort2<=eskiort3)&&(ort2>=ort3)) { AL(); } }
if(sat_emir_sayisi<1) { if((ort3>ort2)&&(ort1<=ort2)&&(eskiort1>=eskiort2)) { SAT(); } }
if(sat_emir_sayisi<1) { if((ort3>ort2)&&(eskiort1>=eskiort3)&&(ort1<=ort3)) { SAT(); } } if(sat_emir_sayisi<1) { if((ort3>ort1)&&(eskiort2>=eskiort3)&&(ort2<=ort3)) { SAT(); } } if(al_emir_sayisi>0) { if(ort1<ort2) CloseBuy(); }
if(sat_emir_sayisi>0) { if(ort1>ort2) CloseSell(); } return(0); } //-----------------------------------------------------------------------------
void CloseBuy() {
for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol()) {
if(OrderType()==OP_BUY){ if(OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue)) { } else { Print("Order Close buy returned the error of ",GetLastError()); } }//if opbuy } }
}
void CloseSell() {
for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol()) {
if(OrderType()==OP_SELL){ if(OrderClose(OrderTicket(),OrderLots(),Ask,3,Orange)) { } else { Print("Order Close buy returned the error of ",GetLastError()); } }//if opsell } }
}
int SellOrderCount() {
int opensellordercount=0; for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_SELL) opensellordercount++; } return(opensellordercount); }
int BuyOrderCount() {
int openbuyordercount=0; for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY) openbuyordercount++; } return(openbuyordercount); }
void AL() {
mycmd=OP_BUY; myprice=Ask; mytakeprofit=takeprofit*Point+Ask; myvolume=volume; if(mystoploss!=0)mystoploss=Bid-stoploss*Point; if( (OrderSend(Symbol(),mycmd,myvolume,myprice,3,mystoploss,mytakeprofit,"BUY order",1001,0,Green))>0) { } else { Alert("OrderSend BUY returned the error of ",GetLastError()); } return(0); }
int SAT() { mycmd=OP_SELL; myprice=Bid; mytakeprofit=Bid-takeprofit*Point; myvolume=volume; if(stoploss!=0)mystoploss=Ask+stoploss*Point;
// Print("takeprofit=",mytakeprofit," stoploss=",mystoploss); if(OrderSend(Symbol(),mycmd,myvolume,myprice,3,mystoploss,mytakeprofit,"Sell Order",1100,0,Red)>0) { } else { Alert("OrderSend SELL returned the error of ",GetLastError()); }
return(0); }
|