mankj
Active Member
- Messages
- 1,346
- Joined
- Jul 10, 2009
- Messages
- 1,346
- Reaction score
- 32
- Points
- 30
TT kasi jelah EA tu...aku compile ada error~X(...ceq bukan reti sgt neh
senang jer bro....rapatkan ayat2 yg renggang jer...
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.
TT kasi jelah EA tu...aku compile ada error~X(...ceq bukan reti sgt neh
senang jer bro....rapatkan ayat2 yg renggang jer...paid
mcm mn nk jd kan mq4 ni. den lagi x reti...
senang jer bro....rapatkan ayat2 yg renggang jer...paid
sama aa aku pun, cmane TT nak jdkan mq4 ni
Copy&Paste sume2 kat bawah nih sebagai fail *.mq4... Sukati korang la nak letak nama apa kat tanda '*' tuh...
//------------------
#property copyright ""
#property link ""
#include <stdlib.mqh>
extern double InitialLot=0.1;
extern int TP=15;
extern int SL=15;
extern bool UseMultiplyLot=true;
extern int LotMultiplier=2;
extern bool UseDailyTarget=true;
extern double DailyTarget=30; //usd
extern int MinuteAssignHiLo=15;
extern int MinuteStart=15;
extern int MinuteFinish=54;
extern int PipDifferentLow=1;
extern int PipDifferentHigh=2;
extern bool UseTimeRange=true;
extern int HoursStartTrade=00;
extern int MinuteStartTrade=00;
extern int HoursFinishTrade=23;
extern int MinuteFinishTrade=59;
extern int MinuteResetHiLo=55;
extern bool UseBasketProfit=false;
extern double BasketProfit=10;
extern double BasketLoss=15;
double high15=0;
double low15=0;
int HourDone[24];
string mySymbol;
double tempTimeStartTrade, tempTimeFinishTrade, tempCurrentTime;
double Slippage=2;
string TradeComment="TF15 HiLo Scalping";
int MagicNumber=12345678;
double ask, bid, point, tempLot, TargetAccountBalance;
// user input
int init()
{
if (UseTimeRange==true)
{
tempTimeStartTrade=(HoursStartTrade*100)+MinuteStartTrade;
tempTimeFinishTrade=(HoursFinishTrade*100)+MinuteFinishTrade;
}
if (UseDailyTarget==true)
{ TargetAccountBalance=AccountBalance()+DailyTarget;}
tempLot=InitialLot;
for (int cv=0; cv<24; cv++) HourDone[cv]=false; //initiate
mySymbol=Symbol();
Print("Init happened ",Hour()+":"+Minute());
Comment("EA Scalping");
}
//+----------------+
//| Custom DE-init |
//+----------------+
// Called ONCE when EA is removed from chart
int deinit()
{
Print("DE-Init happened ",Hour()+":"+Minute());
Comment("");
}
int start()
{
if (UseTimeRange==true && TradeTime()==false) return;
if ( (UseBasketProfit==true) && OrdersTotal()>0 ) FunctionBasketProfit();
if (Hour()==0 && Minute()==0)
{
init();
}
if (UseDailyTarget==true)
{
if (AccountBalance()>=TargetAccountBalance) { Comment("Daily target achieved!"); return;}
}
if (HourDone[Hour()]==true || OrdersTotal()>0 ) return;
//assign high and low
if (Minute()==MinuteAssignHiLo)
{
high15=iHigh(mySymbol,15,1);
low15=iLow(mySymbol,15,1);
}
if (Minute()==MinuteResetHiLo) { high15=0; low15=0;}
Comment("Hour:"+Hour()+", High 0-15 = "+DoubleToStr(high15,4)+", Low 0-15="+DoubleToStr(low15,4));
if (Minute()>=MinuteStart && Minute()<=MinuteFinish &&
HourDone[Hour()]==false)
{
if (Bid>=high15+(PipDifferentLow*point) && Bid<=high15+(PipDifferentHigh*point))
{
if (UseMultiplyLot==true) {CheckHitTP_SL();}
OpenPos("Buy", InitialLot);
HourDone[Hour()]=true;
high15=0; low15=0; //reset hilo
Comment("Open position for Hour ="+Hour()+" is done.");
InitialLot=tempLot;
}
if (Ask<=low15-(PipDifferentLow*point) && Ask>=low15-(PipDifferentHigh*point))
{
if (UseMultiplyLot==true) {CheckHitTP_SL();}
OpenPos("Sell", InitialLot);
HourDone[Hour()]=true;
high15=0; low15=0;//reset hilo
Comment("Open position for Hour ="+Hour()+" is done.");
InitialLot=tempLot;
}
}
return;
} // start()
//check last closed position for multiply lots
void CheckHitTP_SL()
{
if (OrdersHistoryTotal()==0) return;
OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);
if (OrderProfit()>0) {InitialLot=tempLot;}
if (OrderProfit()<0) {InitialLot=OrderLots()*LotMultiplier;}
return;
}
void OpenPos(string Trade, double Lots)
{
int gle=0;
int ticket=0;
int loopcount;
loopcount=0;
bid=MarketInfo(mySymbol,MODE_BID);
ask=MarketInfo(mySymbol,MODE_ASK);
point=MarketInfo(mySymbol,MODE_POINT);
double TPBuy=0;
double SLBuy=0;
double TPSell=0;
double SLSell=0;
if(TP>0){TPBuy=ask+TP*point;TPSell=bid-TP*point;}
if(SL>0){SLBuy=ask-SL*point;SLSell=bid+SL*point;}
while(true)
{
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+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
if (Trade=="Sell") Print("-----ERROR----- placing SELL order: Lots="+Lots+" SL="+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
//RefreshRates();
// give up after 10 tries (~5 seconds)
loopcount++;
if(loopcount>1)
{
if (Trade=="Buy") Print("-----ERROR----- Giving up on placing BUY order");
if (Trade=="Sell") Print("-----ERROR----- Giving up on placing SELL order");
return(gle);
}
}
}
}//void OpenPos
bool TradeTime()
{
tempCurrentTime=(Hour()*100)+Minute();
if(tempTimeStartTrade<tempTimeFinishTrade)
{
if (tempCurrentTime>=tempTimeStartTrade && tempCurrentTime<=tempTimeFinishTrade)
return(true);
}
else if(tempTimeStartTrade>tempTimeFinishTrade)
{
if (tempCurrentTime>=tempTimeStartTrade || tempCurrentTime<=tempTimeFinishTrade)
return(true);
}
return(false);
}
int FunctionBasketProfit()
{
int cnt;
double myAsk;
double myBid;
double currBasket=0;
//Basket profit or loss
currBasket=AccountEquity()-AccountBalance();
//Comment("Profit/Loss = ",currBasket);
if(currBasket>=BasketProfit || currBasket<=(BasketLoss*(-1)) )
{
// CLOSE order if profit target made
while (OrdersTotal()>0) //enforce close all trade
{
for(cnt=OrdersTotal(); cnt>=0; cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if( OrderType()==OP_BUY || OrderType()==OP_SELL )
{
mySymbol=OrderSymbol();
if(OrderType()==OP_BUY)
{
myBid=MarketInfo(mySymbol,MODE_BID);
OrderClose(OrderTicket(),OrderLots(),myBid,Slippage,White);
} // if BUY
if(OrderType()==OP_SELL)
{
myAsk=MarketInfo(mySymbol,MODE_ASK);
OrderClose(OrderTicket(),OrderLots(),myAsk,Slippage,Red);
} //if SELL
} // if(OrderSymbol)
} // for
}//while Ordertotal()>0
} //currBasket
} //
//-----------
yg kaler merah bro...tak pun cuba copy yg ni pulak.gua dah rapatkan mana yg patut.