BTC USD 63,768.5 Gold USD 4,478.28
Time now: Jun 1, 12:00 AM

Forex King Scalper (EA)

Susah2 sangat... folo cenggini jek...

1.bukak je mana2 fail ea lain kat metaeditor, pastu tekan CTRL+A... dia akan select sume kandungan dalam ea lain tuh...
2. tekan DEL... dia akan delete code ea lain tuh...
3. copy semua kat post no 2 tuh... yang kat dalam tanda "//-----"
4. paste kat dlm fail ea lain yg dah delete tuh...
5. jangan tekan save, tapi tekan save as... letak la nama fail baru... EA lain tu akan selamat, nama ea baru akan muncul...
4. lepas tu baru la tekan Compile... kalo takde pape error kuar, dah ok la tuh...

selamat berjaya... :D
 
Last edited:
Copy&Paste sume2 kat bawah nih sebagai fail *.mq4... Sukati korang la nak letak nama apa kat tanda '*' tuh... :D

//------------------
#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...:D tak pun cuba copy yg ni pulak.gua dah rapatkan mana yg patut.
 
Last edited:
Dah compile... Tunggu start engine pula esok... huhu... Yg ada error tu korang double klik kat error tu dan rapatkan... pastu compile je... :D Error tu mesti bro anTu7869 nak bagi korang belajar sikit pasal coding... :))
 
Last edited:

Latest Posts

Live Forex Chart

Currency
Rates
EUR / USD
1.16150
USD / JPY
160.027
GBP / USD
1.34250
USD / CHF
0.78925
USD / CAD
1.38991
EUR / JPY
185.870
AUD / USD
0.71363
Back
Top
Log in Register