BTC USD 105,975 Gold USD 3,355.86
Time now: Jun 1, 12:00 AM

Belajar Coding EA (mql) asas

Sponsored Post

==================
contoh saja, Determine position lotsize based on order direction and market prices
Code:
double CurrentEquityAtRisk=(MaxPercentEquityAtRisk/100.)*AccountBalance();
double CurrentLotSize=LotSize(CurrentEquityAtRisk,OpenPrice_ND,StopLossPrice_ND,CurrentOrderType); // Compute the max possible lotsize for the risk equity
Print("Max allowed EquityAtRisk = $",DoubleToStr(CurrentEquityAtRisk,2)," and Max computed Lotsize = ",CurrentLotSize);
CurrentLotSize=NormalizeLotSize(CurrentLotSize);   // Tuk normal lot, Normalize the lotsize to conform with the Broker's specific quantized position allowances
if(CurrentLotSize<MarketInfo(CurrentSymbol,MODE_MINLOT)) CurrentLotSize=MarketInfo(CurrentSymbol,MODE_MINLOT);
if(CurrentLotSize>MarketInfo(CurrentSymbol,MODE_MAXLOT)) CurrentLotSize=MarketInfo(CurrentSymbol,MODE_MAXLOT);
==================
ada lagi contoh
PHP ny

