BTC USD 83,759.4 Gold USD 4,295.00
Time now: Jun 1, 12:00 AM

Mohon Tulung Pomenkan EA

kalo guna yg ada magicnumber, lps compile ada error..
 
Last edited:
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...

xda magicnumber pun.. nk tukar kat mana?
 
void TrailingPositions()...yg ni tak pakai magicnumber, tapi pakai MarketInfo...

lepas compile, error apa yg keluar?
 
Last edited:
Yang guna MagicNumber cuba tukar pt kepada Point.
 
Masta.. Dh compile yg ada MagicNumber.. dh rapatkan semua typing yg lari.. still error lagi..

if(Bid>=OrderStopLoss()+(sl+TrailingStop)*point)

nk ganti apa masta?
 
Masta.. Dh compile yg ada MagicNumber.. dh rapatkan semua typing yg lari.. still error lagi..

if(Bid>=OrderStopLoss()+(sl+TrailingStop)*point)

nk ganti apa masta?

Point tuh kena huruf besar P .... dan apa error keluar?
 
//+------------------------------------------------------------------+
//| "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";
extern bool ProfitTrailing = True;
extern int TrailingStop = 10;
extern int TrailingStep = 10;


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()
{
//----
if(ProfitTrailing)TrailingPositions();
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);

}
}
}
}

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);
}
 
Bro jejantas dah test x? yg bro masukkan tu dh sama mcm yg saya masukkan.. tapi dia xmau trail pun..
 
Last edited:

Latest Posts

Live Forex Chart

Currency
Rates
EUR / USD
1.13994
USD / JPY
157.250
GBP / USD
1.32514
USD / CHF
0.82895
USD / CAD
1.41534
EUR / JPY
179.125
AUD / USD
0.70291
Back
Top
Log in Register