Merging orders
  #1 (permalink)  
Old 07-30-2005, 12:02 PM
TraderSeven's Avatar
Sophomore
 
Join Date: Jun 2005
Posts: 86
Thanks: 0
Thanked 1 Time in 1 Post
TraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of light
Default Merging orders

MT4 seems to have problems with quickly entering trades.
My EA picks up 1 new position every hours at most.
That won't overflooding the servers I guess


But when I open a new trade all open positions get instantly modified (ProfitTarget and StopLoss)
This could be up to 10 positions so that probebly gives problems/errors.

All open positions are modified to the same TakeProfit and StopLoss values.
So my question is can I merge 10 seperate 1 lot orders into 1 10 lot order.
That way I only have to send 1 order instead of 10.
__________________
If your system fails just swap long & short :whistling
Reply With Quote
  #2 (permalink)  
Old 07-30-2005, 06:55 PM
Ravique's Avatar
Super Moderator
 
Join Date: Sep 2004
Posts: 404
Thanks: 2
Thanked 1 Time in 1 Post
Ravique is a name known to allRavique is a name known to allRavique is a name known to allRavique is a name known to allRavique is a name known to allRavique is a name known to all
Send a message via Yahoo to Ravique
Default

I don`t know about merging orders , but are you talking about your 20`s expert?
__________________
Regards,
Ravique
Reply With Quote
  #3 (permalink)  
Old 07-30-2005, 07:57 PM
TraderSeven's Avatar
Sophomore
 
Join Date: Jun 2005
Posts: 86
Thanks: 0
Thanked 1 Time in 1 Post
TraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of light
Default

Nope about my great Firebird expert noone seems to care about
__________________
If your system fails just swap long & short :whistling
Reply With Quote
  #4 (permalink)  
Old 07-31-2005, 04:41 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,991
Thanks: 125
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

I think MT has no merging functionality after searching the EA dictionary. Anyway, are all trades are opened by the same expert?
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
  #5 (permalink)  
Old 07-31-2005, 09:09 AM
TraderSeven's Avatar
Sophomore
 
Join Date: Jun 2005
Posts: 86
Thanks: 0
Thanked 1 Time in 1 Post
TraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of light
Default

Yes, all in the same expert.
__________________
If your system fails just swap long & short :whistling
Reply With Quote
  #6 (permalink)  
Old 07-31-2005, 09:51 AM
Ravique's Avatar
Super Moderator
 
Join Date: Sep 2004
Posts: 404
Thanks: 2
Thanked 1 Time in 1 Post
Ravique is a name known to allRavique is a name known to allRavique is a name known to allRavique is a name known to allRavique is a name known to allRavique is a name known to all
Send a message via Yahoo to Ravique
Default

Firebird 0,50 ? What are the results so far ?
__________________
Regards,
Ravique
Reply With Quote
  #7 (permalink)  
Old 07-31-2005, 12:27 PM
TraderSeven's Avatar
Sophomore
 
Join Date: Jun 2005
Posts: 86
Thanks: 0
Thanked 1 Time in 1 Post
TraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of lightTraderSeven is a glorious beacon of light
Default

Firebird v0.55 actually.
Results are very promissing (as ever).
Just adding all kind of setting, improvements and stuff.
__________________
If your system fails just swap long & short :whistling
Reply With Quote
  #8 (permalink)  
Old 12-10-2005, 02:19 AM
Freshman
 
Join Date: Nov 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
lowphat is on a distinguished road
Default

Quote:
Originally Posted by TraderSeven
Nope about my great Firebird expert noone seems to care about
I like FB i have learned everything i know about envelopes from it
BTW
Can anyone show me how to add close logic to firebird?
I have tried to copy closing code out of other EA's to no avail
Maybe a Bool to enable or disable close logic. if close logic is enabled then im guessing stoploss and take profit can be set to 9999 if no one wanted to use it. if i can figure out the close logic then i will start messing with using a MA or some indicator for testing to see if i can get the position to ride the bigger trend. maybe something like
Close Sell if osMA prev<0 && osMAcurrent>0
Close Open if osMA prev>0 && osMAcurrent<0
I have some MA cross Closing ideas also



------