Code:
double CalcLots(double Risk)
{
   double tmpLot = 0, MinLot = 0, MaxLot = 0;
   MinLot = MarketInfo(Symbol(),MODE_MINLOT);
   MaxLot = MarketInfo(Symbol(),MODE_MAXLOT);
   tmpLot = NormalizeDouble(AccountBalance()*Risk/1000,2);
      
   if(tmpLot < MinLot)
   {
      Print("LotSize is Smaller than the broker allow minimum Lot!");
      return(MinLot);
   ** 
   if(tmpLot > MaxLot)
   {
      Print ("LotSize is Greater than the broker allow minimum Lot!");
      return(MaxLot);
   **
==================
ada lagi contoh variant lain

Code:
double CalcLotSize(int iSL,double dRisk,double dBalance) {      
  double dRiskCapital=dRisk/100*dBalance;
  return( dRiskCapital/(iSL*MarketInfo(Symbol(),MODE_TICKVALUE)*POINT));

**
 
==================
contoh saja, Determine position lotsize based on order direction and market prices
Code:
double CurrentEquityAtRisk=(MaxPercentEquityAtRisk/100.)*AccountBalance();
double CurrentLotSize=LotSize(CurrentEquityAtRisk,OpenPrice_ND,StopLossPrice_ND,CurrentOrderType); // Compute the max possible lotsize for the risk equity
Print("Max allowed EquityAtRisk = $",DoubleToStr(CurrentEquityAtRisk,2)," and Max computed Lotsize = ",CurrentLotSize);
CurrentLotSize=NormalizeLotSize(CurrentLotSize);   // Tuk normal lot, Normalize the lotsize to conform with the Broker's specific quantized position allowances
if(CurrentLotSize<MarketInfo(CurrentSymbol,MODE_MINLOT)) CurrentLotSize=MarketInfo(CurrentSymbol,MODE_MINLOT);
if(CurrentLotSize>MarketInfo(CurrentSymbol,MODE_MAXLOT)) CurrentLotSize=MarketInfo(CurrentSymbol,MODE_MAXLOT);
==================
ada lagi contoh
PHP ny

Code:
double CalcLots(double Risk)
{
   double tmpLot = 0, MinLot = 0, MaxLot = 0;
   MinLot = MarketInfo(Symbol(),MODE_MINLOT);
   MaxLot = MarketInfo(Symbol(),MODE_MAXLOT);
   tmpLot = NormalizeDouble(AccountBalance()*Risk/1000,2);
      
   if(tmpLot < MinLot)
   {
      Print("LotSize is Smaller than the broker allow minimum Lot!");
      return(MinLot);
   ** 
   if(tmpLot > MaxLot)
   {
      Print ("LotSize is Greater than the broker allow minimum Lot!");
      return(MaxLot);
   **
==================
ada lagi contoh variant lain

Code:
double CalcLotSize(int iSL,double dRisk,double dBalance) {      
  double dRiskCapital=dRisk/100*dBalance;
  return( dRiskCapital/(iSL*MarketInfo(Symbol(),MODE_TICKVALUE)*POINT));

**

ada lagi sample sudah susun,contoh ini tidak faham,sorry!:(:)((
 
susun letak tak jauh beda macam source lainnya
terpenting, pada letaknya ini ada yang mereka letak pada awal mula "int start" , ada pula selepas dibawah "void OnTick()", contoh
==========
ni saya buat selepas onTick
Code:
//+------------------------------------------------------------------+  
//Get Lot Size
double GetLots()

  {
   double lotfactor;
   double ilots;

   double lotstep=MarketInfo(Symbol(),MODE_LOTSTEP);
   double lotstep1= MathLog(lotstep)/MathLog(0.1);
   double minlots = MathMax(MinLots, MarketInfo(Symbol(), MODE_MINLOT));
   double maxlots = MathMin(MaxLots, MarketInfo(Symbol(), MODE_MAXLOT));
   double risk=Speed_HFT/100.0;

   lotfactor=AccountEquity()*100*risk;

   ilots=NormalizeDouble(lotfactor/MarketInfo(Symbol(),MODE_LOTSIZE),(int)lotstep1);
   ilots=MathMin(maxlots,ilots);
   ilots=MathMax(minlots,ilots);
   ilots=NormalizeDouble(ilots,2);

   if(Samurai_NinjaForex==FALSE) ilots=Lots;

   return(ilots);

  **

//+------------------------------------------------------------------+

lanjut source lainnya dari anda
xx
xx
xxx
x
xx
 
Salam, camna nak tukar line code ni ke moving average ya ?? Penat dah 2 malam pikior camna nk tukar, Nak letak 2 EMA, slow dgn fast.. Cross bawah untuk buy, cross atas untuk sell.. Harap dpt membantu



extern string SignalSetting = "---------- Signal Setting ----------";

extern ENUM_APPLIED_PRICE ApplyTo = PRICE_CLOSE;
extern string Setting_ = "----------- Stochastic -----------";
extern int Kperiod = 25;
extern int Dperiod = 3;
extern int Slowing = 5;
extern ENUM_MA_METHOD MA_Stoc = MODE_SMA;
extern ENUM_STO_PRICE Price_Field = STO_CLOSECLOSE;
extern string Stoc_Level = "--- Stoch Level ---";
extern int Upper_level = 80;
extern int Lower_level = 20;

void SetupTrade()
{

double StocFast = iStochastic(Symbol(), Period(), Kperiod, Dperiod, Slowing, MA_Stoc, Price_Field, 0, 1);
double StocSlow = iStochastic(Symbol(), Period(), Kperiod, Dperiod, Slowing, MA_Stoc, Price_Field, 1, 1);

bool buy = StocFast < Lower_level && StocSlow < Lower_level;
bool sell = StocFast > Upper_level && StocSlow > Upper_level;


datetime candleTime = iTime(Symbol(),Period(),0); static datetime timeTrade;
bool trade = Hour() >= StartHour && Hour() <= EndHour;
bool trade2 = true;
int candlebaru = iClose(Symbol(),Period(),0);
{
if(trade && trade2 && candleTime)
{
if(buy && TradeBuy && TotalOrder(OP_BUY)==0)
{
Order(OP_BUY,Commentt);
trail_mode = 0;
timeTrade = candleTime;
}
if(sell && TradeSell && TotalOrder(OP_SELL)==0)
{
Order(OP_SELL,Commentt);
trail_mode = 0;
timeTrade = candleTime;
}

}
}
}
 
Sponsored Post

Live Forex Chart

Currency
Rates
EUR / USD
1.15269
USD / JPY
145.436
GBP / USD
1.34958
USD / CHF
0.81686
USD / CAD
1.37031
EUR / JPY
167.534
AUD / USD
0.64886

CG Sponsors


--->

Back
Top
Log in Register