BTC USD 83,952.1 Gold USD 4,290.87
Time now: Jun 1, 12:00 AM

Mohon Tulung Pomenkan EA

musangpulutt

Active Member
Messages
2,100
Joined
May 1, 2010
Messages
2,100
Reaction score
64
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:
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... :-?
 
sabar bro...nanti ada la yg tolong tuh...
 
den ghaso kabereta kono servis nih.. kasi bosa lubang tu..

mahap yo tt.. lawak time tonung2 chart
 
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.
 
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...
 

Latest Posts

Live Forex Chart

Currency
Rates
EUR / USD
1.13999
USD / JPY
157.148
GBP / USD
1.32455
USD / CHF
0.82839
USD / CAD
1.41366
EUR / JPY
179.181
AUD / USD
0.70246
Back
Top
Log in Register