musangpulutt
Active Member
- Messages
- 2,100
- Joined
- May 1, 2010
- Messages
- 2,100
- Reaction score
- 64
- Points
- 30
//+------------------------------------------------------------------+
//| "PROJEK CUBA NAK JADI KAYA CEPAT" |
//| kopi rait hak ciplak terhuru-hara © 2010, ANAKANTU PISANG |
//+------------------------------------------------------------------+
//------------------
#property copyright "anakantu pisang"
#property link "musangpulutt"
//---- input parameters
extern double Lots = 0.50;
extern int SL = 40;
extern int TP = 60;
extern bool ProfitTrailing = True;
extern int TrailingStop = 17;
extern int TrailingStep = 2;
extern bool Sell = true;
extern bool Buy = true;
extern bool UseSound = True;
extern string NameFileSound = "rugi.wav";
int Slippage = 5;
// globals
string mySymbol, postfix;
// trade management
double ask, bid, point, SLBuy=0, SLSell=0, TPBuy=0, TPSell=0;
string TradeComment="Dah Langgaq Dah";
int MagicNumber = 123456781;
// used for verbose error logging
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() { return(0); }
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
Print("Init happened ",Hour()+":"+Minute());
Comment("Kais Pagi Makan Pagi!");
if (ProfitTrailing)TrailingPositions();
postfix = StringSubstr(Symbol(),6,1);
double CSopen = iOpen(NULL,0,0);
double CSclose = iClose(NULL,0,0);
double TL = NormalizeDouble(ObjectGetValueByShift("bawah",0) ,Digits);
if (ObjectFind ("bawah")==0)
{
if ( (CSopen>TL && TL>CSclose) || (CSopen<TL && TL<CSclose) )
{
ObjectDelete("atas");
ObjectDelete("bawah");
if (Sell==true)
{
TradeComment="Bawah - Sell";
PlaySound(NameFileSound);
Print("Init happened ",Hour()+":"+Minute());
Comment("Mari Sell EURO!");
mySymbol=Symbol()+postfix; OpenPos("Sell");
mySymbol=Symbol()+postfix; OpenPos("Sell");
}
}
}
{
postfix = StringSubstr(Symbol(),6,1);
double CSopen1 = iOpen(NULL,0,0);
double CSclose1 = iClose(NULL,0,0);
double TL1 = NormalizeDouble(ObjectGetValueByShift("atas",0) ,Digits);
{
if (ObjectFind ("atas")==0)
{
if ( (CSopen1>TL1 && TL1>CSclose1) || (CSopen1<TL1 && TL1<CSclose1) )
{
ObjectDelete("bawah");
ObjectDelete("atas");
if (Buy==true)
{
TradeComment="Atas - Buy";
PlaySound(NameFileSound);
Print("Init happened ",Hour()+":"+Minute());
Comment("Mari Buy EURO!");
mySymbol=Symbol()+postfix; OpenPos("Buy");
mySymbol=Symbol()+postfix; OpenPos("Buy");
}
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//ENTRY LONG (buy, Ask)
void OpenPos(string Trade)
{
int gle=0;
int ticket=0;
int loopcount;
loopcount=0;
while(true)
{
bid = MarketInfo(mySymbol,MODE_BID);
ask = MarketInfo(mySymbol,MODE_ASK);
point = MarketInfo(mySymbol,MODE_POINT);
if (SL>0) { SLBuy=bid-(SL*point); SLSell=ask+(SL*point); }
if (TP>0) { TPBuy=bid+(TP*point); TPSell=ask-(TP*point); }
// place order
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+" SL="+SL+" TP="+TP+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
if (Trade=="Sell") Print("-----ERROR----- placing SELL order: Lots="+Lots+" SL="+SL+" TP="+TP+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
RefreshRates();
Sleep(500);
// give up after 10 tries (~5 seconds)
loopcount++;
if (loopcount>10)
{
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 trailingstop()
{
double stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
for(int i=OrdersTotal()-1; i>0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol()||
OrderMagicNumber()!=MagicNumber)
continue;
if(OrderType()==OP_BUY)
{
if(MathAbs(OrderTakeProfit()-OrderStopLoss())<=2*stoplevel*Point) break;
if(Bid>=OrderStopLoss()+(SL+TrailingStop)*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+TrailingStop*Point,OrderTakeProfit(),CLR_NONE);
}
}
if(OrderType()==OP_SELL)
{
if(MathAbs(OrderTakeProfit()-OrderStopLoss())<=2*stoplevel*Point) break;
if(Ask>=OrderStopLoss()-(SL+TrailingStop)*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()-TrailingStop*Point,OrderTakeProfit(),CLR_NONE);
}
}
}
}
//+------------------------------------------------------------------+
Function is not defined
//| "PROJEK CUBA NAK JADI KAYA CEPAT" |
//| kopi rait hak ciplak terhuru-hara © 2010, ANAKANTU PISANG |
//+------------------------------------------------------------------+
//------------------
#property copyright "anakantu pisang"
#property link "musangpulutt"
//---- input parameters
extern double Lots = 0.50;
extern int SL = 40;
extern int TP = 60;
extern bool ProfitTrailing = True;
extern int TrailingStop = 17;
extern int TrailingStep = 2;
extern bool Sell = true;
extern bool Buy = true;
extern bool UseSound = True;
extern string NameFileSound = "rugi.wav";
int Slippage = 5;
// globals
string mySymbol, postfix;
// trade management
double ask, bid, point, SLBuy=0, SLSell=0, TPBuy=0, TPSell=0;
string TradeComment="Dah Langgaq Dah";
int MagicNumber = 123456781;
// used for verbose error logging
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() { return(0); }
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
Print("Init happened ",Hour()+":"+Minute());
Comment("Kais Pagi Makan Pagi!");
if (ProfitTrailing)TrailingPositions();
postfix = StringSubstr(Symbol(),6,1);
double CSopen = iOpen(NULL,0,0);
double CSclose = iClose(NULL,0,0);
double TL = NormalizeDouble(ObjectGetValueByShift("bawah",0) ,Digits);
if (ObjectFind ("bawah")==0)
{
if ( (CSopen>TL && TL>CSclose) || (CSopen<TL && TL<CSclose) )
{
ObjectDelete("atas");
ObjectDelete("bawah");
if (Sell==true)
{
TradeComment="Bawah - Sell";
PlaySound(NameFileSound);
Print("Init happened ",Hour()+":"+Minute());
Comment("Mari Sell EURO!");
mySymbol=Symbol()+postfix; OpenPos("Sell");
mySymbol=Symbol()+postfix; OpenPos("Sell");
}
}
}
{
postfix = StringSubstr(Symbol(),6,1);
double CSopen1 = iOpen(NULL,0,0);
double CSclose1 = iClose(NULL,0,0);
double TL1 = NormalizeDouble(ObjectGetValueByShift("atas",0) ,Digits);
{
if (ObjectFind ("atas")==0)
{
if ( (CSopen1>TL1 && TL1>CSclose1) || (CSopen1<TL1 && TL1<CSclose1) )
{
ObjectDelete("bawah");
ObjectDelete("atas");
if (Buy==true)
{
TradeComment="Atas - Buy";
PlaySound(NameFileSound);
Print("Init happened ",Hour()+":"+Minute());
Comment("Mari Buy EURO!");
mySymbol=Symbol()+postfix; OpenPos("Buy");
mySymbol=Symbol()+postfix; OpenPos("Buy");
}
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//ENTRY LONG (buy, Ask)
void OpenPos(string Trade)
{
int gle=0;
int ticket=0;
int loopcount;
loopcount=0;
while(true)
{
bid = MarketInfo(mySymbol,MODE_BID);
ask = MarketInfo(mySymbol,MODE_ASK);
point = MarketInfo(mySymbol,MODE_POINT);
if (SL>0) { SLBuy=bid-(SL*point); SLSell=ask+(SL*point); }
if (TP>0) { TPBuy=bid+(TP*point); TPSell=ask-(TP*point); }
// place order
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+" SL="+SL+" TP="+TP+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
if (Trade=="Sell") Print("-----ERROR----- placing SELL order: Lots="+Lots+" SL="+SL+" TP="+TP+" Bid="+bid+" Ask="+ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));
RefreshRates();
Sleep(500);
// give up after 10 tries (~5 seconds)
loopcount++;
if (loopcount>10)
{
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 trailingstop()
{
double stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
for(int i=OrdersTotal()-1; i>0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol()||
OrderMagicNumber()!=MagicNumber)
continue;
if(OrderType()==OP_BUY)
{
if(MathAbs(OrderTakeProfit()-OrderStopLoss())<=2*stoplevel*Point) break;
if(Bid>=OrderStopLoss()+(SL+TrailingStop)*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+TrailingStop*Point,OrderTakeProfit(),CLR_NONE);
}
}
if(OrderType()==OP_SELL)
{
if(MathAbs(OrderTakeProfit()-OrderStopLoss())<=2*stoplevel*Point) break;
if(Ask>=OrderStopLoss()-(SL+TrailingStop)*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()-TrailingStop*Point,OrderTakeProfit(),CLR_NONE);
}
}
}
}
//+------------------------------------------------------------------+
Function is not defined
