1 registered members (Quad),
454
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
MT4 to lite-C
#410623
11/06/12 12:52
11/06/12 12:52
|
Joined: Sep 2012
Posts: 74 Niedersachsen, Germany
PriNova
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
|
Hello Zorro's another issue i have is, that i'm using a profitable MT4 EA and converted it into lite-c. But the results are far from similar. this is the MT$ EA:
extern double Lots=0.1;
extern int Symb.magic=9001,
nORD.Buy = 5, // max buy orders
nORD.Sell = 5; // max sell orders
//----
double PRC.Buy,
PRC.Sell;
int ord.ticket,
nORDER,
ORD.Buy,
ORD.Sell,
max.ORD = 1, // max orders at one bar
Slippage=10;
string Name_Expert="Simple KISS";
bool Signal.Bars,
ORD.Close.Buy,
ORD.Close.Sell,
Signal.Buy,
Signal.Sell;
//+------------------------------------------------------------------------------------+
int init() {
Signal.Bars=Bars;
ORD.Close.Buy=true;
ORD.Close.Sell=true;
return(0);
}
//+------------------------------------------------------------------------------------+
void deinit() {
Comment("");
}
//+------------------------------------------------------------------------------------+
int start() {
if(AccountBalance()<1000) return(0);
Signal.Sell=false;
Signal.Buy=false;
if(OrdersTotal()==0) {
Signal.Bars=Bars;
ORD.Close.Buy=true;
ORD.Close.Sell=true;
ORD.Buy=0;
ORD.Sell=0;
}
nORDER=OrdersTotal();
//+---------------------------------------------------------------------------------+
// BUY Signals
//+---------------------------------------------------------------------------------+
if(true
&& High[0]<iLow(NULL,0,1)
&& ORD.Buy<nORD.Buy
//.........................................Filters...................................
&& true // empty filter: passes all signals
) {
//----
Signal.Buy=true;
}
//+---------------------------------------------------------------------------------+
// SELL Signals
//+---------------------------------------------------------------------------------+
if(true
&& Low[0]>iHigh(NULL,0,1)
&& ORD.Sell<nORD.Sell
//.........................................Filters...................................
&& true // empty filter: passes all signals
) {
//----
Signal.Sell=true;
}
//+---------------------------------------------------------------------------------+
if(ORD.Close.Buy==false) StopBuy(Symb.magic); // close orders
if(ORD.Close.Sell==false) StopSell(Symb.magic); // close orders
//+---------------------------------------------------------------------------------+
// Trade: open several orders inside one bar
//+---------------------------------------------------------------------------------+
if (nORDER<max.ORD) {
if (Signal.Buy) {
OpenBuy(Symb.magic);
return(0);
}
if (Signal.Sell) {
OpenSell(Symb.magic);
return(0);
}
}
//+---------------------------------------------------------------------------------+
// Trade: Open one order inside one bar
//+---------------------------------------------------------------------------------+
if (nORDER>=max.ORD) {
if (Signal.Buy && Signal.Bars<Bars) {
OpenBuy(Symb.magic);
return(0);
}
if (Signal.Sell && Signal.Bars<Bars) {
OpenSell(Symb.magic);
return(0);
}
}
return (0);
}
//+------------------------------------------------------------------------------------+
void OpenBuy(int Symbol.magic) {
ORD.Close.Buy=true;
ORD.Close.Sell=false;
if(ORD.Buy>=1 && Ask>PRC.Buy-5*Point) return(0);
ord.ticket=OrderSend
(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,Name_Expert,Symbol.magic,0,Blue);
if(ord.ticket<0) {
Print("Ticket ",ord.ticket," Error",GetLastError());
return(0);
}
PRC.Buy=Ask;
Signal.Bars=Bars;
ORD.Buy++;
ORD.Sell=0;
}
//+------------------------------------------------------------------------------------+
void OpenSell(int Symbol.magic) {
ORD.Close.Sell=true;
ORD.Close.Buy=false;
if(ORD.Sell>=1 && Bid<PRC.Sell+5*Point) return(0);
ord.ticket=OrderSend
(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,Name_Expert,Symbol.magic,0,Red);
if(ord.ticket<0) {
Print("Ticket ",ord.ticket," Error",GetLastError());
return(0);
}
PRC.Sell=Bid;
Signal.Bars=Bars;
ORD.Sell++;
ORD.Buy=0;
}
//+------------------------------------------------------------------------------------+
void StopBuy(int Symbol.magic) {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Symbol.magic) {
if (OrderType()==OP_BUY) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue);
}
}
}
}
}
//+------------------------------------------------------------------------------------+
void StopSell(int Symbol.magic) {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Symbol.magic) {
if (OrderType()==OP_SELL) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red);
}
}
}
}
}
//+------------------------------------------------------------------------------------+
the entry-signal is very simple: LONG: High[0] < Low[1] SHORT: Low[0] > High[1] exit if opposite signal occure. Max open trades are 5 per direction Simply spoken, go Long if, open of actual candle is higher then close of last candle and last candle has no High-Wick and go short if open of actual candle is lower then close of last candle and last candle has no Low-Wick Here is the lite-c code for this, but it opens only one trade and. why is this? I heard that zorro is using Ask-Prices instead of Bid-Prices could this be the problem
function run()
{
set(TICKS);
// StartDate = 20100101;
BarPeriod = 60;
if( priceLow(0) > priceHigh(1) )
{
exitLong();
if (numShort() <5) enterShort();
}
if( priceHigh(0) < priceLow(1) )
{
exitShort();
if (numLong() < 5) enterLong();
}
}
|
|
|
Re: MT4 to lite-C
[Re: jcl]
#410633
11/06/12 13:41
11/06/12 13:41
|
Joined: Sep 2012
Posts: 74 Niedersachsen, Germany
PriNova
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
|
yes, it could. High(0) is lower Low(1) if candle(1) has no low-wick so that Low(1)==Close(1) and the new candle Open(0) opens lower then the close of candle(1). this often happens with momentum-candles. they close without wick/shadow and opens lower/higher 1 Tick and rally/plunge with extended momentum
or with another expression: if (open(0) < close(1)) and (Low(1) == Close(1))
and as a retail-trader we have gaps between friday close and sunday open. this could sometimes in very volatile markets be 30 Pips and more.
does this mean from your answer, that close(1) == open(0) always?
Last edited by PriNova; 11/06/12 13:43.
|
|
|
|