Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Quad), 454 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
MT4 to lite-C #410623
11/06/12 12:52
11/06/12 12:52
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
P
PriNova Offline OP
Junior Member
PriNova  Offline OP
Junior Member
P

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:



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();
	}
	
}


Re: MT4 to lite-C [Re: PriNova] #410626
11/06/12 13:13
11/06/12 13:13
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Zorro uses Ask prices, but that is just a convention and does not affect strategies.

Your system can never trade because High(0) can never be lower than Low(1) on hourly bars. Currencies are traded 24 hours, so you would only get trades with this system when you used price data with gaps or missing prices, and then the result is random. The price data that we deliver with Zorro reflects the 24 hours market and has no gaps.

The original idea of this system was possibly using the open and close hours of a certain stock exchange for determining High or Low. That would make sense, but only when trading once per day, not once per hour.

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
P
PriNova Offline OP
Junior Member
PriNova  Offline OP
Junior Member
P

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.
Re: MT4 to lite-C [Re: PriNova] #410636
11/06/12 15:13
11/06/12 15:13
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Originally Posted By: PriNova
does this mean from your answer, that close(1) == open(0) always?

Almost. Price quotes arrive in milliseconds and come from many different sources, so they are mostly uncorrelated. Thus any difference between close(1) and open(0) is negligible.

Still, when your script compared close(1) with open(0), it could theoretically generate some trades, which would be of course totally random. But you compare high(1) with low(0) in hour bars, and that occurrence has zero probability in real price data. It would mean that of the millions of price quotes that arrive in an hour, no single quote would be lower or higher than the close or open. That just does not happen.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1