Belajar Coding EA (mql) asas

Recommended Brokers


Forex Chart

catcat0625

Freshie
Joined
Jul 2, 2019
Messages
4
Reaction score
1
Points
8
bro aiman,saya nak tanya
ada cara ea auto lots
contoh:saya 500 usd , start lots 0.01,kalau lebas 2 bulan jadi 1000 usd , lots EA sendiri ajust 0.02? ada cord ini?ada sample ajar? thank.


input double lotSize = AccountEquity();
 
Last edited:
Sponsored Post

ninjaforex

Freshie
Joined
Jun 20, 2019
Messages
31
Reaction score
2
Points
11
==================
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));
**
 

catcat0625

Freshie
Joined
Jul 2, 2019
Messages
4
Reaction score
1
Points
8
==================
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!:(:)((
 

ninjaforex

Freshie
Joined
Jun 20, 2019
Messages
31
Reaction score
2
Points
11
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
 
Sponsored Post
Top
Log in Register