ZeroCode Expert Running 3 Majors (?)

 

I have successfully created an expert using ZeroCode. Unfortunately, it seems my expert can only be used on one currency pair at a time. I would like to use my expert on three pairs simultaneously. I have read this thread and I don't think MetaTrader's 5 sec rule will be applicable in my case based on the longer-term nature of my trades which is obviously a good thing. Here is the code of the simple MA Cross system I have developed. If anyone can add in a function (TotalTrades(?)...) to allow me to attach the same advisor to three currency pairs I would REALLY appreciate it. Thank You

//*---------------------------------------------------------------------------------------------------------*\

// This MQL is automatically generated by FXFisherman ZeroCode v1.0.2014.30845 (www.fxfisherman.com)
//
// DISCLAIMER:
//
// FXFisherman ZeroCode is provided free of charge, and, therefore, on an "as is" basis, without warranty
// of any kind, express or implied, including without limitation the warranties that it is free of defects,
// virus free, able to operate on an uninterrupted basis, merchantable, fit for a particular purpose or
// non-infringing. In any case, the author(s) will not be responsible or liable for ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL, INDIRECT OR ANY OTHER LOSSES caused by using of this software. USE IT AT YOUR OWN RISK.
//
//*-----------------------------------PLEASE DO NOT REMOVE THIS HEADER--------------------------------------*/

/*[[ Name := ZeroCode Test System
Author := ZeroCoder
Link := Coded_by_FXFisherman_ZeroCode_@www.fxfisherman.com
Lots := 1
Stop Loss := 40
Take Profit := 0
Trailing Stop := 0
]]*/
defines: Slippage(3);
defines: ;
var: cnt(0),IsBuying(False),IsSelling(False),IsClosing( False),RealTP(0),RealSL(0);
var: ma1_1(0),ma1_0(0),ma2_1(0),ma2_0(0);

// Check for invalid bars and takeprofit
If Bars<200 then Exit;

// Calculate indicators' value
ma1_1 = iMAEx(2,MODE_EMA,0,PRICE_CLOSE,1);
ma1_0 = iMAEx(2,MODE_EMA,0,PRICE_CLOSE,0);
ma2_1 = iMAEx(20,MODE_EMA,0,PRICE_CLOSE,1);
ma2_0 = iMAEx(20,MODE_EMA,0,PRICE_CLOSE,0);


// Check for BUY, SELL, and CLOSE signal
IsBuying = (ma1_1 < ma2_1)
and (ma2_0 > ma2_0);
IsSelling = (ma1_1 > ma2_1)
and (ma1_0 < ma2_0);
IsClosing = False;

// Control open trades
for cnt=1 to TotalTrades
{
// Control only market trades not entry order
if OrderValue(cnt,VAL_TYPE)<=OP_SELL and
OrderValue(cnt,VAL_SYMBOL)=Symbol then
{

// Check for close signal for bought trade
If OrderValue(cnt,VAL_TYPE)=OP_BUY then
{

If IsSelling or IsClosing then
{
// Close bought trade
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(c nt,VAL_LOTS),Bid,3,Violet);
Alert("ZeroCode Test System: Closing BUY order.");
};

// Check trailing stop
If TrailingStop>0 then
{
If (Bid-OrderValue(cnt,VAL_OPENPRICE))>(Point*TrailingStop) then
{
If OrderValue(cnt,VAL_STOPLOSS)<(Bid-Point*TrailingStop) then
{
// Modify trailing stop
ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue( cnt,VAL_OPENPRICE),
Bid-Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROFIT), Red);
};
};
};
}
else
{

// Check sold trade for close signal
If IsBuying or IsClosing then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(c nt,VAL_LOTS),Ask,3,Violet);
Alert("ZeroCode Test System: Closing SELL order.");
};

// Control trailing stop
If TrailingStop>0 then
{
If (OrderValue(cnt,VAL_OPENPRICE)-Ask)>(Point*TrailingStop) then
{
If OrderValue(cnt,VAL_STOPLOSS)=0 or
OrderValue(cnt,VAL_STOPLOSS)>(Ask+Point*TrailingStop) then
{
ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue( cnt,VAL_OPENPRICE),
Ask+Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROF IT),Red);
};
};
};
};
};
};


// If there is no open trade
If TotalTrades<1 then
{
// If we have enough money for 1 lot
If FreeMargin<1000 then Exit;

// Check for BUY entry signal
If IsBuying and IsSelling=False and IsClosing=False then
{
// Buy
If StopLoss>0 then
{
RealSL=Ask-StopLoss*Point;
}
If TakeProfit>0 then
{
RealTP=Ask+TakeProfit*Point;
}
SetOrder(OP_BUY,Lots,Ask, Slippage,RealSL,RealTP,RED);
Alert("ZeroCode Test System: Buying");
};

// Check for SELL entry signal
If IsSelling and IsBuying=False and IsClosing=False then
{
// Sell
If StopLoss>0 then
{
RealSL=Bid+StopLoss*Point;
}
If TakeProfit>0 then
{
RealTP=Bid-TakeProfit*Point;
}
SetOrder(OP_SELL,Lots,Bid,Slippage,RealSL,RealTP,R ED);
Alert("ZeroCode Test System: Selling");
};
};


//-------------- Coded by FXFisherman ZeroCode v1.0\

 

Im not an expert on this but I'm thinking that the best way to do this is by just opening three different metatrader platforms and I think you should be allowed to login to the same account for both.

 

gazuz thank you so much for the reply.

I will try this and report back...

 

gazuz, unfortunately this did not seem to work. I was able to log into multiple platforms with the same account just not able to utilize my advisor as described above. It still executed trades on just one currency pair. Again, thank you very much for your kind suggestion. If anyone, including gazuz, knows if there is anything else I should try please do not hesitate to let me know

 

In my opinion, metatrader 3 platform doesn't handle multiple positions in one account well, although the mql programming is not limited to open multiple positions. In demo account, it might be just fine, but in real cash account, it's a different ball game--most mt brokers must have all trade executions confirmed manually, so what if an order is refused but the return code is "ok, it's closed".

However, if you just want to test your expert on various currency pairs, then:

1. Duplicate MetaTrader folder.

2. Run the metatrader program in the new folder.

3. Open new demo account.

4. Run your expert in the currency pair your like.

5. Repeat the step 1-4 if you need to test on another pair.

Hope this helps you.

 

Scorpion thanks for your reply. MT doesn't seem to handle much very well. How does the supposed 1.9 trillion dollar a day currency market not produce a workable platform that can be programmed to execute trades automatically? It doesn't make sense. 1.9 trillion dollars adds up, doesn't it? LOL Clearly it's a broker's game. I talked to one of my preferred brokers over the phone and asked if MT was a reliable source of automatic trading - they replied 'yes - it should be', hahaha I agree. Unless ZeroCode (no offence) simply does not produce enough code to handle all of the variables needed to sustain an MA Cross stop & reverse strategy then MT is simply not an option for me. Paying for an API is also unfortunately not an option at this time. Thoughts?

 

Of course trading platforms for small traders are just like gaming platform. Because, we speculators all together is only a tiny bit in 1.9 trillion dollar a day. We most of the time play against each others within the same broker only. I guess 99.9% of 1.9 trillion exchange is traded by instituion directly with banks and banks with banks. BoJ alone regularly exchange trillions dollar worth of USDJPY in just a few weeks! And Top 100 fortune companies alone exchange trillions dollar worth directly with banks. I don't think they trade with brokers who charge them 2-3 pips spread! In brief, platform we use today either FXCM tradestation, Oanda FXTrade, or MetaTrader can be categorized as a gaming software--some people even name it gambling software!

Anyway, MetaTrader 4 is kinda reliable for multiple-position execution, coz it natively supports magic number. MQL4 can assign magic number accordingly to each trade on server and then can close them reliably. Auto trading in MT3 is absolutely not reliable.

 

Scorpion I knew I could count on you to put my arrogant attitude in its place! What you say makes a lot of sense. It still seems though that the average trader should at least have a fighting chance when it comes to autotrading. Clearly MT3 isn't reliable in this sense but perhaps I wrote off MT4 too quickly. I had read numerous reports on various forums about all the bugs which needed to be fixed in version 4 and was put off quite quickly. However, after taking your advice things seem to be working quite well. In fact I have no complaints whatsoever. Hopefully MT4 is the answer. Thanks again for your insight Scorpion - it's always welcomed.

 

Hello,

Mr Scicronys we have Ea That called EURO fx2 This is Profitable but This Direction So dengerous...Because of To depend their open order their go everywhere until back again to order and go closing.Coul you repair it so that this EA best in direction and this EA Closing to new direction and This EA don't have floating openposion in long term???Could u help to makee this EA stable and usefull.Thx so much

Indonesian Trader that called tukul love 4x....

He..he..he...

Reason: