naruhiko
Fun Poster
- Messages
- 752
- Joined
- Jul 16, 2009
- Messages
- 752
- Reaction score
- 16
- Points
- 15
salam sape sini ada script tuk set TP kt order buy or sell? untuk yg banyak order..tq
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.
salam sape sini ada script tuk set TP kt order buy or sell? untuk yg banyak order..tq
//+------------------------------------------------------------------+
//| Combinescript.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
// allow script to accept inputs from user
#property show_inputs
//user input
extern double Lots = 0.02;
extern int SL = 30;
extern int TP = 50;
extern bool USD_buy = false;
extern bool USD_sell = false;
extern bool YEN_buy = false;
extern bool YEN_sell = false;
int Slippage = 3;
// globals
string mySymbol, postfix, TradeComment;
double ask, bid, point, SLBuy, SLSell, TPBuy, TPSell;
int MagicNumber=12345678;
// used for verbose error logging
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int init()
{
postfix=StringSubstr(Symbol(),6,1);
if (USD_buy==true)
{
TradeComment="BUY USD";
mySymbol="GBPUSD"+postfix; OpenPos("Sell");
mySymbol="AUDUSD"+postfix; OpenPos("Sell");
mySymbol="EURUSD"+postfix; OpenPos("Sell");
}
if (USD_sell==true)
{
TradeComment="SELL USD";
mySymbol="GBPUSD"+postfix; OpenPos("Buy");
mySymbol="AUDUSD"+postfix; OpenPos("Buy");
mySymbol="EURUSD"+postfix; OpenPos("Buy");
}
if (YEN_buy==true)
{
TradeComment="BUY YEN";
mySymbol="GBPJPY"+postfix; OpenPos("Sell");
mySymbol="USDJPY"+postfix; OpenPos("Sell");
mySymbol="EURJPY"+postfix; OpenPos("Sell");
}
if (YEN_sell==true)
{
TradeComment="SELL YEN";
mySymbol="GBPJPY"+postfix; OpenPos("Buy");
mySymbol="USDJPY"+postfix; OpenPos("Buy");
mySymbol="EURJPY"+postfix; OpenPos("Buy");
}
}
int start() {}
//ENTRY LONG (buy, Ask)
void OpenPos(string Trade)
{
int gle=0;
int ticket=0;
int loopcount;
bid=MarketInfo(mySymbol,MODE_BID);
ask=MarketInfo(mySymbol,MODE_ASK);
point=MarketInfo(mySymbol,MODE_POINT);
loopcount=0;
if (Daily_AVG (mySymbol)>(iHigh(mySymbol,1440,0)-iLow(mySymbol,1440,0))/point)
{
while(true)
{
if (SL>0) { SLBuy=bid-(SL*point); SLSell=ask+(SL*point); }
if (TP>0) { TPBuy=bid+(TP*point); TPSell=ask-(TP*point); }
if (Trade=="Buy") ticket=OrderSend(mySymbol,OP_BUY,Lots,ask,Slippage ,SLBuy,TPBuy,TradeComment,MagicNumber,White);
if (Trade=="Sell") ticket=OrderSend(mySymbol,OP_SELL,Lots,bid,Slippage,SLSell,TPSell,TradeComment,MagicNumber,Red);
gle=GetLastError();
if(gle==0)
{
if (Trade=="Buy") Print("BUY PLACED Ticket="+ticket+" Ask="+ask+" Lots="+Lots);
if (Trade=="Sell") Print("SELL PLACED Ticket="+ticket+" Bid="+bid+" Lots="+Lots);
break;
}
else
{
if (Trade=="Buy") Print("-----ERROR----- Placing BUY order: Lots="+Lots+" SL="+SL+" TP="+TP+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
if (Trade=="Sell") Print("-----ERROR----- placing SELL order: Lots="+Lots+" SL="+SL+" TP="+TP+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
RefreshRates();
Sleep(500);
// give up after 10 tries (~5 seconds)
loopcount++;
if(loopcount>10)
{
if (Trade=="Buy") Print("-----ERROR----- Giving up on placing BUY order");
if (Trade=="Sell") Print("-----ERROR----- Giving up on placing SELL order");
return(gle);
}
}
}
}
}
//+------------------------------------------------------------------+
int Daily_AVG (string symbolAvg)
{
int R1=0,R5=0,R10=0,R20=0,RAvg=0,i=0;
R1 = (iHigh(symbolAvg,PERIOD_D1,1)-iLow(symbolAvg,PERIOD_D1,1))/MarketInfo(symbolAvg,MODE_POINT);
for(i=1;i<=5;i++) R5=R5+(iHigh(symbolAvg,PERIOD_D1,i)-iLow(symbolAvg,PERIOD_D1,i))/MarketInfo(symbolAvg,MODE_POINT);
for(i=1;i<=10;i++) R10=R10+(iHigh(symbolAvg,PERIOD_D1,i)-iLow(symbolAvg,PERIOD_D1,i))/MarketInfo(symbolAvg,MODE_POINT);
for(i=1;i<=20;i++) R20=R20+(iHigh(symbolAvg,PERIOD_D1,i)-iLow(symbolAvg,PERIOD_D1,i))/MarketInfo(symbolAvg,MODE_POINT);
R5 = R5/5;
R10 = R10/10;
R20 = R20/20;
RAvg = (R1+R5+R10+R20)/4;
return (RAvg);
}


salam nak tanye sape ader scrips pending order yang leh bukak order banyak2..contoh lot 0.1, 0.2, 0.4 n seterusnya..siap ngan tp n sl..