• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 8:15am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 8:15am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

I'm looking for a MT4 coder for my Heiken Ashi EA idea 3 replies

MT4 Compiler Build prior to Build 6xxx 7 replies

Looking for EA coder (will pay) 13 replies

In need of a coder for new MT4 build 3 replies

looking for a mt4 coder who can make a pretty simple indicator 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 2
Attachments: will pay - looking for coder to update my EA for new MT4 build
Exit Attachments
Tags: will pay - looking for coder to update my EA for new MT4 build
Cancel

will pay - looking for coder to update my EA for new MT4 build

  • Post #1
  • Quote
  • First Post: May 12, 2014 11:33pm May 12, 2014 11:33pm
  •  FXForLife
  • | Joined Apr 2010 | Status: Member | 367 Posts
hi, i need the attached code updated so that it will work on the latest mt4 build.

i will gladly pay for any help.

thank you

Inserted Code
#include <stdlib.mqh>
extern int myMagic = 123;
extern double TakeProfit =500;
extern bool   PartialClosing = True;
extern int    TPDivide = 1;
extern double StopLoss =500;  
extern int    TrailingStop =0;
extern double BreakEvenStop =0;  
extern int    slippage=2;      
extern int    shift=0;            
extern double Lots = 0.10;
extern double MaximumRisk = 1.0; //
extern bool   FixedLot = true;
extern int TimeStart1=000;
extern int TimeStop1=2359;
extern int TimeStart2=0000;
extern int TimeStop2=0000;
extern int TimeStart3=0000;
extern int TimeStop3=0000;
extern int TimeStart4=0000;
extern int TimeStop4=0000;
extern int       OrderTriesNumber=25;
bool buysig,sellsig,closebuy,closesell; int lastsig,tries;
 
double LotsRisk(int StopLoss)  {
   double lot=Lots;
//---- select lot size
   if (!FixedLot && (StopLoss > 0))
      lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk*0.001/StopLoss,2);
   else
      lot=Lots;
//---- return lot size
   if(lot<0.01) lot=0.01;
   return(lot);
}
//+------------------------------------------------------------------+
//| Calculate open positions                                         |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
  {
   int buys=0,sells=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==myMagic)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }
//---- return orders volume
   if(buys>0) return(buys);
   else       return(-sells);
  }
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
void CheckForSignals(datetime tradeopenbar) {
      
      sellsig=false;
      buysig=false;
      
       if(tradeopenbar<Time[0]){
       if
            
    
                     (Close[0]>Close[50])  
                    
                    
                     {
          buysig=true;
      }
      if            
                     (Close[0]<Close[50])
                    
                     {
          sellsig=true;
      }
      
}      
      closebuy=false;
      closesell=false;
      
      if (High[0]<Low[0])                                           {  
         closebuy=true;
      }
      if (High[0]<Low[0])                                           {
         closesell=true;
      }
}
datetime CheckForOpen(datetime orderopenbar) {
   int    res,ct;
   datetime result = orderopenbar;
   ct=Hour()*100+Minute();
   if
  
   ( !((ct>=TimeStart1 && ct<TimeStop1) || (ct>=TimeStart2 && ct<TimeStop2) ||
  
       (ct>=TimeStart3 && ct<TimeStop3) || (ct>=TimeStart4 && ct<TimeStop4)) ) return(result);
      
   double takeProfit;
   double SetLots=0;
   string EAComment='';
//---- sell conditions
   if(sellsig && lastsig!=-1)  {
       res=0;
       tries=0;
        while (res<=0 && tries<OrderTriesNumber) {
          while(!IsTradeAllowed()) Sleep(5000);
            RefreshRates();
            if(TakeProfit > MarketInfo(Symbol(), MODE_STOPLEVEL))
              takeProfit = Bid-TakeProfit*Point;
            else
              takeProfit = 0;
            SetLots=LotsRisk(StopLoss);
            EAComment="TimeWave EURUSD M15";  
          res=OrderSend(Symbol(),OP_SELL,SetLots,Bid,slippage,Bid+StopLoss*Point,
                  takeProfit,EAComment,myMagic,0,DeepPink);
            if (res<0)
              Print("Error opening SELL order : ",ErrorDescription(GetLastError()));
            else
              result = Time[0]; // return this bar open time.
            tries++;
        }
      lastsig= 0;
      return(result);
   }
//---- buy conditions
   if(buysig && lastsig!=1)  {
       res=0;
       tries=0;
        while (res<=0 && tries<OrderTriesNumber) {
          while(!IsTradeAllowed()) Sleep(5000);
            RefreshRates();
            if(TakeProfit > MarketInfo(Symbol(), MODE_STOPLEVEL))
              takeProfit = Ask+TakeProfit*Point;
            else
              takeProfit = 0;
            SetLots=LotsRisk(StopLoss);
            EAComment="TimeWave EURUSD M15";  
          res=OrderSend(Symbol(),OP_BUY,LotsRisk(StopLoss),Ask,slippage,Ask-StopLoss*Point,
                  takeProfit,EAComment,myMagic,0,Yellow);
          if (res<0)
            Print("Error opening BUY order : ",ErrorDescription(GetLastError()));
          else
            result = Time[0]; // return this bar open Time
          tries++;
        }
      lastsig = 0;
      return(result);
   }
   return(result);
}
  
  
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void CheckForClose()  {
   bool bres; int tr;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;
      if(OrderMagicNumber()!=myMagic || OrderSymbol()!=Symbol()) continue;
      //---- check order type
      if(OrderType()==OP_BUY)
        {
         if (closebuy) {
            bres=false;
             tries=0;
              while (!bres && tries<OrderTriesNumber) {
               while(tr<7 && !IsTradeAllowed()) { tr++; Sleep(5000); }
               RefreshRates();
               bres=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,White);
               Sleep(3000);
                  if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
                  tries++;
               }
           }
           else
              if(PartialClosing) PartialClosingExe();
         break;
        }
      if(OrderType()==OP_SELL)
        {
         if (closesell) {
            bres=false;
             tries=0;
              while (!bres && tries<OrderTriesNumber) {
               while(tr<7 && !IsTradeAllowed()) { tr++; Sleep(5000); }
               RefreshRates();
               bres=OrderClose(OrderTicket(),OrderLots(),Ask,slippage,White);
               Sleep(3000);
                  if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
                  tries++;
               }
           }
           else
              if(PartialClosing) PartialClosingExe();
         break;
        }
     }
}
 
