need help to modify ea

To add comments, please log in or register
32025073
13
32025073  

hi,

i am not really good in programming but i have developed one ea using free online ea generator. the ea work well as per my expectation by opening an order when condition meet and close when hit tp i  set. however this ea only open one order when condition meet and will not open another order again on the same pair event though condition meet until the previous order is closed or hit tp.

i need someone help to modify this ea so that it will continue opening an order every time the condition meet either buy or sell regardless how many orders are still floating on the same pair.



i need help or guide on modifying the ea so that it can:

  1. open 5 orders at once when condition is met either buy or sell.
  2. open another 5 orders when the next condition is met again regardless buy or sell on the same pair
  3. keep opening 5 orders  at once every time condition is meet again regardless buy or sell or the previous order has been closed or still open.
  4. add a function at expert properties that can choosing either just "open buy" or "open sell" or "both"


attached is my ea file.

Files:
Sergey Golubev
Moderator
114272
Marco vd Heijden
Moderator
12714
Marco vd Heijden  
//+------------------------------------------------------------------+
//                        DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//
//                   Copyright ©2011, ForexEAdvisor.com
//                 ForexEAdvisor Strategy Builder version 0.2
//                        http://www.ForexEAdvisor.com 
//
// THIS EA CODE HAS BEEN GENERATED USING FOREXEADVISOR STRATEGY BUILDER 0.2 
// on: 5/19/2016 5:22:02 PM
// Disclaimer: This EA is provided to you "AS-IS", and ForexEAdvisor disclaims any warranty
// or liability obligations to you of any kind. 
// UNDER NO CIRCUMSTANCES WILL FOREXEADVISOR BE LIABLE TO YOU, OR ANY OTHER PERSON OR ENTITY,
// FOR ANY LOSS OF USE, REVENUE OR PROFIT, LOST OR DAMAGED DATA, OR OTHER COMMERCIAL OR
// ECONOMIC LOSS OR FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, STATUTORY, PUNITIVE,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES WHATSOEVER RELATED TO YOUR USE OF THIS EA OR 
// FOREXEADVISOR STRATEGY BUILDER     
// Because software is inherently complex and may not be completely free of errors, you are 
// advised to verify this EA. Before using this EA, please read the ForexEAdvisor Strategy Builder
// license for a complete understanding of ForexEAdvisor' disclaimers.  
// USE THIS EA AT YOUR OWN RISK. 
//  
// Before adding this expert advisor to a chart, make sure there are NO
// open positions.
//                      DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//+------------------------------------------------------------------+


extern int MagicNumber=10001;
extern double Lots =0.01;
extern double StopLoss=0;
extern double TakeProfit=10;
extern int TrailingStop=0;
extern int Slippage=3;
extern bool AllowOnlyOneOpenedOrder=true;
bool dummy;
//+------------------------------------------------------------------+
//    expert start function
//+------------------------------------------------------------------+
int start()
{
  double MyPoint=Point;
  if(Digits==3 || Digits==5) MyPoint=Point*10;
  
  double TheStopLoss=0;
  double TheTakeProfit=0;

     int result=0;
     if((iRSI(NULL,0,3,PRICE_CLOSE,0)<10)&&(iRSI(NULL,0,20,PRICE_CLOSE,0)>35)) // Here is your open buy rule
     {
        result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
        if(result>0)
        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
         dummy=OrderSelect(result,SELECT_BY_TICKET);
         dummy=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
        }
        return(0);
     }
     if((iRSI(NULL,0,3,PRICE_CLOSE,0)>90)&&(iRSI(NULL,0,20,PRICE_CLOSE,0)<65)) // Here is your open Sell rule
     {
        result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
        if(result>0)
        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
         dummy=OrderSelect(result,SELECT_BY_TICKET);
         dummy=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
        }
        return(0);
     }

  
  for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
      dummy=OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   
         OrderSymbol()==Symbol() &&
         OrderMagicNumber()==MagicNumber 
         )  
        {
         if(OrderType()==OP_BUY)  
           {
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
                    {
                     dummy=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else 
           {
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     dummy=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
   return(0);
}

int TotalOrdersCount()
{
   if (!AllowOnlyOneOpenedOrder) return(0);
  int result=0;
  for(int i=0;i<OrdersTotal();i++)
  {
     dummy=OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
     if (OrderMagicNumber()==MagicNumber) result++;

   }
  return (result);
}
William Roeder
20214
William Roeder  

32025073:

i have developed one ea using free online ea generator.

i need someone help to modify this ea

EA builder, fxDreema, EATree, FxPro Quant, MQL5 Wizard, etc. are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.
  • Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
    If we tell you what you need, you can't code it.
    If we give you the code, you don't know how to integrate it into yours.
    We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

  • EA builder makes bad code counting up while closing multiple orders.
    EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
    EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
    EA builder makes bad code, not adjusting for ECN brokers. (pre-Build 500)
    EA builder makes bad code, not checking return codes.
    EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
Muhammad Musa
161
Muhammad Musa  

Hi All,

I have this EA, but I cannot get it to work on an ECN broker platform. Please can anyone help?

Thanks


Regards

MM

Files:
William Roeder
20214
William Roeder  

Muhammad Musa: I have this EA, but I cannot get it to work on an ECN broker platform. Please can anyone help?

  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.
  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
  3. Check your return codes for errors, report them. Print your call's variables including Bid/Ask/Price/Lots including _LastError and find out why.
Muhammad Musa
161
Muhammad Musa  
whroeder1:

Thanks for replying, and apologies f the rather unclear post

The code simply wont place an order on an ECN broker's platform.

I didn't write the code my self, but paid for it. However, it appears it will not work on an ECN broker's platform because the code is programmed to open an order  with SL and TP at the same time.

I don't know how to modify the EA so that will open the trade first, then modify it with SL and TP immediately after.

thanks

William Roeder
20214
William Roeder  
Muhammad Musa However, it appears it will not work on an ECN broker's platform because the code is programmed to open an order  with SL and TP at the same time.
  1. Don't double post!
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. TP/SL on OrderSend has been fine for years.
              Build 500 2013.05.09 № 9
              Need help me mql4 guru add take profit to this EA - Take Profit - MQL4 and MetaTrader 4 - MQL4 programming forum
To add comments, please log in or register