BTC USD 39,833.9 Gold USD 1,863.90
Time now: Jun 1, 12:00 AM

Mohon Tulung Pomenkan EA

musangpulutt

Active Member
Joined
May 1, 2010
Messages
2,097
Reaction score
63
Points
30
Salam....
mohon masta2 koding tulung masukkan Trailing Stop ngan Trailing Step kat dlm robot sekoq ni...
baru buleh tinggal dia masa buat keja kat opis...


//+------------------------------------------------------------------+
//| "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 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!");

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);

}
}
}
}


ps# ni asal masta Aiman yg punya.. patik godek2 sikit... mintak halal...
 
Last edited:
Sponsored Post

musangpulutt

Active Member
Joined
May 1, 2010
Messages
2,097
Reaction score
63
Points
30
aik... smua masuk tngok ja... sapa2 pun xmau tulung... :((. patik dh try 3-4 kali dh.. tapi dia xmau jd jgk.. mana masta2 koding ni... :-?
 

mankj

Active Member
Joined
Jul 10, 2009
Messages
1,346
Reaction score
32
Points
30
sabar bro...nanti ada la yg tolong tuh...
 

tenungskrin

Super Active Member
Joined
Oct 5, 2009
Messages
5,711
Reaction score
90
Points
70
den ghaso kabereta kono servis nih.. kasi bosa lubang tu..

mahap yo tt.. lawak time tonung2 chart
 

musangpulutt

Active Member
Joined
May 1, 2010
Messages
2,097
Reaction score
63
Points
30
mana masta aiman ni... letih dah den nunggu...
 

aiman

Active Member
Joined
Apr 19, 2006
Messages
1,894
Reaction score
1,356
Points
101
trailingstop kena guna EA, tak boleh guna script sebab kena monitor. etrailing EA dah ada kat thread 1000 pips lukpayat. Tak ingat la page berapa.
 

ForexGaban_83

Fun Poster
Joined
Aug 17, 2010
Messages
716
Reaction score
333
Points
31
cuba pakai yang ni...
letak kat bawah sekali...
//+-----------------------------------------------------------------+

void TrailingPositions() {
double pBid, pAsk, pp;

pp = MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY) {
pBid = MarketInfo(OrderSymbol(), MODE_BID);
if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
ModifyStopLoss(pBid-TrailingStop*pp);
return;
}
}
}
if (OrderType()==OP_SELL) {
pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
if (!ProfitTrailing || (OrderOpenPrice()-pAsk)>TrailingStop*pp) {
if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp) {
ModifyStopLoss(pAsk+TrailingStop*pp);
return;
}
}
}
}
void ModifyStopLoss(double ldStopLoss) {
bool fm;

fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
}

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

yg ni letak kat atas sekali

extern bool ProfitTrailing = True;
extern int TrailingStop = 10;
extern int TrailingStep = 10;

yg ni letak dlm int start...

if(ProfitTrailing)TrailingPositions();


sekian, semoga membantu...
 
Sponsored Post

Live Forex Chart

Currency
Rates
EUR / USD
1.21305
USD / JPY
110.123
GBP / USD
1.40871
USD / CHF
0.89778
USD / CAD
1.21638
EUR / JPY
133.585
AUD / USD
0.76918

CG Sponsors




Top
Log in Register