Code:
//+-----------------------------------------------------------------------------+ //| Firebird v0.61.01 - MA envelope exhaustion system | //+-----------------------------------------------------------------------------+ #property copyright "Copyright © 2005, TraderSeven" #property link "TraderSeven@gmx.net" // \\|// +-+-+-+-+-+-+-+-+-+-+-+ \\|// // ( o o ) |T|r|a|d|e|r|S|e|v|e|n| ( o o ) // ~~~~oOOo~(_)~oOOo~~~~ +-+-+-+-+-+-+-+-+-+-+-+ ~~~~oOOo~(_)~oOOo~~~~ // Firebird calculates a 10 day SMA and then shifts it up and down 2% to for a channel. // For the calculation of this SMA either close (more trades) or H+L (safer trades) is used. // When the price breaks a band a postion in the opposite of the current trend is taken. // If the position goes against us we simply open an extra position to average. // 50% of the trades last a day. 45% 2-6 days 5% longer or just fail. // //01010100 01110010 01100001 01100100 01100101 01110010 01010011 01100101 01110110 01100101 01101110 //----------------------- USER INPUT extern int MA_length = 10; extern int MA_timeframe = 30; // hdb did I add this ? lol extern int MAtype=0;//0=close, 1=HL extern double Percent = 0.1; extern int TradeOnFriday =1; // >0 trades on friday extern int slip = 100;//exits only extern double Lots = 1; extern int TakeProfit = 30; extern int Stoploss = 2000;// total loss on all open positions in pips //extern double TrailingStop = 5; extern int PipStep = 30;//if position goes this amount of pips against you add another. extern double IncreasementType =0;//0=just add every PipStep, >0 =OrdersToal()^x *Pipstep extern double MagicNumber=12345; double Stopper=0; double KeepStopLoss=0; double KeepAverage; double dummy; double spread=0; double CurrentPipStep; int OrderWatcher=0; //----------------------- MAIN PROGRAM LOOP int start() { double PriceTarget; double AveragePrice; int OpeningDay; //----------------------- CALCULATE THE NEW PIPSTEP CurrentPipStep=PipStep; if(IncreasementType>0) { CurrentPipStep=MathSqrt(OrdersTotal())*PipStep; CurrentPipStep=MathPow(OrdersTotal(),IncreasementType)*PipStep; } //----------------------- int Direction=0;//1=long, 11=avoid long, 2=short, 22=avoid short if (Day()!=5 || TradeOnFriday >0) { int cnt=0, total; int myTotal =0; // hdb total=OrdersTotal(); if(total==0) OpeningDay=DayOfYear(); for(cnt=0;cnt<total;cnt++) { if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) ) // hdb - only symbol and magic { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); double LastPrice=OrderOpenPrice(); myTotal = myTotal +1; // hdb - count of relevant trades } } // OrderSelect(total, SELECT_BY_POS, MODE_TRADES); // removed hdb ///////////////////////////////////////////////////////////////////////////////////////// // BACKTESTER FIX: DO NOT PLACE AN ORDER IF WE JUST CLOSED // AN ORDER WITHIN Period() MINUTES AGO ///////////////////////////////////////////////////////////////////////////////////////// datetime orderclosetime; string rightnow; int rightnow2; int TheHistoryTotal=HistoryTotal(); int difference; int flag=0; for(cnt=0;cnt<TheHistoryTotal;cnt++) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==true) { if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) ) // hdb - only symbol and magic { orderclosetime=OrderCloseTime(); rightnow=Year()+"-"+Month()+"-"+Day()+" "+Hour()+":"+Minute()+":"+Seconds(); rightnow2=StrToTime(rightnow); difference=rightnow2-orderclosetime; if(Period()*60*2>difference) { // At least 2 periods away! flag=1; // Throw a flag break; } } } } ///////////////////////////////////////////////////////////////////////////////////////// if(flag!=1) { //----------------------- ENTER POSITION BASED ON OPEN OrderWatcher=0; total=OrdersTotal(); OrderSelect(total-1, SELECT_BY_POS, MODE_TRADES); LastPrice=OrderOpenPrice(); //Comment("LastPrice",LastPrice); if(MAtype==0) { double myMA =iMA(NULL,MA_timeframe,MA_length,0,MODE_SMA,PRICE_OPEN,0); // Print(" Top, Bid ",myMA*(1+Percent/100)," ",Bid); // if((myMA*(1+Percent/100))<Bid) Print(" Top, Bid ",myMA*(1+Percent/100)," ",Bid); if((myMA*(1+Percent/100))<Bid && Direction!=22 && (Bid>=(LastPrice+(CurrentPipStep*Point))||total==0)) // Go SHORT -> Only sell if >= 30 pips above previous position entry { OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),0,0,Red); OrderWatcher=1; Direction=2; } if((myMA*(1-Percent/100))>Ask && Direction!=11 && (Ask<=(LastPrice-(CurrentPipStep*Point))||total==0)) // Go LONG -> Only buy if >= 30 pips below previous position entry { OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),0,0,Blue); OrderWatcher=1; Direction=1; } } //----------------------- ENTER POSITION BASED ON HIGH/LOW if(MAtype==1) { if((iMA(NULL,MA_timeframe,MA_length,0,MODE_SMA,PRICE_HIGH,0)*(1+Percent/100))<Bid && Direction!=22 && (Bid>=(LastPrice+(CurrentPipStep*Point))||total==0)) // Go SHORT -> Only sell if >= 30 pips above previous position entry { OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),0,0,Red); OrderWatcher=1; Direction=2; } if((iMA(NULL,MA_timeframe,MA_length,0,MODE_SMA,PRICE_LOW,0)*(1-Percent/100))>Ask && Direction!=11 && (Ask<=(LastPrice-(CurrentPipStep*Point))||total==0)) // Go LONG -> Only buy if >= 30 pips below previous position entry { OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),0,0,Blue); OrderWatcher=1; Direction=1; } } } // end of flag test //----------------------- CALCULATE AVERAGE OPENING PRICE total=OrdersTotal(); AveragePrice=0; int myOrderType = -1; // hdb myTotal = 0; // hdb - count of relevant trades if(total>1 && OrderWatcher==1) { for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) ) // hdb - only symbol and magic { AveragePrice=AveragePrice+OrderOpenPrice(); myOrderType = OrderType(); // hdb - keep order type myTotal = myTotal +1; // hdb - count of relevant trades } } AveragePrice=AveragePrice/MathMax(myTotal,1); // hdb myTotal } //----------------------- RECALCULATE STOPLOSS & PROFIT TARGET BASED ON AVERAGE OPENING PRICE // OrderSelect(0, SELECT_BY_POS, MODE_TRADES); // hdb removed if(myOrderType==OP_BUY && OrderWatcher==1 && myTotal>1) // Calculate profit/stop target for long { PriceTarget=AveragePrice+(TakeProfit*Point); Stopper=AveragePrice-(((Stoploss*Point)/myTotal)); } if(myOrderType==OP_SELL && OrderWatcher==1 && myTotal>1) // Calculate profit/stop target for short { PriceTarget=AveragePrice-(TakeProfit*Point); Stopper=AveragePrice+(((Stoploss*Point)/myTotal)); } Comment("AveragePrice", AveragePrice); //----------------------- IF NEEDED CHANGE ALL OPEN ORDERS TO THE NEWLY CALCULATED PROFIT TARGET //if(OrderWatcher==1 && myTotal>1)// check if average has really changed //if(OrderWatcher==1 && myTotal>1)// check if average has really changed // { total=OrdersTotal(); for(cnt=0;cnt<total;cnt++) { if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) ) // hdb - only symbol and magic { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); OrderModify(OrderTicket(),0,Stopper,PriceTarget,0,Yellow);// set all positions to averaged levels } } // } //Comment("PriceTarget: ",PriceTarget," AveragePrice: ",AveragePrice," Total: ",total); //----------------------- KEEP TRACK OF STOPLOSS TO AVOID RUNAWAY MARKETS // Sometimes the market keeps trending so strongly the system never reaches it's target. // This means huge drawdown. After stopping out it falls in the same trap over and over. // The code below avoids this by only accepting a signal in teh opposite direction after a SL was hit. // After that all signals are taken again. Luckily this seems to happen rarely. if (OrdersTotal()>0) { myOrderType = -1; // hdb myTotal = 0; // hdb - count of relevant trades total=OrdersTotal(); for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) ) // hdb - only symbol and magic { KeepStopLoss=OrderStopLoss(); AveragePrice=AveragePrice+OrderOpenPrice(); myTotal = myTotal +1; // hdb - count of relevant trades myOrderType = OrderType(); // hdb - keep order type } } AveragePrice=AveragePrice/MathMax(myTotal,1); // hdb myTotal KeepAverage=AveragePrice; Direction =0; if(myOrderType==OP_BUY) { Direction=1; } //long else { if (myOrderType==OP_SELL) Direction=2; }//short } if(KeepStopLoss!=0) { spread=MathAbs(KeepAverage-KeepStopLoss)/2; dummy=(Bid+Ask)/2; if (KeepStopLoss<(dummy+spread) && KeepStopLoss>(dummy-spread)) { // a stoploss was hit if(Direction==1) Direction=11;// no more longs if(Direction==2) Direction=22;// no more shorts } KeepStopLoss=0; } } } //----------------------- TO DO LIST // 1st days profit target is the 30 pip line *not* 30 pips below average as usually. -----> Day() // Trailing stop -> trailing or S/R or pivot target // Realistic stop loss // Avoid overly big positions // EUR/USD 30 pips / use same value as CurrentPipStep // GBP/CHF 50 pips / use same value as CurrentPipStep // USD/CAD 35 pips / use same value as CurrentPipStep //----------------------- OBSERVATIONS // GBPUSD not suited for this system due to not reversing exhaustions. Maybe use other types of MA // EURGBP often sharp reversals-> good for trailing stops? // EURJPY deep pockets needed.



Quote:
Originally Posted by TraderSeven
Firebird v0.55 actually.
Results are very promissing (as ever).
Just adding all kind of setting, improvements and stuff.
Attached Files
File Type: mq4 Firebird_v.61.01__ea_.mq4 (10.7 KB, 55 views)
EA Shark +1064% Return
Stock Market Crash? No Problem!
We Are Making Profits As Usual. More Info
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Does a NDD Actually Work? EFX_justin General Trading Talk 1 09-07-2006 05:50 AM
Closing Pending Orders Rastarr MetaTrader and ZeroCode 0 06-08-2005 12:52 AM


All times are GMT. The time now is 05:17 PM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0

Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now

Main Menu

Economic Forecast