Posted By: PriNova
MT4 to lite-C - 11/06/12 12:52
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:
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
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:
Code:
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
Code:
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(); } }