void BreakEvenStop() {
   bool bres;
   double StopLoss;
   if ( BreakEvenStop > 2 ) {
      for (int i = 0; i < OrdersTotal(); i++) {
         if ( OrderSelect (i, SELECT_BY_POS) == false )  continue;
         if ( OrderSymbol() != Symbol() || OrderMagicNumber() != myMagic )  continue;
         if ( OrderType() == OP_BUY ) {
            if ( (Bid < OrderOpenPrice()+BreakEvenStop*Point) )  return;
            StopLoss = OrderOpenPrice();
            if ( StopLoss > OrderStopLoss() ) {
                  bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss+4*Point, OrderTakeProfit(), 0, White);
                  Sleep(3000);
                       if (!bres) Print("Error Modifying BUY order : ",ErrorDescription(GetLastError()));
            }
         }
  
         if ( OrderType() == OP_SELL ) {
            if ( (Ask > OrderOpenPrice()-BreakEvenStop*Point) )  return;
            StopLoss = OrderOpenPrice();
            if ( StopLoss < OrderStopLoss() ) {
                  bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss-4*Point, OrderTakeProfit(), 0, White);
                  Sleep(3000);
                       if (!bres) Print("Error Modifying SELL order : ",ErrorDescription(GetLastError()));
            }
         }
      }
   }
   return;
}
void TrailingStop() {
   bool bres;
   double StopLoss;
   if ( TrailingStop > MarketInfo(Symbol(), MODE_STOPLEVEL)) {
      for (int i = 0; i < OrdersTotal(); i++) {
         if ( OrderSelect (i, SELECT_BY_POS) == false )  continue;
         if ( OrderSymbol() != Symbol() || OrderMagicNumber() != myMagic )  continue;
         if ( OrderType() == OP_BUY ) {
            if ( (Bid < OrderStopLoss()+TrailingStop*Point) )  return;
            StopLoss = Bid-TrailingStop*Point;
            if ( StopLoss > OrderStopLoss() ) {
                  bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss, OrderTakeProfit(), 0, White);
                  Sleep(3000);
                       if (!bres) Print("Error Modifying BUY order : ",ErrorDescription(GetLastError()));
            }
         }
  
         if ( OrderType() == OP_SELL ) {
            if ( (Ask > OrderStopLoss()-TrailingStop*Point) )  return;
            StopLoss = Ask+TrailingStop*Point;
            if ( StopLoss < OrderStopLoss() ) {
                  bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss, OrderTakeProfit(), 0, White);
                  Sleep(3000);
                       if (!bres) Print("Error Modifying SELL order : ",ErrorDescription(GetLastError()));
            }
         }
      }
   }
   return;
}
double RoundLots(string S, double P)
{
   double value=P;
   double MinimalLot=0;
   MinimalLot=MarketInfo(S,MODE_MINLOT);
   if(MinimalLot<=0)
      {
         RefreshRates();
         return(-1);
      }
   value=MathFloor(P/MinimalLot)*MinimalLot;
   return(value);
}
//+------------------------------------------------------------------+
//| Linear closing of position                                       |
//+------------------------------------------------------------------+
void PartialClosingExe()
{
   int Profit=0;
   if(OrderType()==OP_BUY) Profit=MathRound((Bid-OrderOpenPrice())/Point);
   if(OrderType()==OP_SELL) Profit=MathRound((OrderOpenPrice()-Ask)/Point);
   if(Profit<=0) return;
   int PipStep=MathFloor(TakeProfit/TPDivide);
   if(PipStep<1) PipStep=1;
   if(PipStep>TakeProfit) PipStep=TakeProfit;
   double LotPercent=1.00/TPDivide;
   if(LotPercent>1.00) LotPercent=1.00;
   if(TPDivide>TakeProfit && TakeProfit>0) LotPercent=1.00/TakeProfit;
   double FirstPosition=LotsRisk(StopLoss);
   double CutLots=FirstPosition*LotPercent*MathFloor(Profit/PipStep);
   CutLots=RoundLots(Symbol(),CutLots);
   if(CutLots<=0) return;
   CutLots=CutLots-(FirstPosition-OrderLots());
   if(CutLots<=0) return;
   if(OrderLots()<CutLots) CutLots=OrderLots();
   if(OrderType()==OP_BUY)
      OrderClose(OrderTicket(),CutLots,Bid,slippage,White);
   if(OrderType()==OP_SELL)
      OrderClose(OrderTicket(),CutLots,Ask,slippage,White);
      
   return;
}
void start()  {
  static datetime TradeOpenBar;
   //---- check for history and trading
   if(Bars<100 || IsTradeAllowed()==false) return;
   //---- check for signals
   CheckForSignals(TradeOpenBar);
  
   //---- calculate open orders by current symbol
   if (CalculateCurrentOrders(Symbol())==0)
      TradeOpenBar = CheckForOpen(TradeOpenBar);
   else
      CheckForClose();
      
   BreakEvenStop();
   TrailingStop();
}
//+------------------------------------------------------------------+
  • Post #2
  • Quote
  • Edited 8:53am May 13, 2014 3:00am | Edited 8:53am
  •  fxdaytrader_
  • Joined Jan 2011 | Status: UberTroll | 1,847 Posts
attached the .ex4, copy it to your indicators-folder (the .ex4 only, not a mq4!), I did some modifications also (added option to adjust pips/points stuff, changed some variabletypes from int to double, removed the various sleep-commands, added checks for tradecontextbusy, etc.).
Attached File(s)
File Type: ex4 TimeWave EA.EURUSD M15.mod.ex4   12 KB | 199 downloads
PM me with coding requests and I'll probably put you on my ignore list
 
 
  • Post #3
  • Quote
  • Last Post: Edited 10:20am May 13, 2014 9:42am | Edited 10:20am
  •  fxdaytrader_
  • Joined Jan 2011 | Status: UberTroll | 1,847 Posts
attached v1.1, I made the signalcandles external and updated the ea a bit (e.g. with the tradinghours-function by steve hopwood and baluda)
Attached File(s)
File Type: ex4 TimeWave EA.EURUSD M15.mod v1.1.ex4   22 KB | 219 downloads
PM me with coding requests and I'll probably put you on my ignore list
 
 
  • Platform Tech
  • /
  • will pay - looking for coder to update my EA for new MT4 build
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023