//+------------------------------------------------------------------+
//| Moving Average.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Moving Average sample expert advisor"
#define MAGICMA 20131111
//--- Inputs
input double Lots =0.1;
input double MaximumRisk =0.02;
input double DecreaseFactor=3;
input int MovingPeriod =12;
input int MovingShift =6;
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//---
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//--- return orders volume
if(buys>0) return(buys);
else return(-sells);
}
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//--- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//--- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("Error in history!");
break;
}
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
continue;
//---
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1)
lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
//--- return lot size
if(lot<0.1) lot=0.1;
return(lot);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma;
int res;
//--- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//--- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
//--- sell conditions
if(Open[1]>ma && Close[1]<ma)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
return;
}
//--- buy conditions
if(Open[1]<ma && Close[1]>ma)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);
return;
}
//---
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
double ma;
//--- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//--- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
//---
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//--- check order type
if(OrderType()==OP_BUY)
{
if(Open[1]>ma && Close[1]<ma)
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
if(OrderType()==OP_SELL)
{
if(Open[1]<ma && Close[1]>ma)
{
if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
}
//---
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--- check for history and trading
if(Bars<100 || IsTradeAllowed()==false)
return;
//--- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//---
}
//+------------------------------------------------------------------+
========
Selasa, 20 Mei 2014
2 Moving Average Cross
//+------------------------------------------------------------------+
//| 2 Moving Average Cross |
//| Copyright © 2009, EarnForex.com |
//| http://www.earnforex.com/ |
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int StopLoss = 35;
extern int TakeProfit = 70;
extern int TrailingStop = 20;
extern int Slippage = 3;
extern int Period_1 = 20;
extern int Period_2 = 40;
//0 - SMA, 1 - EMA, 2 - SMMA, 3 - LWMA
extern int MA_Method = 0;
//The minimum difference between MAs for Cross to count
extern int MinDiff = 5;
int Magic;
//Depend on broker's quotes
double Poin;
int Deviation;
int LastBars = 0;
//0 - undefined, 1 - bullish cross (fast MA above slow MA), -1 - bearish cross (fast MA below slow MA)
int PrevCross = 0;
int SlowMA;
int FastMA;
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
FastMA = MathMin(Period_1, Period_2);
SlowMA = MathMax(Period_1, Period_2);
Poin = Point;
Deviation = Slippage;
//Checking for unconvetional Point digits number
if ((Point == 0.00001) || (Point == 0.001))
{
Poin *= 10;
Deviation *= 10;
}
Magic = Period()+19472394;
return(0);
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
if (FastMA == SlowMA)
{
Print("MA periods should differ.");
return;
}
if (TrailingStop > 0) DoTrailing();
//Wait for the new Bar in a chart.
if (LastBars == Bars) return;
else LastBars = Bars;
if ((Bars < SlowMA) || (IsTradeAllowed() == false)) return;
CheckCross();
}
//+------------------------------------------------------------------+
//| Check for cross and open/close the positions respectively |
//+------------------------------------------------------------------+
void CheckCross()
{
double FMA_Current = iMA(NULL, 0, FastMA, 0, MA_Method, PRICE_CLOSE, 0);
double SMA_Current = iMA(NULL, 0, SlowMA, 0, MA_Method, PRICE_CLOSE, 0);
if (PrevCross == 0) //Was undefined
{
if ((FMA_Current - SMA_Current) >= MinDiff * Poin) PrevCross = 1; //Bullish state
else if ((SMA_Current - FMA_Current) >= MinDiff * Poin) PrevCross = -1; //Bearish state
return;
}
else if (PrevCross == 1) //Was bullish
{
if ((SMA_Current - FMA_Current) >= MinDiff * Poin) //Became bearish
{
ClosePrev();
fSell();
PrevCross = -1;
}
}
else if (PrevCross == -1) //Was bearish
{
if ((FMA_Current - SMA_Current) >= MinDiff * Poin) //Became bullish
{
ClosePrev();
fBuy();
PrevCross = 1;
}
}
}
//+------------------------------------------------------------------+
//| Close previous position |
//+------------------------------------------------------------------+
void ClosePrev()
{
int total = OrdersTotal();
for (int i = 0; i < total; i++)
{
if (OrderSelect(i, SELECT_BY_POS) == false) continue;
if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == Magic))
{
if (OrderType() == OP_BUY)
{
RefreshRates();
OrderClose(OrderTicket(), OrderLots(), Bid, Deviation);
}
else if (OrderType() == OP_SELL)
{
RefreshRates();
OrderClose(OrderTicket(), OrderLots(), Ask, Deviation);
}
}
}
}
//+------------------------------------------------------------------+
//| Sell |
//+------------------------------------------------------------------+
int fSell()
{
double SL, TP;
RefreshRates();
if (StopLoss > 0) SL = Bid + StopLoss * Poin;
else SL = 0;
if (TakeProfit > 0) TP = Bid - TakeProfit * Poin;
else TP = 0;
int result = OrderSend(Symbol(), OP_SELL, Lots, Bid, Deviation, SL, TP, "Adjustable MA", Magic);
if (result == -1)
{
int e = GetLastError();
Print(e);
}
else return(result);
}
//+------------------------------------------------------------------+
//| Buy |
//+------------------------------------------------------------------+
int fBuy()
{
double SL, TP;
RefreshRates();
if (StopLoss > 0) SL = Ask - StopLoss * Poin;
else SL = 0;
if (TakeProfit > 0) TP = Ask + TakeProfit * Poin;
else TP = 0;
int result = OrderSend(Symbol(), OP_BUY, Lots, Ask, Deviation, SL, TP, "Adjustable MA", Magic);
if (result == -1)
{
int e = GetLastError();
Print(e);
}
else return(result);
}
void DoTrailing()
{
int total = OrdersTotal();
for (int pos = 0; pos < total; pos++)
{
if (OrderSelect(pos, SELECT_BY_POS) == false) continue;
if ((OrderMagicNumber() == Magic) && (OrderSymbol() == Symbol()))
{
if (OrderType() == OP_BUY)
{
RefreshRates();
if (Bid - OrderOpenPrice() >= TrailingStop * Poin) //If profit is greater or equal to the desired Trailing Stop value
{
if (OrderStopLoss() < (Bid - TrailingStop * Poin)) //If the current stop-loss is below the desired trailing stop level
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * Poin, OrderTakeProfit(), 0);
}
}
else if (OrderType() == OP_SELL)
{
RefreshRates();
if (OrderOpenPrice() - Ask >= TrailingStop * Poin) //If profit is greater or equal to the desired Trailing Stop value
{
if (OrderStopLoss() > (Ask + TrailingStop * Poin)) //If the current stop-loss is below the desired trailing stop level
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailingStop * Poin, OrderTakeProfit(), 0);
}
}
}
}
}
//+------------------------------------------------------------------+
//| 2 Moving Average Cross |
//| Copyright © 2009, EarnForex.com |
//| http://www.earnforex.com/ |
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int StopLoss = 35;
extern int TakeProfit = 70;
extern int TrailingStop = 20;
extern int Slippage = 3;
extern int Period_1 = 20;
extern int Period_2 = 40;
//0 - SMA, 1 - EMA, 2 - SMMA, 3 - LWMA
extern int MA_Method = 0;
//The minimum difference between MAs for Cross to count
extern int MinDiff = 5;
int Magic;
//Depend on broker's quotes
double Poin;
int Deviation;
int LastBars = 0;
//0 - undefined, 1 - bullish cross (fast MA above slow MA), -1 - bearish cross (fast MA below slow MA)
int PrevCross = 0;
int SlowMA;
int FastMA;
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
FastMA = MathMin(Period_1, Period_2);
SlowMA = MathMax(Period_1, Period_2);
Poin = Point;
Deviation = Slippage;
//Checking for unconvetional Point digits number
if ((Point == 0.00001) || (Point == 0.001))
{
Poin *= 10;
Deviation *= 10;
}
Magic = Period()+19472394;
return(0);
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
if (FastMA == SlowMA)
{
Print("MA periods should differ.");
return;
}
if (TrailingStop > 0) DoTrailing();
//Wait for the new Bar in a chart.
if (LastBars == Bars) return;
else LastBars = Bars;
if ((Bars < SlowMA) || (IsTradeAllowed() == false)) return;
CheckCross();
}
//+------------------------------------------------------------------+
//| Check for cross and open/close the positions respectively |
//+------------------------------------------------------------------+
void CheckCross()
{
double FMA_Current = iMA(NULL, 0, FastMA, 0, MA_Method, PRICE_CLOSE, 0);
double SMA_Current = iMA(NULL, 0, SlowMA, 0, MA_Method, PRICE_CLOSE, 0);
if (PrevCross == 0) //Was undefined
{
if ((FMA_Current - SMA_Current) >= MinDiff * Poin) PrevCross = 1; //Bullish state
else if ((SMA_Current - FMA_Current) >= MinDiff * Poin) PrevCross = -1; //Bearish state
return;
}
else if (PrevCross == 1) //Was bullish
{
if ((SMA_Current - FMA_Current) >= MinDiff * Poin) //Became bearish
{
ClosePrev();
fSell();
PrevCross = -1;
}
}
else if (PrevCross == -1) //Was bearish
{
if ((FMA_Current - SMA_Current) >= MinDiff * Poin) //Became bullish
{
ClosePrev();
fBuy();
PrevCross = 1;
}
}
}
//+------------------------------------------------------------------+
//| Close previous position |
//+------------------------------------------------------------------+
void ClosePrev()
{
int total = OrdersTotal();
for (int i = 0; i < total; i++)
{
if (OrderSelect(i, SELECT_BY_POS) == false) continue;
if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == Magic))
{
if (OrderType() == OP_BUY)
{
RefreshRates();
OrderClose(OrderTicket(), OrderLots(), Bid, Deviation);
}
else if (OrderType() == OP_SELL)
{
RefreshRates();
OrderClose(OrderTicket(), OrderLots(), Ask, Deviation);
}
}
}
}
//+------------------------------------------------------------------+
//| Sell |
//+------------------------------------------------------------------+
int fSell()
{
double SL, TP;
RefreshRates();
if (StopLoss > 0) SL = Bid + StopLoss * Poin;
else SL = 0;
if (TakeProfit > 0) TP = Bid - TakeProfit * Poin;
else TP = 0;
int result = OrderSend(Symbol(), OP_SELL, Lots, Bid, Deviation, SL, TP, "Adjustable MA", Magic);
if (result == -1)
{
int e = GetLastError();
Print(e);
}
else return(result);
}
//+------------------------------------------------------------------+
//| Buy |
//+------------------------------------------------------------------+
int fBuy()
{
double SL, TP;
RefreshRates();
if (StopLoss > 0) SL = Ask - StopLoss * Poin;
else SL = 0;
if (TakeProfit > 0) TP = Ask + TakeProfit * Poin;
else TP = 0;
int result = OrderSend(Symbol(), OP_BUY, Lots, Ask, Deviation, SL, TP, "Adjustable MA", Magic);
if (result == -1)
{
int e = GetLastError();
Print(e);
}
else return(result);
}
void DoTrailing()
{
int total = OrdersTotal();
for (int pos = 0; pos < total; pos++)
{
if (OrderSelect(pos, SELECT_BY_POS) == false) continue;
if ((OrderMagicNumber() == Magic) && (OrderSymbol() == Symbol()))
{
if (OrderType() == OP_BUY)
{
RefreshRates();
if (Bid - OrderOpenPrice() >= TrailingStop * Poin) //If profit is greater or equal to the desired Trailing Stop value
{
if (OrderStopLoss() < (Bid - TrailingStop * Poin)) //If the current stop-loss is below the desired trailing stop level
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * Poin, OrderTakeProfit(), 0);
}
}
else if (OrderType() == OP_SELL)
{
RefreshRates();
if (OrderOpenPrice() - Ask >= TrailingStop * Poin) //If profit is greater or equal to the desired Trailing Stop value
{
if (OrderStopLoss() > (Ask + TrailingStop * Poin)) //If the current stop-loss is below the desired trailing stop level
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailingStop * Poin, OrderTakeProfit(), 0);
}
}
}
}
}
//+------------------------------------------------------------------+
HedgeLot_EA.mq4
//+------------------------------------------------------------------+
//| HedgeLot_EA.mq4 |
//| Copyright © 2009, metropolis |
//| metropolisfx@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, metropolis"
#property link "metropolisfx@yahoo.com"
extern int TP = 35;
extern int SL = 10;
extern double InstantLot = 0.1;
extern double PendingLot = 0.3;
#define Slippage 2
#define id1 12345
#define id2 67890
//global variables
static datetime lastB = -1;
static datetime lastS = -1;
static datetime lastClose = -1;
static double nextLot;
static double levelBuy;
static double levelSell;
static bool firstRun;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
Comment("\n", " Broker Time : ",TimeToStr(TimeCurrent()),"\n",
"\n", " Stop Level : ",MarketInfo(Symbol(),MODE_STOPLEVEL),
"\n", " Orders Total : ",OrdersTotal(),"\n",
"\n", " Copyright © 2009, metropolis - metropolisfx@yahoo.com");
if(!IsTradeAllowed())
{
Print("Server tidak mengizinkan trade");
Sleep(5000);
return(0);
}
if(IsTradeContextBusy())
{
Print("Trade context is busy. Tunggu sebentar");
Sleep(5000);
return(0);
}
if(!IsConnected())
{
Print("Nggak ada koneksi untuk order dari EA ke server");
Sleep(5000);
return(0);
}
if(MarketInfo(Symbol(),MODE_STOPLEVEL)>TP || MarketInfo(Symbol(),MODE_STOPLEVEL)>SL)
{
Print("Stop Level lebih besar dari pada SL atau TP");
return(0);
}
if(!firstRun)
{
for (int i=OrdersHistoryTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderProfit()>0 )
{
if(OrderType()==OP_SELL && OrderOpenTime()==lastS)
{
deleteAll(OP_BUYSTOP);
lastS = -1;
Sleep(5000);
}
if(OrderType()==OP_BUY && OrderOpenTime()==lastB)
{
deleteAll(OP_SELLSTOP);
lastB = -1;
Sleep(5000);
}
}
}
}
manageTrade();
if(OrdersTotal()==0) firstRun();
//----
return(0);
}
//+------------------------------------------------------------------+
double p()
{
double p;
if(Digits==5 || Digits==3) p = 10*(MarketInfo(Symbol(),MODE_POINT));
else p = MarketInfo(Symbol(),MODE_POINT);
return (p);
}
void openOrder(string simbol, int trade, double lotsize, double price, double sl, double tp,string pesan, int magic, color warna)
{
int tiket=OrderSend(simbol,trade,lotsize,price,Slippage,sl,tp,pesan,magic,0,warna);
if(tiket>0)
{
if(OrderSelect(tiket,SELECT_BY_TICKET,MODE_TRADES)) OrderPrint();
}
else Print("Tidak bisa buka order karena : ",GetLastError());
}
void firstRun()
{//
RefreshRates();
int spread = MarketInfo(Symbol(),MODE_SPREAD);
//buy
double buyTP = Ask+(TP-spread)*p();
double buySL = Ask-SL*p();
openOrder(Symbol(),OP_BUY,InstantLot,Ask,buySL,buyTP,"buy awal",id1,Blue);
levelBuy = Ask;
//sell
double sellTP = Bid-(TP-spread)*p();
double sellSL = Bid+SL*p();
openOrder(Symbol(),OP_SELL,InstantLot,Bid,sellSL,sellTP,"sell awal",id1,Red);
levelSell = Bid;
//buystop
openOrder(Symbol(),OP_BUYSTOP,PendingLot,buyTP+spread*p(),Bid,buyTP+TP*p(),"buy lanjut",id2,Blue);
//sellstop
openOrder(Symbol(),OP_SELLSTOP,PendingLot,sellTP-spread*p(),Ask,sellTP-TP*p(),"sell lanjut",id2,Red);
nextLot = PendingLot*2;
firstRun = true;
}
void manageTrade()
{
int i;
int spread = MarketInfo(Symbol(),MODE_SPREAD);
bool NewBuyExist = false;
bool NewSellExist = false;
for (i=OrdersTotal()-1;i>=0;i--)// mencari order terakhir buystop yang menjadi buy
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_BUY)
{
if(lastB != OrderOpenTime())
{
lastB = OrderOpenTime();
levelBuy = OrderOpenPrice();
NewBuyExist = true;
break;
}
}
}
}
for (i=OrdersTotal()-1;i>=0;i--)// mencari order terakhir sell stop yang menjadi sell
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_SELL)
{
if(lastS != OrderOpenTime())
{
lastS = OrderOpenTime(); // order terakhir sell dicatet waktunya
levelSell = OrderOpenPrice();
NewSellExist = true;
break;
}
}
}
}
if(NewBuyExist)
{
if(firstRun)
{
for(i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_SELLSTOP)
{
OrderDelete(OrderTicket());
firstRun = false;
}
}
}
if(!firstRun)
{
double sellTP = levelSell-(TP-spread)*p();
double sellSL = levelSell+SL*p();
openOrder(Symbol(),OP_SELLSTOP,nextLot,levelSell,sellSL,sellTP,"sell lanjut",id2,Red);
nextLot *= 2;
}
}
if(NewSellExist)
{
if(firstRun)
{
for(i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_BUYSTOP)
{
OrderDelete(OrderTicket());
firstRun = false;
}
}
}
if(!firstRun)
{
double buyTP = levelBuy+(TP-spread)*p();
double buySL = levelBuy-SL*p();
openOrder(Symbol(),OP_BUYSTOP,nextLot,levelBuy,buySL,buyTP,"buy lanjut",id2,Blue);
nextLot *= 2;
}
}
//---
}//
void deleteAll( int trade)
{
int i;
for (i=0;i<OrdersTotal();i++)
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if(OrderType()==trade) OrderDelete(OrderTicket());
}
}
//| HedgeLot_EA.mq4 |
//| Copyright © 2009, metropolis |
//| metropolisfx@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, metropolis"
#property link "metropolisfx@yahoo.com"
extern int TP = 35;
extern int SL = 10;
extern double InstantLot = 0.1;
extern double PendingLot = 0.3;
#define Slippage 2
#define id1 12345
#define id2 67890
//global variables
static datetime lastB = -1;
static datetime lastS = -1;
static datetime lastClose = -1;
static double nextLot;
static double levelBuy;
static double levelSell;
static bool firstRun;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
Comment("\n", " Broker Time : ",TimeToStr(TimeCurrent()),"\n",
"\n", " Stop Level : ",MarketInfo(Symbol(),MODE_STOPLEVEL),
"\n", " Orders Total : ",OrdersTotal(),"\n",
"\n", " Copyright © 2009, metropolis - metropolisfx@yahoo.com");
if(!IsTradeAllowed())
{
Print("Server tidak mengizinkan trade");
Sleep(5000);
return(0);
}
if(IsTradeContextBusy())
{
Print("Trade context is busy. Tunggu sebentar");
Sleep(5000);
return(0);
}
if(!IsConnected())
{
Print("Nggak ada koneksi untuk order dari EA ke server");
Sleep(5000);
return(0);
}
if(MarketInfo(Symbol(),MODE_STOPLEVEL)>TP || MarketInfo(Symbol(),MODE_STOPLEVEL)>SL)
{
Print("Stop Level lebih besar dari pada SL atau TP");
return(0);
}
if(!firstRun)
{
for (int i=OrdersHistoryTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderProfit()>0 )
{
if(OrderType()==OP_SELL && OrderOpenTime()==lastS)
{
deleteAll(OP_BUYSTOP);
lastS = -1;
Sleep(5000);
}
if(OrderType()==OP_BUY && OrderOpenTime()==lastB)
{
deleteAll(OP_SELLSTOP);
lastB = -1;
Sleep(5000);
}
}
}
}
manageTrade();
if(OrdersTotal()==0) firstRun();
//----
return(0);
}
//+------------------------------------------------------------------+
double p()
{
double p;
if(Digits==5 || Digits==3) p = 10*(MarketInfo(Symbol(),MODE_POINT));
else p = MarketInfo(Symbol(),MODE_POINT);
return (p);
}
void openOrder(string simbol, int trade, double lotsize, double price, double sl, double tp,string pesan, int magic, color warna)
{
int tiket=OrderSend(simbol,trade,lotsize,price,Slippage,sl,tp,pesan,magic,0,warna);
if(tiket>0)
{
if(OrderSelect(tiket,SELECT_BY_TICKET,MODE_TRADES)) OrderPrint();
}
else Print("Tidak bisa buka order karena : ",GetLastError());
}
void firstRun()
{//
RefreshRates();
int spread = MarketInfo(Symbol(),MODE_SPREAD);
//buy
double buyTP = Ask+(TP-spread)*p();
double buySL = Ask-SL*p();
openOrder(Symbol(),OP_BUY,InstantLot,Ask,buySL,buyTP,"buy awal",id1,Blue);
levelBuy = Ask;
//sell
double sellTP = Bid-(TP-spread)*p();
double sellSL = Bid+SL*p();
openOrder(Symbol(),OP_SELL,InstantLot,Bid,sellSL,sellTP,"sell awal",id1,Red);
levelSell = Bid;
//buystop
openOrder(Symbol(),OP_BUYSTOP,PendingLot,buyTP+spread*p(),Bid,buyTP+TP*p(),"buy lanjut",id2,Blue);
//sellstop
openOrder(Symbol(),OP_SELLSTOP,PendingLot,sellTP-spread*p(),Ask,sellTP-TP*p(),"sell lanjut",id2,Red);
nextLot = PendingLot*2;
firstRun = true;
}
void manageTrade()
{
int i;
int spread = MarketInfo(Symbol(),MODE_SPREAD);
bool NewBuyExist = false;
bool NewSellExist = false;
for (i=OrdersTotal()-1;i>=0;i--)// mencari order terakhir buystop yang menjadi buy
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_BUY)
{
if(lastB != OrderOpenTime())
{
lastB = OrderOpenTime();
levelBuy = OrderOpenPrice();
NewBuyExist = true;
break;
}
}
}
}
for (i=OrdersTotal()-1;i>=0;i--)// mencari order terakhir sell stop yang menjadi sell
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_SELL)
{
if(lastS != OrderOpenTime())
{
lastS = OrderOpenTime(); // order terakhir sell dicatet waktunya
levelSell = OrderOpenPrice();
NewSellExist = true;
break;
}
}
}
}
if(NewBuyExist)
{
if(firstRun)
{
for(i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_SELLSTOP)
{
OrderDelete(OrderTicket());
firstRun = false;
}
}
}
if(!firstRun)
{
double sellTP = levelSell-(TP-spread)*p();
double sellSL = levelSell+SL*p();
openOrder(Symbol(),OP_SELLSTOP,nextLot,levelSell,sellSL,sellTP,"sell lanjut",id2,Red);
nextLot *= 2;
}
}
if(NewSellExist)
{
if(firstRun)
{
for(i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id2 && OrderType()==OP_BUYSTOP)
{
OrderDelete(OrderTicket());
firstRun = false;
}
}
}
if(!firstRun)
{
double buyTP = levelBuy+(TP-spread)*p();
double buySL = levelBuy-SL*p();
openOrder(Symbol(),OP_BUYSTOP,nextLot,levelBuy,buySL,buyTP,"buy lanjut",id2,Blue);
nextLot *= 2;
}
}
//---
}//
void deleteAll( int trade)
{
int i;
for (i=0;i<OrdersTotal();i++)
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if(OrderType()==trade) OrderDelete(OrderTicket());
}
}
Rabu, 30 April 2014
Ngoprek EA 2
Salam sukses semuanya
Sepertinya harus dilengkapi pada posting saya Ngoprex 1
Senenarnya saya menunggu -nunggu temen2 yang hasil oprekan temen2 , tapi ternyata gak ada yang muncul, baru beberapa orang yang sempat menghubungi di Ym tetntang EA Setka
Nah dalam kesempatan ini saya akan share hasil oprekan versi saya , unguk menambah wawan
Nah ini hasilnya ...silahkan dicopas
//===========================================================================================================================//
// Author VOLDEMAR227 site WWW.TRADING-GO.RU SKYPE: TRADING-GO e-mail: TRADING-GO@List.ru
//===========================================================================================================================//
#property copyright "Copyright © 2013, ngoprex by Jumforex.blogspot.com"
#property link "http://WWW.TRADING-GO.RU"
//===========================================================================================================================//
extern string nGoPrex_by = "Jumforex.blogspot.com";
extern double Risiko_inMoney = 1000;
extern double Target_Persen = 100;
extern bool Close_Panic= false;
extern string Hari_Trade = "=>Sesuai selera::";
extern bool Senin = true;
extern bool Selasa = true;
extern bool Rabu = true;
extern bool Kamis = true;
extern bool Jumat = true;
extern string Comment_1 = "settings";
extern int Plus= 50;
extern int TakeProfit = 11;
extern int Range = 17;
extern double Lots = 0.00;
extern double Percent = 1;
extern bool Martin = true;
extern string Comment_2 = "signalMA";
extern bool SignalMA = false;
extern int PeriodMA1 = 8 ;
extern int PeriodMA2 = 14 ;
extern string Comment_3 = "signalRSI";
extern bool SignalRSI = true;
extern int PeriodRSI = 14 ;
extern int up= 40;
extern int dw= 60;
extern string Comment_4 = "signalProc";
extern bool Proc =true;
extern double Procent =1.3;
extern int Slip=2;
extern int Magic=1;
double bal,xc;string st;
int init()
{
bal= AccountBalance();
return(0);
}
int start() {
if(!IsDemo() ){ Alert("Maaf bos versi demo , hubungi : ym: gifaesa ..."); return(0);}
if(AccountEquity() <= bal - Risiko_inMoney){
cL(0);
cL(1);
Alert(" Waduh Prehatin Bro");
return(0);
}
if(Close_Panic){
cL(0);
cL(1);
Alert(" Tenang Bro dunia belum Berakhir");
return(0);
}
bool tr=false;
xc=(bal*Target_Persen/100);
if(AccountEquity()>=bal+xc){
cL(0);
cL(1);
Alert(" Hore Target udah sampe tujuan selamat");
tr=true;
}
double Lots_New=0;
string Symb =Symbol();
double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);
double Min_Lot=MarketInfo(Symb,MODE_MINLOT);
double Step =MarketInfo(Symb,MODE_LOTSTEP);
double Free =AccountFreeMargin();
//--------------------------------------------------------------- 3 --
if (Lots>0)
{
double Money=Lots*One_Lot;
if(Money<=AccountFreeMargin())
Lots_New=Lots;
else
Lots_New=MathFloor(Free/One_Lot/Step)*Step;
}
//--------------------------------------------------------------- 4 --
else
{
if (Percent > 100)
Percent=100;
if (Percent==0)
Lots_New=Min_Lot;
else
Lots_New=MathFloor(Free*Percent/100/One_Lot/Step)*Step;//????
}
//--------------------------------------------------------------- 5 --
if (Lots_New < Min_Lot)
Lots_New=Min_Lot;
if (Lots_New*One_Lot > AccountFreeMargin())
{
return(false);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
ObjectCreate("R",OBJ_LABEL,0,0,0);
ObjectSet("R",OBJPROP_CORNER,2);
ObjectSet("R",OBJPROP_XDISTANCE,10);
ObjectSet("R",OBJPROP_YDISTANCE,10);
ObjectSetText("R","from: WWW.TRADING-GO.RU ,nGoPrex by Jumforex.blogspot.com",21,"Mistral",Aqua);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double opB=2000; double opS=0; double orderProfitbuy=0; double Sum_Profitbuy=0; double orderProfitsel; double Sum_Profitsel; int orderType;
double LotB=Lots_New;
double LotS=Lots_New;
int total=OrdersTotal();
int b=0,s=0,n=0;
for(int i=total-1; i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() )
{
n++;
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
b++;
LotB=OrderLots();
double ProfitB=OrderTakeProfit(); double openB=OrderOpenPrice();
if(openB<opB)
{opB=openB;}
}
//---------------------------------
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
s++;
LotS=OrderLots();
double ProfitS=OrderTakeProfit(); double openS=OrderOpenPrice();
if(openS>opS)
{opS=openS;}
}
}
}
}
double max = NormalizeDouble(iHigh(Symbol(),1440,0),Digits);
double min = NormalizeDouble(iLow (Symbol(),1440,0),Digits);
double opp=NormalizeDouble(iOpen(Symbol(),1440,0),Digits);
double cl=NormalizeDouble(iClose(Symbol(),1440,0),Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double dis =NormalizeDouble(Range*Point,Digits);
double spred =NormalizeDouble(MarketInfo(Symbol(),MODE_SPREAD)*Point,Digits);
double CORR=NormalizeDouble(Plus *Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int sigup=0;
int sigdw=0;
double RS=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1);
int sig,sg;
if (SignalMA == true)
{
if(MA(PeriodMA1,2)<MA(PeriodMA2,2)&& MA(PeriodMA1,1)>MA(PeriodMA2,1))sig=1;
if(MA(PeriodMA1,2)>MA(PeriodMA2,2)&& MA(PeriodMA1,1)<MA(PeriodMA2,1))sig=2;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (SignalRSI == true)
{
if(RS<up)sg=1;
if(RS>dw)sg=2;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (Proc ==true)
{
if(cl>min) { double x=NormalizeDouble(cl*100/min-100,2); }
if(cl<max) { double y=NormalizeDouble(cl*100/max-100,2); }
if (Procent*(-1)<=y&&Close[1]>Open[1]){ sigup=1; sigdw=0; }
if (Procent >=x&&Close[1]<Open[1]){ sigup=0; sigdw=1; }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int f=0;
if(Martin==true)
{
if (total==0){f=1 ;}
if (total>=1){f=total;}
LotB=Lots_New*f;
LotS=Lots_New*f;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(Martin==false)
{
LotB=LotS;
LotS=LotB;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(!tr && !Close_Panic && tday()==1 && IsDemo()){
if((!SignalMA && !SignalRSI && b==0&&sigup==1&&s==0)||(SignalMA && !SignalRSI && b==0&&sigup==1&&s==0 && sig==1)||(!SignalMA && SignalRSI && b==0&&sigup==1&&s==0 && sg==1)||(SignalMA && SignalRSI && b==0&&sigup==1&&s==0&& sig==1&& sg==1)||(Ask<opB-dis+spred&&b>=1&&s==0)) { OrderSend(Symbol(),OP_BUY ,LotB,Ask,Slip,0,0,"Jum69Buy+"+b,Magic,0,Green); }
if((!SignalMA && !SignalRSI && s==0&&sigdw==1&&b==0)||(SignalMA && !SignalRSI && s==0&&sigdw==1&&b==0 && sig==2)||(!SignalMA && SignalRSI && s==0&&sigdw==1&&b==0 && sg==2)||(SignalMA && SignalRSI && s==0&&sigdw==1&&b==0&& sig==2&& sg==2)||(Bid>opS+dis+spred&&s>=1&&b==0)) { OrderSend(Symbol(),OP_SELL,LotS,Bid,Slip,0,0,"Jum69Sell+"+s,Magic,0,Green); }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double TP= NormalizeDouble (spred+TakeProfit*Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(AccountEquity()<bal+xc && s+b>0) st=" SabaR menunggu ,Target masih dikejar...sabar!"; else
if(AccountEquity()<bal+xc && s+b==0) st=" SabaR menunggu kabar Signal dari langit!"; else
if(tr) st=" Hore Target udah sampe tujuan selamat";
for (int iq=total-1; iq>=0; iq--)
{
if(OrderSelect(iq, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
{
if (OrderType()==OP_BUY && OrderTakeProfit()==0 && b==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()+TP,Digits),0,Blue);
}
if (OrderType()==OP_SELL && OrderTakeProfit()==0 && s==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()-TP,Digits),0,Blue);
}
}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double nn=0,bb=0;
for(int ui=total-1; ui>=0; ui--)
{
if(OrderSelect(ui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
double op=OrderOpenPrice();
double llot=OrderLots();
double itog=op*llot;
bb=bb+itog;
nn=nn+llot;
double factb=bb/nn;
}
}
}
}
double nnn=0,bbb=0;
for(int usi=total-1; usi>=0; usi--)
{
if(OrderSelect(usi,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
double ops=OrderOpenPrice();
double llots=OrderLots();
double itogs=ops*llots;
bbb=bbb+itogs;
nnn=nnn+llots;
double facts=bbb/nnn;
}
}
}
}
for(int uui=total-1; uui>=0; uui--)
{
if(OrderSelect(uui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(b>=2 && OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(factb+CORR,Digits),0,Blue);
}
if(s>=2 && OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(facts-CORR,Digits),0,Blue);
}
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
Comment("\n ",
"\n ",
"\n ------------------------------------------------",
"\n :: Spread : ", MarketInfo(Symbol(), MODE_SPREAD),
"\n :: Leverage : 1 : ", AccountLeverage(),
"\n :: Jam Server :", Hour(), ":", Minute(),
"\n ------------------------------------------------",
"\n :: Equity Sekarang : ", AccountEquity(),
"\n :: Floting : ", mon(),
"\n :: Target : ", Target_Persen, " Persen, @Equety :", bal+xc,"$",
"\n :: Posisi :", st,
"\n ------------------------------------------------",
"\n :: nGopRex By: Jum69",
"\n ------------------------------------------------");
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
void cL(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic || OrderType()!=m) continue;
if (OrderType() > 1) OrderDelete(OrderTicket());
if (OrderType() == 0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == 1)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
double mon()
{
double t;
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic ) continue;
t+=OrderProfit();
}
return(t);
}
double MA(int Per,int s){ return(iMA(NULL,0,Per,8,MODE_SMMA,PRICE_MEDIAN,s)); }
int tday()
{
int trd=0;
if(Senin && DayOfWeek()==1) trd=1;
if(Selasa && DayOfWeek()==2) trd=1;
if(Rabu && DayOfWeek()==3) trd=1;
if(Kamis && DayOfWeek()==4) trd=1;
if(Jumat && DayOfWeek()==5) trd=1;
return(trd);
}
======================
Jangan lupa ea di atas ada proteksi demonya silahkan untuk dicoba
semoga bermanfaat
Salam sukses
*copas dari http://jumforex.blogspot.com
Sepertinya harus dilengkapi pada posting saya Ngoprex 1
Senenarnya saya menunggu -nunggu temen2 yang hasil oprekan temen2 , tapi ternyata gak ada yang muncul, baru beberapa orang yang sempat menghubungi di Ym tetntang EA Setka
Nah dalam kesempatan ini saya akan share hasil oprekan versi saya , unguk menambah wawan
Nah ini hasilnya ...silahkan dicopas
//===========================================================================================================================//
// Author VOLDEMAR227 site WWW.TRADING-GO.RU SKYPE: TRADING-GO e-mail: TRADING-GO@List.ru
//===========================================================================================================================//
#property copyright "Copyright © 2013, ngoprex by Jumforex.blogspot.com"
#property link "http://WWW.TRADING-GO.RU"
//===========================================================================================================================//
extern string nGoPrex_by = "Jumforex.blogspot.com";
extern double Risiko_inMoney = 1000;
extern double Target_Persen = 100;
extern bool Close_Panic= false;
extern string Hari_Trade = "=>Sesuai selera::";
extern bool Senin = true;
extern bool Selasa = true;
extern bool Rabu = true;
extern bool Kamis = true;
extern bool Jumat = true;
extern string Comment_1 = "settings";
extern int Plus= 50;
extern int TakeProfit = 11;
extern int Range = 17;
extern double Lots = 0.00;
extern double Percent = 1;
extern bool Martin = true;
extern string Comment_2 = "signalMA";
extern bool SignalMA = false;
extern int PeriodMA1 = 8 ;
extern int PeriodMA2 = 14 ;
extern string Comment_3 = "signalRSI";
extern bool SignalRSI = true;
extern int PeriodRSI = 14 ;
extern int up= 40;
extern int dw= 60;
extern string Comment_4 = "signalProc";
extern bool Proc =true;
extern double Procent =1.3;
extern int Slip=2;
extern int Magic=1;
double bal,xc;string st;
int init()
{
bal= AccountBalance();
return(0);
}
int start() {
if(!IsDemo() ){ Alert("Maaf bos versi demo , hubungi : ym: gifaesa ..."); return(0);}
if(AccountEquity() <= bal - Risiko_inMoney){
cL(0);
cL(1);
Alert(" Waduh Prehatin Bro");
return(0);
}
if(Close_Panic){
cL(0);
cL(1);
Alert(" Tenang Bro dunia belum Berakhir");
return(0);
}
bool tr=false;
xc=(bal*Target_Persen/100);
if(AccountEquity()>=bal+xc){
cL(0);
cL(1);
Alert(" Hore Target udah sampe tujuan selamat");
tr=true;
}
double Lots_New=0;
string Symb =Symbol();
double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);
double Min_Lot=MarketInfo(Symb,MODE_MINLOT);
double Step =MarketInfo(Symb,MODE_LOTSTEP);
double Free =AccountFreeMargin();
//--------------------------------------------------------------- 3 --
if (Lots>0)
{
double Money=Lots*One_Lot;
if(Money<=AccountFreeMargin())
Lots_New=Lots;
else
Lots_New=MathFloor(Free/One_Lot/Step)*Step;
}
//--------------------------------------------------------------- 4 --
else
{
if (Percent > 100)
Percent=100;
if (Percent==0)
Lots_New=Min_Lot;
else
Lots_New=MathFloor(Free*Percent/100/One_Lot/Step)*Step;//????
}
//--------------------------------------------------------------- 5 --
if (Lots_New < Min_Lot)
Lots_New=Min_Lot;
if (Lots_New*One_Lot > AccountFreeMargin())
{
return(false);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
ObjectCreate("R",OBJ_LABEL,0,0,0);
ObjectSet("R",OBJPROP_CORNER,2);
ObjectSet("R",OBJPROP_XDISTANCE,10);
ObjectSet("R",OBJPROP_YDISTANCE,10);
ObjectSetText("R","from: WWW.TRADING-GO.RU ,nGoPrex by Jumforex.blogspot.com",21,"Mistral",Aqua);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double opB=2000; double opS=0; double orderProfitbuy=0; double Sum_Profitbuy=0; double orderProfitsel; double Sum_Profitsel; int orderType;
double LotB=Lots_New;
double LotS=Lots_New;
int total=OrdersTotal();
int b=0,s=0,n=0;
for(int i=total-1; i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() )
{
n++;
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
b++;
LotB=OrderLots();
double ProfitB=OrderTakeProfit(); double openB=OrderOpenPrice();
if(openB<opB)
{opB=openB;}
}
//---------------------------------
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
s++;
LotS=OrderLots();
double ProfitS=OrderTakeProfit(); double openS=OrderOpenPrice();
if(openS>opS)
{opS=openS;}
}
}
}
}
double max = NormalizeDouble(iHigh(Symbol(),1440,0),Digits);
double min = NormalizeDouble(iLow (Symbol(),1440,0),Digits);
double opp=NormalizeDouble(iOpen(Symbol(),1440,0),Digits);
double cl=NormalizeDouble(iClose(Symbol(),1440,0),Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double dis =NormalizeDouble(Range*Point,Digits);
double spred =NormalizeDouble(MarketInfo(Symbol(),MODE_SPREAD)*Point,Digits);
double CORR=NormalizeDouble(Plus *Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int sigup=0;
int sigdw=0;
double RS=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1);
int sig,sg;
if (SignalMA == true)
{
if(MA(PeriodMA1,2)<MA(PeriodMA2,2)&& MA(PeriodMA1,1)>MA(PeriodMA2,1))sig=1;
if(MA(PeriodMA1,2)>MA(PeriodMA2,2)&& MA(PeriodMA1,1)<MA(PeriodMA2,1))sig=2;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (SignalRSI == true)
{
if(RS<up)sg=1;
if(RS>dw)sg=2;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (Proc ==true)
{
if(cl>min) { double x=NormalizeDouble(cl*100/min-100,2); }
if(cl<max) { double y=NormalizeDouble(cl*100/max-100,2); }
if (Procent*(-1)<=y&&Close[1]>Open[1]){ sigup=1; sigdw=0; }
if (Procent >=x&&Close[1]<Open[1]){ sigup=0; sigdw=1; }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int f=0;
if(Martin==true)
{
if (total==0){f=1 ;}
if (total>=1){f=total;}
LotB=Lots_New*f;
LotS=Lots_New*f;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(Martin==false)
{
LotB=LotS;
LotS=LotB;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(!tr && !Close_Panic && tday()==1 && IsDemo()){
if((!SignalMA && !SignalRSI && b==0&&sigup==1&&s==0)||(SignalMA && !SignalRSI && b==0&&sigup==1&&s==0 && sig==1)||(!SignalMA && SignalRSI && b==0&&sigup==1&&s==0 && sg==1)||(SignalMA && SignalRSI && b==0&&sigup==1&&s==0&& sig==1&& sg==1)||(Ask<opB-dis+spred&&b>=1&&s==0)) { OrderSend(Symbol(),OP_BUY ,LotB,Ask,Slip,0,0,"Jum69Buy+"+b,Magic,0,Green); }
if((!SignalMA && !SignalRSI && s==0&&sigdw==1&&b==0)||(SignalMA && !SignalRSI && s==0&&sigdw==1&&b==0 && sig==2)||(!SignalMA && SignalRSI && s==0&&sigdw==1&&b==0 && sg==2)||(SignalMA && SignalRSI && s==0&&sigdw==1&&b==0&& sig==2&& sg==2)||(Bid>opS+dis+spred&&s>=1&&b==0)) { OrderSend(Symbol(),OP_SELL,LotS,Bid,Slip,0,0,"Jum69Sell+"+s,Magic,0,Green); }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double TP= NormalizeDouble (spred+TakeProfit*Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(AccountEquity()<bal+xc && s+b>0) st=" SabaR menunggu ,Target masih dikejar...sabar!"; else
if(AccountEquity()<bal+xc && s+b==0) st=" SabaR menunggu kabar Signal dari langit!"; else
if(tr) st=" Hore Target udah sampe tujuan selamat";
for (int iq=total-1; iq>=0; iq--)
{
if(OrderSelect(iq, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
{
if (OrderType()==OP_BUY && OrderTakeProfit()==0 && b==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()+TP,Digits),0,Blue);
}
if (OrderType()==OP_SELL && OrderTakeProfit()==0 && s==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()-TP,Digits),0,Blue);
}
}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double nn=0,bb=0;
for(int ui=total-1; ui>=0; ui--)
{
if(OrderSelect(ui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
double op=OrderOpenPrice();
double llot=OrderLots();
double itog=op*llot;
bb=bb+itog;
nn=nn+llot;
double factb=bb/nn;
}
}
}
}
double nnn=0,bbb=0;
for(int usi=total-1; usi>=0; usi--)
{
if(OrderSelect(usi,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
double ops=OrderOpenPrice();
double llots=OrderLots();
double itogs=ops*llots;
bbb=bbb+itogs;
nnn=nnn+llots;
double facts=bbb/nnn;
}
}
}
}
for(int uui=total-1; uui>=0; uui--)
{
if(OrderSelect(uui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(b>=2 && OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(factb+CORR,Digits),0,Blue);
}
if(s>=2 && OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(facts-CORR,Digits),0,Blue);
}
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
Comment("\n ",
"\n ",
"\n ------------------------------------------------",
"\n :: Spread : ", MarketInfo(Symbol(), MODE_SPREAD),
"\n :: Leverage : 1 : ", AccountLeverage(),
"\n :: Jam Server :", Hour(), ":", Minute(),
"\n ------------------------------------------------",
"\n :: Equity Sekarang : ", AccountEquity(),
"\n :: Floting : ", mon(),
"\n :: Target : ", Target_Persen, " Persen, @Equety :", bal+xc,"$",
"\n :: Posisi :", st,
"\n ------------------------------------------------",
"\n :: nGopRex By: Jum69",
"\n ------------------------------------------------");
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
void cL(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic || OrderType()!=m) continue;
if (OrderType() > 1) OrderDelete(OrderTicket());
if (OrderType() == 0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == 1)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
double mon()
{
double t;
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic ) continue;
t+=OrderProfit();
}
return(t);
}
double MA(int Per,int s){ return(iMA(NULL,0,Per,8,MODE_SMMA,PRICE_MEDIAN,s)); }
int tday()
{
int trd=0;
if(Senin && DayOfWeek()==1) trd=1;
if(Selasa && DayOfWeek()==2) trd=1;
if(Rabu && DayOfWeek()==3) trd=1;
if(Kamis && DayOfWeek()==4) trd=1;
if(Jumat && DayOfWeek()==5) trd=1;
return(trd);
}
======================
Jangan lupa ea di atas ada proteksi demonya silahkan untuk dicoba
semoga bermanfaat
Salam sukses
*copas dari http://jumforex.blogspot.com
Ngoprek EA 1
Ha bagi para trader yang sudah biasa bermain dengan coding EA tentu hal
yang lumrah bila sekali waktu ngoprek ,..............Tentu ngoprek EA
maksudnya!
Nah Kali ini saya akan mengajak temen2 untuk mencoba mengoprek sebuah EA yang cukup baik yang berasal dari library mql4 , dan asal EA nya dari negeri beruang ==>Rusia
VR---SETKA---3 ini nama aslinya dari sononya
Begini Eanya!
//===========================================================================================================================//
// Author VOLDEMAR227 site WWW.TRADING-GO.RU SKYPE: TRADING-GO e-mail: TRADING-GO@List.ru
//===========================================================================================================================//
#property copyright "Copyright © 2012, WWW.TRADING-GO.RU ."
#property link "http://WWW.TRADING-GO.RU"
//WWW.TRADING-GO.RU full version free
//===========================================================================================================================//
extern string Comment_1 = "settings";
extern int Plus= 50;
extern int TakeProfit = 300;
extern int Distanciya = 300;
extern double Lots = 0.00;
extern double Percent = 1;
extern bool Martin = true;
extern string Comment_2 = "signalMA";
extern bool SignalMA = false;
extern int PeriodMA1 = 8 ;
extern int PeriodMA2 = 14 ;
extern string Comment_3 = "signalRSI";
extern bool SignalRSI = false;
extern int PeriodRSI = 14 ;
extern int up= 50;
extern int dw= 50;
extern string Comment_4 = "signalProc";
extern bool Proc =true;
extern double Procent =1.3;
extern string Comment_5 = "Monitor";
extern bool Monitor = true;
extern int CORNER = 0;
extern int Slip=2;
extern int Magic=1;
int start()
{
double Lots_New=0;
string Symb =Symbol();
double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);
double Min_Lot=MarketInfo(Symb,MODE_MINLOT);
double Step =MarketInfo(Symb,MODE_LOTSTEP);
double Free =AccountFreeMargin();
//--------------------------------------------------------------- 3 --
if (Lots>0)
{
double Money=Lots*One_Lot;
if(Money<=AccountFreeMargin())
Lots_New=Lots;
else
Lots_New=MathFloor(Free/One_Lot/Step)*Step;
}
//--------------------------------------------------------------- 4 --
else
{
if (Percent > 100)
Percent=100;
if (Percent==0)
Lots_New=Min_Lot;
else
Lots_New=MathFloor(Free*Percent/100/One_Lot/Step)*Step;//????
}
//--------------------------------------------------------------- 5 --
if (Lots_New < Min_Lot)
Lots_New=Min_Lot;
if (Lots_New*One_Lot > AccountFreeMargin())
{
return(false);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
ObjectCreate("R",OBJ_LABEL,0,0,0);
ObjectSet("R",OBJPROP_CORNER,2);
ObjectSet("R",OBJPROP_XDISTANCE,10);
ObjectSet("R",OBJPROP_YDISTANCE,10);
ObjectSetText("R","WWW.TRADING-GO.RU full version free",15,"Arial Black",Red);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double opB=2000; double opS=0; double orderProfitbuy=0; double Sum_Profitbuy=0; double orderProfitsel; double Sum_Profitsel; int orderType;
double LotB=Lots_New;
double LotS=Lots_New;
int total=OrdersTotal();
int b=0,s=0,n=0;
for(int i=total-1; i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() )
{
n++;
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
b++;
LotB=OrderLots();
double ProfitB=OrderTakeProfit(); double openB=OrderOpenPrice();
if(openB<opB)
{opB=openB;}
}
//---------------------------------
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
s++;
LotS=OrderLots();
double ProfitS=OrderTakeProfit(); double openS=OrderOpenPrice();
if(openS>opS)
{opS=openS;}
}
}
}
}
double max = NormalizeDouble(iHigh(Symbol(),1440,0),Digits);
double min = NormalizeDouble(iLow (Symbol(),1440,0),Digits);
double opp=NormalizeDouble(iOpen(Symbol(),1440,0),Digits);
double cl=NormalizeDouble(iClose(Symbol(),1440,0),Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double dis =NormalizeDouble(Distanciya*Point,Digits);
double spred =NormalizeDouble(MarketInfo(Symbol(),MODE_SPREAD)*Point,Digits);
double CORR=NormalizeDouble(Plus *Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int sigup=0;
int sigdw=0;
//WWW.TRADING-GO.RU full version free
if (SignalMA == true)
{
//WWW.TRADING-GO.RU full version free
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (SignalRSI == true)
{
//WWW.TRADING-GO.RU full version free
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (Proc ==true)
{
if(cl>min) { double x=NormalizeDouble(cl*100/min-100,2); }
if(cl<max) { double y=NormalizeDouble(cl*100/max-100,2); }
if (Procent*(-1)<=y&&Close[1]>Open[1]){ sigup=1; sigdw=0; }
if (Procent >=x&&Close[1]<Open[1]){ sigup=0; sigdw=1; }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int f=0;
if(Martin==true)
{
if (total==0){f=1 ;}
if (total>=1){f=total;}
LotB=Lots_New*f;
LotS=Lots_New*f;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(Martin==false)
{
LotB=LotS;
LotS=LotB;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if((b==0&&sigup==1&&s==0)||(Ask<opB-dis+spred&&b>=1&&s==0)) { OrderSend(Symbol(),OP_BUY ,LotB,Ask,Slip,0,0,"Buy ",Magic,0,Green); }
if((s==0&&sigdw==1&&b==0)||(Bid>opS+dis+spred&&s>=1&&b==0)) { OrderSend(Symbol(),OP_SELL,LotS,Bid,Slip,0,0,"Sell",Magic,0,Green); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double TP= NormalizeDouble (spred+TakeProfit*Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
for (int iq=total-1; iq>=0; iq--)
{
if(OrderSelect(iq, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
{
if (OrderType()==OP_BUY && OrderTakeProfit()==0 && b==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()+TP,Digits),0,Blue);
}
if (OrderType()==OP_SELL && OrderTakeProfit()==0 && s==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()-TP,Digits),0,Blue);
}
}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double nn=0,bb=0;
for(int ui=total-1; ui>=0; ui--)
{
if(OrderSelect(ui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
double op=OrderOpenPrice();
double llot=OrderLots();
double itog=op*llot;
bb=bb+itog;
nn=nn+llot;
double factb=bb/nn;
}
}
}
}
double nnn=0,bbb=0;
for(int usi=total-1; usi>=0; usi--)
{
if(OrderSelect(usi,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
double ops=OrderOpenPrice();
double llots=OrderLots();
double itogs=ops*llots;
bbb=bbb+itogs;
nnn=nnn+llots;
double facts=bbb/nnn;
}
}
}
}
for(int uui=total-1; uui>=0; uui--)
{
if(OrderSelect(uui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(b>=2 && OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),factb+CORR,0,Blue);
}
if(s>=2 && OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),facts-CORR,0,Blue);
}
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if ( Monitor == true )
{
//WWW.TRADING-GO.RU full version free
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
=======================
Bagi temen2 yang mau nyoba silahkan di copas dan mungkin bisa diamati programnya.
Ea ini termsuk sudah cukup baik karena sudah menggunakan perhitungan Bep untuk Take profitnya. (emang ada sedikit error untuk modifikasi ordernya tapi tidak menggganggu).
Kalo diamati emang sepertinya EA ini edisi free dan untuk signalnya belum lengkap tetapi sudah cukup baik untuk di coba di buat demo atau riel heeeee dan mungkin edisi lengkapnya dibuat premium (kali aja loh)
Nah Pada kesempatan kali ini saya akan ngoprek dengan sedikit saya tambahakan:
Nah Kali ini saya akan mengajak temen2 untuk mencoba mengoprek sebuah EA yang cukup baik yang berasal dari library mql4 , dan asal EA nya dari negeri beruang ==>Rusia
VR---SETKA---3 ini nama aslinya dari sononya
Begini Eanya!
//===========================================================================================================================//
// Author VOLDEMAR227 site WWW.TRADING-GO.RU SKYPE: TRADING-GO e-mail: TRADING-GO@List.ru
//===========================================================================================================================//
#property copyright "Copyright © 2012, WWW.TRADING-GO.RU ."
#property link "http://WWW.TRADING-GO.RU"
//WWW.TRADING-GO.RU full version free
//===========================================================================================================================//
extern string Comment_1 = "settings";
extern int Plus= 50;
extern int TakeProfit = 300;
extern int Distanciya = 300;
extern double Lots = 0.00;
extern double Percent = 1;
extern bool Martin = true;
extern string Comment_2 = "signalMA";
extern bool SignalMA = false;
extern int PeriodMA1 = 8 ;
extern int PeriodMA2 = 14 ;
extern string Comment_3 = "signalRSI";
extern bool SignalRSI = false;
extern int PeriodRSI = 14 ;
extern int up= 50;
extern int dw= 50;
extern string Comment_4 = "signalProc";
extern bool Proc =true;
extern double Procent =1.3;
extern string Comment_5 = "Monitor";
extern bool Monitor = true;
extern int CORNER = 0;
extern int Slip=2;
extern int Magic=1;
int start()
{
double Lots_New=0;
string Symb =Symbol();
double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);
double Min_Lot=MarketInfo(Symb,MODE_MINLOT);
double Step =MarketInfo(Symb,MODE_LOTSTEP);
double Free =AccountFreeMargin();
//--------------------------------------------------------------- 3 --
if (Lots>0)
{
double Money=Lots*One_Lot;
if(Money<=AccountFreeMargin())
Lots_New=Lots;
else
Lots_New=MathFloor(Free/One_Lot/Step)*Step;
}
//--------------------------------------------------------------- 4 --
else
{
if (Percent > 100)
Percent=100;
if (Percent==0)
Lots_New=Min_Lot;
else
Lots_New=MathFloor(Free*Percent/100/One_Lot/Step)*Step;//????
}
//--------------------------------------------------------------- 5 --
if (Lots_New < Min_Lot)
Lots_New=Min_Lot;
if (Lots_New*One_Lot > AccountFreeMargin())
{
return(false);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
ObjectCreate("R",OBJ_LABEL,0,0,0);
ObjectSet("R",OBJPROP_CORNER,2);
ObjectSet("R",OBJPROP_XDISTANCE,10);
ObjectSet("R",OBJPROP_YDISTANCE,10);
ObjectSetText("R","WWW.TRADING-GO.RU full version free",15,"Arial Black",Red);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double opB=2000; double opS=0; double orderProfitbuy=0; double Sum_Profitbuy=0; double orderProfitsel; double Sum_Profitsel; int orderType;
double LotB=Lots_New;
double LotS=Lots_New;
int total=OrdersTotal();
int b=0,s=0,n=0;
for(int i=total-1; i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() )
{
n++;
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
b++;
LotB=OrderLots();
double ProfitB=OrderTakeProfit(); double openB=OrderOpenPrice();
if(openB<opB)
{opB=openB;}
}
//---------------------------------
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
s++;
LotS=OrderLots();
double ProfitS=OrderTakeProfit(); double openS=OrderOpenPrice();
if(openS>opS)
{opS=openS;}
}
}
}
}
double max = NormalizeDouble(iHigh(Symbol(),1440,0),Digits);
double min = NormalizeDouble(iLow (Symbol(),1440,0),Digits);
double opp=NormalizeDouble(iOpen(Symbol(),1440,0),Digits);
double cl=NormalizeDouble(iClose(Symbol(),1440,0),Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double dis =NormalizeDouble(Distanciya*Point,Digits);
double spred =NormalizeDouble(MarketInfo(Symbol(),MODE_SPREAD)*Point,Digits);
double CORR=NormalizeDouble(Plus *Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int sigup=0;
int sigdw=0;
//WWW.TRADING-GO.RU full version free
if (SignalMA == true)
{
//WWW.TRADING-GO.RU full version free
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (SignalRSI == true)
{
//WWW.TRADING-GO.RU full version free
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (Proc ==true)
{
if(cl>min) { double x=NormalizeDouble(cl*100/min-100,2); }
if(cl<max) { double y=NormalizeDouble(cl*100/max-100,2); }
if (Procent*(-1)<=y&&Close[1]>Open[1]){ sigup=1; sigdw=0; }
if (Procent >=x&&Close[1]<Open[1]){ sigup=0; sigdw=1; }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int f=0;
if(Martin==true)
{
if (total==0){f=1 ;}
if (total>=1){f=total;}
LotB=Lots_New*f;
LotS=Lots_New*f;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(Martin==false)
{
LotB=LotS;
LotS=LotB;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if((b==0&&sigup==1&&s==0)||(Ask<opB-dis+spred&&b>=1&&s==0)) { OrderSend(Symbol(),OP_BUY ,LotB,Ask,Slip,0,0,"Buy ",Magic,0,Green); }
if((s==0&&sigdw==1&&b==0)||(Bid>opS+dis+spred&&s>=1&&b==0)) { OrderSend(Symbol(),OP_SELL,LotS,Bid,Slip,0,0,"Sell",Magic,0,Green); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double TP= NormalizeDouble (spred+TakeProfit*Point,Digits);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
for (int iq=total-1; iq>=0; iq--)
{
if(OrderSelect(iq, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
{
if (OrderType()==OP_BUY && OrderTakeProfit()==0 && b==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()+TP,Digits),0,Blue);
}
if (OrderType()==OP_SELL && OrderTakeProfit()==0 && s==1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()-TP,Digits),0,Blue);
}
}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
double nn=0,bb=0;
for(int ui=total-1; ui>=0; ui--)
{
if(OrderSelect(ui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
double op=OrderOpenPrice();
double llot=OrderLots();
double itog=op*llot;
bb=bb+itog;
nn=nn+llot;
double factb=bb/nn;
}
}
}
}
double nnn=0,bbb=0;
for(int usi=total-1; usi>=0; usi--)
{
if(OrderSelect(usi,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
double ops=OrderOpenPrice();
double llots=OrderLots();
double itogs=ops*llots;
bbb=bbb+itogs;
nnn=nnn+llots;
double facts=bbb/nnn;
}
}
}
}
for(int uui=total-1; uui>=0; uui--)
{
if(OrderSelect(uui,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(b>=2 && OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),factb+CORR,0,Blue);
}
if(s>=2 && OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),facts-CORR,0,Blue);
}
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if ( Monitor == true )
{
//WWW.TRADING-GO.RU full version free
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
=======================
Bagi temen2 yang mau nyoba silahkan di copas dan mungkin bisa diamati programnya.
Ea ini termsuk sudah cukup baik karena sudah menggunakan perhitungan Bep untuk Take profitnya. (emang ada sedikit error untuk modifikasi ordernya tapi tidak menggganggu).
Kalo diamati emang sepertinya EA ini edisi free dan untuk signalnya belum lengkap tetapi sudah cukup baik untuk di coba di buat demo atau riel heeeee dan mungkin edisi lengkapnya dibuat premium (kali aja loh)
Nah Pada kesempatan kali ini saya akan ngoprek dengan sedikit saya tambahakan:
- Target persen = artinya kalo target equety sudah tercapai maka EA akan berhenti trading
- Penambahan signal berdasarkan indikator yang ada
- dan sedikit diberi pemanis buatan heeeeeeee
Nah sementara di sini dulu yah
hasil ngopreknya sabar dulu atau ada temen2 yang akan menyumbangkan
hasil oprekannya , silahkan di kasih link atau email juga boleh
untuk versi oprek bisa langung meluncur ke sini
untuk versi oprek bisa langung meluncur ke sini
*copas dari http://jumforex.blogspot.com
Share JumStoch v2.6
Share JumStoch v2.6
Pada posting kali ini sayare a akan coba share satu EA sy, sebagai kelanjutan dari EA yang pernah saya share pada forum Indomt5 di sini dan kelanjutan dari posting di sini.
====================
EA JumStoCh+v2 Final Edition
secara konsep EA ini menggunakan indikator MA dan Stockhastik
EA ini telah saya share di tread forum Mt5 silahkan kunjungi disini
EA ini ada 2 macam
1. versi 2.1-2.3 menggunakan tp dalam hitungan pip dari orderopenprice
2. versi 2.4 dan 2.5 menggunakan tp Bep
Ini hasil Beck test versi 2.5 selama 1 bulan
Seiringing dengan pengalaman penggunaanny Jum+StoCh+ akhirnya lebih disempurnakan dengan Jum+StoCh+ Final Edition ==> dengan penambahan fitur baru untuk kepentingan trade menhadapi market
Fitur Jum+StoCh+v2.3F al:
extern string Seting_Parameter = "=>Parameter Pro+v2.3<<";
extern string Khusus_Closing = "=>Gunakan sesuai Kebutuhan<<";
extern bool Close_Panic =false; >>close mendadak sema order
extern bool Close_Buy_Trend =false; >> close khusus buy trend (Jum+StoCh+1)
extern bool Close_Sell_Trend =false; >> close khusus sell trend (Jum+StoCh+2)
extern bool Close_Buy_Counter =false; >> close khusus buy counter (Jum+StoCh+3)
extern bool Close_Sell_Counter =false; >> close khusus sel lcounter (Jum+StoCh+4)
extern string Seting_Risk_Target = "=>Gunakan sesuai Kebutuhan<<";
extern bool Risk_In_Money =false;
extern double Risk_in_money =1000;
extern double Target_Persen =1000;
extern string Seting_Mode_Trend = "=>Seting Trade trend<<"; >> tambahan fitur baru khusus trend
extern int StartHour = 0;
extern int StopHour = 24;
extern bool Buy_Trend =true;
extern bool Sell_Trend =true;
extern string Seting_Mode_Conter= "=>Seting Trade Counter
Trend<<"; >> tambahan fitur baru khusus counter trend
extern int Start_Hour = 0;
extern int Stop_Hour = 24;
extern bool Buy_Counter =true;
extern bool Sell_Counter =true;
extern string Gap_="==>Gap_Factor= jarak pip gap order ";
extern bool Close_All_Gap =true;
extern double Gap_Factor =38;
extern string Seting_MM = "=>Seting sesuai selera<<";
extern string Lot_info = "Lot Mode = 1 -> Compound; Mode = 2 -> Fix Lot)";
extern int Lot_mode = 2;
extern string Lot_info2 = "Rumus Compound = Balance/Manage_Lot";
extern double Manage_Lot =10000;
extern double Fix_lot =0.01;
extern int Magic =69;
extern double Range =21;
extern int Level_Max =12;
extern int Star_ModifTp =4;
extern double DiMarti =1.7;
extern double SL =253;
extern double TP =30;
extern bool Tp_In_money =false;
extern double Tp_in_money =7.0;
extern bool Dtrailing =false;
extern int Trailing = 5;
extern string Indi_Seting = "==>Stockhastik trend & MA
Seting<<="; >>seting indikator masiing2 mode disendirikan
extern int kperiod = 10;
extern int dperiod = 3;
extern int slowing = 3;
extern int lo_level = 25;
extern int up_level = 75;
extern int maPereode = 25;
extern string Indi_Stoch_2 = "==>Stockhastik counter trend<<=";
extern int k_period = 32;
extern int d_period = 12;
extern int s_lowing = 12;
extern int lolevel = 30;
extern int uplevel = 70;
Fitur Jum+StoCh+v2.5F tidak jauh berbeda al:extern string Seting_Parameter = "=>Parameter Pro+v2.5<<";
extern string StopTrade_Info = "=>Model Stop Profit / Take Loss EA<<"; // :D
extern string Khusus_Closing = "=>Gunakan sesuai Kebutuhan<<";
extern bool Close_Panic =false;
extern bool Close_Buy_Trend =false;
extern bool Close_Sell_Trend =false;
extern bool Close_Buy_Counter =false;
extern bool Close_Sell_Counter =false;
extern string Seting_Risk_Target = "=>Gunakan sesuai Kebutuhan<<";
extern bool Risk_In_Money = false;
extern double Risk_in_money = 1000;
extern double Target_Persen = 1000;
extern string Seting_Mode_Trend = "=>Seting Trade trend<<";
extern int StartHour = 0;
extern int StopHour = 24;
extern bool Buy_Trend =true;
extern bool Sell_Trend =true;
extern string Seting_Mode_Conter= "=>Seting Trade Counter Trend<<";
extern int Start_Hour = 0;
extern int Stop_Hour = 24;
extern bool Buy_Counter =true;
extern bool Sell_Counter =true;
extern string Seting_MM = "=>Seting sesuai selera<<";
extern string Lot_info = "Lot Mode = 1 -> Compound; Mode = 2 -> Fix Lot)";
extern int Lot_mode = 2;
extern string Lot_info2 = "Rumus Compound = Balance/Manage_Lot";
extern double Manage_Lot = 10000;
extern double Fix_lot = 0.01;
extern int Magic = 69;
extern double Range = 21;
extern int Level_Max = 12;
extern double DiMarti = 1.7;
extern double SL = 253;
extern double TP = 30;
extern int Star_ModifTp_Bep = 3;
extern double Tp_from_Bep = 11;
extern bool Tp_In_money = false;
extern double Tp_in_money = 7.0;
extern bool Dtrailing = true;
extern int StartTrail = 10;
extern int Trailing = 7;
extern string Indi_Seting = "==>Stockhastik trend & MA Seting<<=";
extern int kperiod = 32;
extern int dperiod = 12;
extern int slowing = 12;
extern int lo_level = 25;
extern int up_level = 75;
extern int maPereode = 25;
extern string Indi_Stoch_2 = "==>Stockhastik counter trend<<=";
extern int k_period = 32;
extern int d_period = 12;
extern int s_lowing = 12;
extern int lolevel = 30;
extern int uplevel = 70;
Semoga bermanfaat untuk trader IndonesiaNah Final Edition Silahkan download ===> disini
Jangan lupa kasih comment kalo ada hal2 sebagai masukan====================
Sebenarnya versi ini telah dikembangkan sampai versi 9 (masih untuk pribadi).
Pada versi ini sebenar sedikit berbeda dengan versi sebelumnya karena pada versi ini sebenarnya disamping untuk mengejar profit tapi juga mengejar rabat.
Masih tetep trigernya cuma sedikit ditambah pengembangan sehingga lebih agresif dengan model
average dan lotsnya tetep , tetapi mengacu pada kelipatan balance
Penasaran ini Parameternya
Ada parameter Slow_aja ini bisa dipilih true atau false
untuk mengetahui kegunaannya silahkan di coba dibuat demo atu di Becktest.
Penampakannya sbb:
Bagi yang mau nyoba silahkan sedot disini
Belajar Membuat EA Sederhana 38 (terapan indikator IFX_Keltner_Channel III)
Dibagian sebelumnya sudah di jelaskan tentang model indikator ini. dan juga ada teman yang sudah bikin eanya di part sebelum nya .
Kali saya juga agan share tentang ea yg berdasarkan indikator ini dengan model averaging .
EA ini cococok untuk mengejar rabat !
Tapi jangan lupa Ea ini ada proteksi demonya | jadi harus dihilangkan dulu
//+------------------------------------------------------------------+
//| Jum+Keltner Chan .mq4 |
//| Copyright 2013, Annura |
//| gifaesa@yahoo.com |
//| http://JumForex.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "JumForex.blogspot.com"
#property link "Gifaesa@yahoo.com"
extern string Nama_EA = "Jum+Keltner+Chan";
extern int TP = 11;
extern int TP_money = 11;
extern int SL = 20;
extern bool SL_otomatis = false;
extern double Lot = 0.01;
extern int Magic = 69;
extern int Mode_Ma = 0;
extern int Ma_Pareode = 10;
extern int Price_tip = 5;
extern int Max_order = 2;
double pt,SLb,TPb,SLs,TPs;
int init()
{
if(Digits==3 || Digits==5) pt=10*Point; else pt=Point;
return(0);
}
int deinit()
{
return(0);
}
int start() {lab();
if(!IsDemo()){Alert("hanya untuk demo boss"); return(0);}
if(TP_money<=man())closeall();
double kfa = iCustom(Symbol(),0,"IFX_Keltner_Channel",Ma_Pareode,Mode_Ma,Price_tip,0,0);
double kfm = iCustom(Symbol(),0,"IFX_Keltner_Channel",Ma_Pareode,Mode_Ma,Price_tip,1,0);
double kfb = iCustom(Symbol(),0,"IFX_Keltner_Channel",Ma_Pareode,Mode_Ma,Price_tip,2,0);
static datetime w;
if(TP==0)TPb=0;else TPb=Ask+TP*pt;
if(TP==0)TPs=0;else TPs=Bid-TP*pt;
if(SL==0)SLb=0;else SLb=Ask-SL*pt;
if(SL==0)SLs=0;else SLs=Bid+SL*pt;
if(SL_otomatis){ SLb=kfb; SLs=kfa;}//else if(!SL_otomatis){SLb=Ask-SL*pt; SLs=Bid +SL*pt;}
if(w!=Time[0] && IsDemo()){
if(Ask<kfb && JumlahOrder(0)<Max_order) {
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,SLb,TPb,Nama_EA,Magic,0,Blue);
}
if(Bid>kfa && JumlahOrder(1)<Max_order) {
OrderSend(Symbol(),OP_SELL,Lot,Bid,3,SLs,TPs,Nama_EA,Magic,0,Red);
}
w=Time[0]; }
return(0);
}
//+------------------------------------------------------------------+
int JumlahOrder(int Tipe){ int Total = 0;
for(int i=0; i<OrdersTotal(); i++) {
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=Tipe) continue;
if(IsDemo())Total++; }
return(Total);}
double man(){double Total = 0;
for(int i=0; i<OrdersTotal(); i++) {
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic ) continue;
if(IsDemo())Total+=OrderProfit(); }
return(Total);}
void closeall(){
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic ) continue;
if (OrderType() > 1) OrderDelete(OrderTicket());
if (OrderType() == 0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == 1)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE); }}
void lab(){
Comment("\n ",
"\n ------------------------------------------------",
"\n :: Spread : ", MarketInfo(Symbol(), MODE_SPREAD),
"\n :: Leverage : 1 : ", AccountLeverage(),
"\n :: Equity : ", AccountEquity(),
"\n :: Jam Server :", Hour(), ":", Minute(),
"\n ------------------------------------------------",
"\n :: Total Op Buy : ",JumlahOrder(0),
"\n :: Total Op Sell : ",JumlahOrder(1),
"\n ------------------------------------------------",
"\n :: >>By: Jum69<<",
"\n ------------------------------------------------");
}
=============
*copas dari http://jumforex.blogspot.com
Langganan:
Postingan (Atom)