Sequential orders open EA

 

Dear guys,

Some traders exhibits some tradings result (Account summary) ,I see that they use a EA and their EA opens a lot of orders in a minute (buy/sell).I am looking for such kind Expert Adviser.If you help me I will be very glad.

Regards

 

no reply???? (

 

Making the EA open a lot of orders is probably the easiest thing. Much harder is what is the logic of it? When should it open and when not? If you disregard all that then use a simple code like this :

//------------------------------------------------------------------

//

//------------------------------------------------------------------

extern int MagicNumber = 1111;

extern int MaxNumberOfOrders = 50;

extern int StopLoss = 0;

extern int TrailStopLoss = 10;

extern int TakeProfit = 50;

extern int OrderMaximalDuration = 60;

extern double OrderLotSize = 0.1;

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init() { return(0); }

int deinit() { return(0); }

//

//

//

//

//

int start()

{

double pipMultiplier = 0; if (Digits==3 || Digits==5) pipMultiplier = 10;

//

//

//

//

//

for (int k=OrdersTotal()-1; k>=0; k--)

{

if (!OrderSelect(k,SELECT_BY_POS)) continue;

if (OrderSymbol() !=Symbol()) continue;

if (OrderMagicNumber()!=MagicNumber) continue;

int orderType = OrderType();

int ticket = OrderTicket();

//

//

//

//

//

bool shouldClose = false;

bool orderCloseTime = OrderOpenTime()+OrderMaximalDuration*60;

if (IsTesting())

shouldClose = (orderCloseTime<=Time[0]);

else shouldClose = (orderCloseTime<=TimeCurrent());

if ( shouldClose )

{

double closePrice = Bid;

if (orderType == OP_SELL) closePrice = Ask;

for (int c=0; c<3; c++)

{

if (OrderClose(ticket,OrderLots(),closePrice,0,CLR_NONE)) break;

Sleep(150);

}

if (c<3) continue;

}

//

//

//

//

//

double stopLoss = 0;

double takeProfit = 0;

double trailStopLoss = 0;

if (StopLoss>0 && OrderStopLoss()==0)

{

if (orderType == OP_BUY) stopLoss = OrderOpenPrice()-StopLoss*pipMultiplier*Point;

if (orderType == OP_SELL) stopLoss = OrderOpenPrice()+StopLoss*pipMultiplier*Point;

}

if (TakeProfit>0 && OrderTakeProfit()==0)

{

if (orderType == OP_BUY) takeProfit = OrderOpenPrice()+TakeProfit*pipMultiplier*Point;

if (orderType == OP_SELL) takeProfit = OrderOpenPrice()-TakeProfit*pipMultiplier*Point;

}

if (TrailStopLoss>0 && OrderProfit()>0)

{

if (orderType==OP_BUY)

{

trailStopLoss = Bid-TrailStopLoss*pipMultiplier*Point; if (trailStopLoss<=OrderStopLoss() || trailStopLoss<=OrderOpenPrice()) trailStopLoss = 0;

}

if (orderType==OP_SELL)

{

if (OrderStopLoss()==0)

double currentStopLoss = OrderOpenPrice();

else currentStopLoss = OrderStopLoss();

trailStopLoss = Ask+TrailStopLoss*pipMultiplier*Point; if (trailStopLoss>=currentStopLoss || trailStopLoss>=OrderOpenPrice()) trailStopLoss = 0;

}

}

if (trailStopLoss!=0) stopLoss = trailStopLoss;

//

//

//

//

//

bool shouldModify = ((stopLoss!=0 && !compare(OrderStopLoss(),stopLoss)) || (takeProfit!=0 && !compare(OrderTakeProfit(),takeProfit)));

if ( shouldModify )

{

if (stopLoss == 0) stopLoss = OrderStopLoss();

if (takeProfit == 0) takeProfit = OrderTakeProfit();

for (c=0; c<3; c++) if (OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(stopLoss,Digits),NormalizeDouble(takeProfit,Digits),0,CLR_NONE)) break;

}

}

//

//

//

//

//

int ordersOpened=0;

for (k=OrdersTotal()-1; k>=0; k--)

if (OrderSelect(k,SELECT_BY_POS) && OrderMagicNumber()== MagicNumber && OrderSymbol() == Symbol()) ordersOpened++;

if (ordersOpened < MaxNumberOfOrders)

{

bool shouldBuy = (MathRand()%2==0);

if ( shouldBuy )

OrderSend(Symbol(),OP_BUY ,OrderLotSize,Ask,0,0,0,NULL,MagicNumber,0);

else OrderSend(Symbol(),OP_SELL,OrderLotSize,Bid,0,0,0,NULL,MagicNumber,0);

}

//

//

//

//

//

return(0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

bool compare(double first, double second)

{

return (NormalizeDouble(first,Digits)==NormalizeDouble(second,Digits));

}

It will open up to MaxNumberOfOrders randomly (one per each tick - it depends on a random number generator if it is going to be a buy or a sell) and will keep them opened for OrderMaximalDuration minutes. It even can place stop los, take profit and traling stop loss. So it is up to your preferences (and your account size) how many orders do you wish to be opened

enigmaman:
no reply???? (
Files:
testea.mq4  5 kb
 

sequential ea

i got it

.

 

mladen,

thank you so much I will investigate (for learning ) and will test.By the way ,I belive in to EA's run because Forex trading needs 3 main factor:1-knowledge, 2-Disciplines, 3-Patient but if you use a good Ea you dont need 2 and 3 (most biggest failure reasons) and so you eliminate these.To learn coding I have only coders guru small books not more,so I mostly in a dark room,with time I will learn (I hope)

Thanks again

 

this is what sequential does

enigmaman:
mladen,

thank you so much I will investigate (for learning ) and will test.By the way ,I belive in to EA's run because Forex trading needs 3 main factor:1-knowledge, 2-Disciplines, 3-Patient but if you use a good Ea you dont need 2 and 3 (most biggest failure reasons) and so you eliminate these.To learn coding I have only coders guru small books not more,so I mostly in a dark room,with time I will learn (I hope)

Thanks again
Files: