You didn't post a topic yet. Let us show you how to make your first topic and upload your favorite forex robot. Guide me

Skip to forum content

Quick Login / Register with Facebook Account!

Login with Facebook

Login with Username and Password!

     Username:       Password:  Login

Register  |  Forgot Password?

 

The latest topics with attached files (Forex robots, Forex Indicators, etc..)

Forums in this category with details of Replies, Views, last post

Hide

Recommended by Forum Admin!

Try your Forex Robot with a small deposit, with leverage 1:3000 on ZERO Spread Forex account!


Search options (Page 15 of 86)

Scalper → ► MT4talk - FREE Forex Robots and more... → Search results

Pages Previous 1 13 14 15 16 17 86 Next

Perform new search

Posts found: 141 to 150 of 857

Guys, I tested this EA a lot, and just like any scalper EA, you won't make no money in raw spread real accounts due to the slippage and broker commission. You may have a chance if you strike a good deal with your broker and is able to reach a trading condition with a very deep liquidity pool and a very low commission per round lot (Less than 2.5 USD!).

Regards,
John

142

(1 replies, posted in Forex Tutorials.)

Wehave to remember that in the forex markets investors trade one currency for another. I am trading on this industry with a reliable broker called Circle Markets, who got brilliant educational setup that got everything you need while their expert’s analysis, insights and all that helps one working with ease and confident. I am scalper and I can follow all trading styles with them. I always feel secure and comfortable when scalping practically.

scalper trial 1 to be used in 1, 2, 5 min interval

//+------------------------------------------------------------------+
//                        DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//
//                   Copyright ©2017, https://mt4talk.com
//                     MT4talk Expert Advisor Generator
//                        https://mt4talk.com/eagenerator/
//
// THIS EXPERT ADVISOR (EA) HAS BEEN GENERATED USING MT4talk EA GENERATOR. 
// 
// Disclaimer: This EA is provided to you "AS-IS", and MT4talk disclaims any warranty
// or liability obligations to you of any kind. 
//
// FREE EA LICENSE
// This EA is provided to you for free of charge! You can share this EA on any website or any forums. 
//
// CFTC RULE 4.41
// HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED 
// RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-
// OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, 
// IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING 
// MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.
//
// U.S. Government Required Disclaimer.
// Commodity Futures Trading Commission Futures and Options trading has large potential rewards, but also large potential risk. 
// You must be aware the risks and be willing to accept them in order to invest in the futures and options markets. 
// Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to Buy/Sell futures or options.
// No representation is being made that any account will or is likely to achieve profits or losses similar 
// to those discussed on this website. The past performance of any trading system or methodology is not necessarily 
// indicative of future results.
//
// USE THIS EA AT YOUR OWN RISK. 
//
//                      DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//+------------------------------------------------------------------+

#property copyright "Copyright 2017"
#property link      "https://mt4talk.com"
#property version   "1.00"
#property strict
extern double Lotsize=0.01;
extern double Stop_Loss=10;
extern double Take_Profit=30;
extern double Break_Even=1;
extern double Trailing_Stop=20 ;
extern int Magic_Number=12345;
extern int Max_Nr_Of_Trades=10;
extern string TimeStart="00:01";
extern string TimeStop="23:59";
extern int Max_Nr_Of_Sell_Trades=5;
extern int Max_Nr_Of_Buy_Trades=5;
extern bool Hidden=false;
extern bool Close_opposit_signal=true; 
extern bool DayFilter=true;
extern string SundayStart="00:00";
extern string SundayStop="00:01";
extern string MondayStart="00:00";
extern string MondayStop="00:01";
extern string TuesdayStart="00:00";
extern string TuesdayStop="00:01";
extern string WednesdayStart="00:00";
extern string WednesdayStop="00:01";
extern string ThursdayStart="00:00";
extern string ThursdayStop="00:01";
extern string FridayStart="00:00";
extern string FridayStop="00:01"; 
extern bool TimeFilter=true;
 
double Risk=0;

double Martingale_Value=0;

bool FixSL=0;
int Money_Management=1;

int cntmartin=0;
double ts=0;
double be=0;
double sl,tp;
int mp;
datetime lasttrade;


 

 

int OnInit() 
 
{ 
    mp=1;
    if (Digits==5 || Digits==3) mp=10; 
    lasttrade=TimeCurrent();
    cntmartin=0;
    
    if (Money_Management==1)   
    {
       Stop_Loss=Stop_Loss/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Take_Profit=Take_Profit/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Break_Even=Break_Even/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Trailing_Stop=Trailing_Stop/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
    }

    //---
    return(INIT_SUCCEEDED);

} 

 
void OnDeinit(const int reason)
 
{} 

 
void OnTick()
{
    bool TradeAllow=false;
    bool buy_signal=false;
    bool sell_signal=false;
    double sl;
    double tp;
    double lotsize;
    
 
    TradeAllow=sTimeFilter(TimeStart,TimeStop);
 
    if (((TradeAllow && TimeFilter) || !TimeFilter) && (!DayFilter ||  DayFilter && GetDayFilter()) )
    {
        buy_signal=GetSignal(OP_BUY);
        sell_signal=GetSignal(OP_SELL);
    }
 
    //---       
    if((CloseSignal(OP_BUY)) ||
        (sell_signal && Close_opposit_signal))
    {
      CloseOrders(OP_BUY);
    }
    if((CloseSignal(OP_SELL)) ||
        (buy_signal && Close_opposit_signal))
    {
      CloseOrders(OP_SELL);
    }
 
    if((Max_Nr_Of_Trades>0 && GetNrOfTrades(6)<Max_Nr_Of_Trades)||
        Max_Nr_Of_Trades==0)
    {
        if((Max_Nr_Of_Buy_Trades>0 && GetNrOfTrades(OP_BUY)<Max_Nr_Of_Trades)||
            Max_Nr_Of_Trades==0)
        {
            if(buy_signal)
            {
                if (Money_Management==2)
                {
                    double entry;
        
                    entry=MarketInfo(Symbol(),MODE_ASK);
                    if(FixSL)
                    {    
                        sl=NormalizeDouble(entry-Stop_Loss*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        Lotsize=NormalizeDouble(CalcLotsize(Symbol(),entry,sl,Risk),2);
                        tp=NormalizeDouble(entry+CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    else
                    {
                        sl=NormalizeDouble(entry-CalcDistance(Stop_Loss,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        tp=NormalizeDouble(entry+CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    
                }
                   
                   
                if (GetLastProfit(lotsize)<0 && Martingale_Type>0)
                {
                    Lotsize=lotsize;
                    cntmartin++;
                }
                else
                {
                    cntmartin=0;
                }
                  
                if (Martingale_Type==1)//Increment
                {
                    Lotsize+=Martingale_Value;
                }
                        
                if (Martingale_Type==2)//Multipli
                {
                     Lotsize*=Martingale_Value;
                }
                OpenOrder(OP_BUY);
            }
        }
        if((Max_Nr_Of_Sell_Trades>0 && GetNrOfTrades(OP_SELL)<Max_Nr_Of_Sell_Trades)||
            Max_Nr_Of_Sell_Trades==0)
        {
            if(sell_signal)
            {
                if (Money_Management==2)
                {
                    double entry;
                    entry=MarketInfo(Symbol(),MODE_BID);
                    if(FixSL)
                    {
                        sl=NormalizeDouble(entry+Stop_Loss*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));
                        Lotsize=NormalizeDouble(CalcLotsize(Symbol(),entry,sl,Risk),2);
                        tp=NormalizeDouble(entry-CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    else
                    {
                        sl=NormalizeDouble(entry+CalcDistance(Stop_Loss,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        tp=NormalizeDouble(entry-CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                }
                
                
                if (GetLastProfit(lotsize)<0 && Martingale_Type>0)
                {
                    Lotsize=lotsize;
                    cntmartin++;
                }
                else
                {
                    cntmartin=0;
                }
                  
                if (Martingale_Type==1)//Increment
                {
                    Lotsize+=Martingale_Value;
                }
                        
                if (Martingale_Type==2)//Multipli
                {
                     Lotsize*=Martingale_Value;
                }
                OpenOrder(OP_SELL);
            }
        }
    }
}
       

 
bool sTimeFilter(string inStart,string inEnd,string inString=':')
{
   bool Result=true;
   int TimeHourStart,TimeMinuteStart,TimeHourEnd,TimeMinuteEnd;
   static datetime TimeStart,TimeEnd;

   sInputTimeConvert(TimeHourStart,TimeMinuteStart,inStart,inString);
   sInputTimeConvert(TimeHourEnd,TimeMinuteEnd,inEnd,inString);
   TimeStart=StrToTime(IntegerToString(TimeHourStart)+':'+IntegerToString(TimeMinuteStart));
   TimeEnd=StrToTime(IntegerToString(TimeHourEnd)+':'+IntegerToString(TimeMinuteEnd));

   if((TimeStart<=TimeEnd) && ((TimeCurrent()<TimeStart) || (TimeCurrent()>TimeEnd))) Result=false;
   if((TimeStart>TimeEnd) && (TimeCurrent()<TimeStart) && (TimeCurrent()>TimeEnd)) Result=false;

   return(Result);
}


int sInputTimeConvert(int &inHour,int &inMinute,string inInput,string inString=':')
{
   int PS;

   PS=StringFind(inInput,inString,0);
   inMinute=(int)StrToDouble(StringSubstr(inInput,PS+1,StringLen(inInput)-PS));
   inHour=(int)StrToDouble(StringSubstr(inInput,0,PS));

   return(PS);
}
 
bool GetDayFilter()
{
   switch (DayOfWeek())
   {
      case 0: return (sTimeFilter(SundayStart,SundayStop));
      case 1: return (sTimeFilter(MondayStart,MondayStop));
      case 2: return (sTimeFilter(TuesdayStart,TuesdayStop));
      case 3: return (sTimeFilter(WednesdayStart,WednesdayStop));
      case 4: return (sTimeFilter(ThursdayStart,ThursdayStop));
      case 5: return (sTimeFilter(FridayStart,FridayStop));
      
   }
   return (false);
} 
 
bool GetSignal(int type)
{
    bool b=false;
     
 
    if(type==OP_BUY)
    {
 
            if(iOpen(Symbol(),1,0)>iClose(Symbol(),1,1))
            {
               b=true;
            }
        } 
 
    if(type==OP_SELL)
    {
            if(iOpen(Symbol(),1,0)<iClose(Symbol(),1,1))
            {
               b=true;
            }
        } 
 
    return(b);
} 
 
bool CloseSignal(int type)
{
    bool b=false;
     
 
    if(type==OP_BUY)
    {
            if(iClose(Symbol(),1,1)iClose(Symbol(),1,2))
            {
               b=true;
            }
        } 
 
    if(type==OP_SELL)
    {
            if(iClose(Symbol(),1,1)iClose(Symbol(),1,2))
            {
               b=true;
            }
        } 
 
    return(b);
}
 
void OpenOrder(int type)
{
   int ticket=-1;
   int err=0;
  
    if(type==OP_BUY)
    {
        ticket = OrderSend(Symbol(), OP_BUY, Lotsize, MarketInfo(Symbol(), MODE_ASK), 10, 0, 0,"", Magic_Number);       
        if(ticket<0)
        {
            err=GetLastError();
            //Print ('Error!. Cannot Open BUY, failed with error : ',err);
        }
        else
        {
            if(Money_Management<2)
            {
                sl=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK)-Stop_Loss*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
                tp=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK)+Take_Profit*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
            }
            OrderModify(ticket, MarketInfo(Symbol(), MODE_ASK), sl, tp,0);//open price=MarketInfo(Symbol(), MODE_ASK)
        }
    }

    if(type==OP_SELL)
    {
        ticket = OrderSend(Symbol(), OP_BUY, Lotsize, MarketInfo(Symbol(), MODE_BID), 10, 0, 0,"", Magic_Number);       
        if(ticket<0)
        {
            err=GetLastError();
            //Print ('Error!. Cannot Open BUY, failed with error : ',err);
        }
        else
        {
            if(Money_Management<2)
            {
                sl=NormalizeDouble(MarketInfo(Symbol(), MODE_BID)+Stop_Loss*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
                tp=NormalizeDouble(MarketInfo(Symbol(), MODE_BID)-Take_Profit*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
            }
            OrderModify(ticket, MarketInfo(Symbol(), MODE_BID), sl, tp,0);//open price=MarketInfo(Symbol(), MODE_ASK)
        }
    }
}
 
void CloseOrders(int type)
{
   int total  = OrdersTotal();
   for (int i = total-1 ; i >=0 ; i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && 
        OrderMagicNumber() == Magic_Number && 
        OrderSymbol() == Symbol() && 
        type==OrderType()) 
        {
            switch(OrderType())
            {
                case OP_BUY:
                {
                    OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),10);
                    break;  
                }
                                  
                case OP_SELL:
                {
                    OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),10);
                    break;
                }
            }             
        }
    }
}
 
bool IsNewBar()
{
    if (lasttrade<iTime(Symbol(),0,0))
    {
        lasttrade=iTime(Symbol(),0,0);
        return (true);
    }
    return (false);
}
int GetNrOfTrades(int type)
{
   int t=0;
   
   int total = OrdersTotal();
   int count;
   if(type==OP_BUY || type==OP_SELL)
   {
       for(count = total - 1; count >= 0; count--)
       {
          if(!OrderSelect(count, SELECT_BY_POS, MODE_TRADES)) continue;
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderType()==type)
          {
             t++;
          }
       }
       return (t);
   }
   else if(type==6)
   {
       for(count = total - 1; count >= 0; count--)
       {
          if(!OrderSelect(count, SELECT_BY_POS, MODE_TRADES)) continue;
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
          {
             t++;
          }
       }
       return (t);
   }
   return(t);
}
    
 
double CalcLotsize(string symbol,double entry, double sl,double risk)
{
   
   double qty,riskm,dist; 
   dist=MathAbs(entry-sl)/MarketInfo(symbol,MODE_POINT);
   riskm=AccountBalance()*risk/100;
   
   qty=riskm/(dist*MarketInfo(symbol,MODE_TICKVALUE));  
   return( NormalizeDouble(qty,2) );
}
    
 
void Trailing(double Trailing_Stop)
{
  int err;
   double sl = 0;
   bool result;
   
   //
   sl = OrderStopLoss();
   if(OrderType() == OP_BUY)
   {
      if((MarketInfo(Symbol(),MODE_BID) > (OrderOpenPrice() + Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT))) )
      {                        
         
         if(OrderStopLoss() == 0) sl = MarketInfo(Symbol(),MODE_BID) - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT);
         if(OrderStopLoss() != 0 && MarketInfo(Symbol(),MODE_BID) >= OrderStopLoss() + Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT)) sl = MarketInfo(Symbol(),MODE_BID) - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT);
         while(IsTradeContextBusy()) Sleep(100);
         if(sl > OrderStopLoss())
         {
            ResetLastError();
            result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
            //
            if (result)
            {               
               Print("Trailing Stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(OrderStopLoss(), MarketInfo(Symbol(),MODE_DIGITS)), "; Bid = ", DoubleToStr(MarketInfo(Symbol(),MODE_BID), MarketInfo(Symbol(),MODE_DIGITS)));
            }
            else
            {
               err = GetLastError();
               Print("Error!. Trailing Stop #", OrderTicket(), " order modify failed with error(",err,")");
            }
         }
      }
   }//if(OrderType() == OP_BUY)
   //
   if(OrderType() == OP_SELL)
   {
      
      if((MarketInfo(Symbol(),MODE_ASK) < (OrderOpenPrice() - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT))))
      {
         
         if(OrderStopLoss() == 0) sl = MarketInfo(Symbol(),MODE_ASK) + (Trailing_Stop*mp)*MarketInfo(Symbol(),MODE_POINT);
         if(OrderStopLoss() != 0 && MarketInfo(Symbol(),MODE_ASK) <= OrderStopLoss() - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT)) sl = MarketInfo(Symbol(),MODE_ASK) + (Trailing_Stop*mp)*MarketInfo(Symbol(),MODE_POINT);
         while(IsTradeContextBusy()) Sleep(100);
         if(sl < OrderStopLoss())
         {
            ResetLastError();
            result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
            //
            if (result)
            {
               Print("Trailing Stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Ask = ", DoubleToStr(MarketInfo(Symbol(),MODE_ASK), MarketInfo(Symbol(),MODE_DIGITS)));
            }
            else
            {
               err = GetLastError();
               Print("Error!. Trailing Stop #", OrderTicket(), " order modify failed with error(",err,")");
            }
         }
      }
   }
}
    
 
void ManageTrades()
{
   int t=OrdersTotal();
   for(int i=t-1;i>=0;i--)
   {
      if(OrderSelect(i,SELECT_BY_POS))
      {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
         {
            if (!Hidden)
            {
                if (Money_Management==2)
                {
                    ts=CalcDistance(Trailing_Stop,OrderLots());//OrderLots
                    be=CalcDistance(Break_Even,OrderLots()); 
                }
                else
                {
                    ts=Trailing_Stop;
                    be=Break_Even;
                }
                
                if (Break_Even>0)
                {
                    BreakEven(be);
                }
                if (Trailing_Stop>0)
                {
                    Trailing(ts);
                }
            }
           
         
         }
      }
   }//for end
}
    
 
    
void BreakEven(double Break_Even)
{
   bool result;
   double sl;
   int err;
   //
   ResetLastError();
   if(OrderType() == OP_BUY)
   {
       if(OrderStopLoss() >= OrderOpenPrice()) return;
       
       if (MarketInfo(Symbol(),MODE_BID) >= OrderOpenPrice() + Break_Even*mp*MarketInfo(Symbol(),MODE_POINT))
       {
         sl= OrderOpenPrice() ;
         while(IsTradeContextBusy()) Sleep(100);
         result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
         if (result)
         {
            Print("Break Even stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Bid = ", DoubleToStr(MarketInfo(Symbol(),MODE_BID), MarketInfo(Symbol(),MODE_DIGITS)));
         }
         else
         {
            err = GetLastError();
            Print("Error!. Break Even #", OrderTicket(), " order modify failed with error(",err,")");
         }
       }
   }
   //
   if (OrderType() == OP_SELL) 
   {
       if (OrderStopLoss() <= OrderOpenPrice() && OrderStopLoss() != 0) return;
       
       if (MarketInfo(Symbol(),MODE_ASK) <= OrderOpenPrice() - Break_Even*mp*MarketInfo(Symbol(),MODE_POINT))
       {
         sl = OrderOpenPrice() ;
         while(IsTradeContextBusy()) Sleep(100);
         result = OrderModify(OrderTicket(),OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
         if (result)
         {           
            Print("Break Even stop updated: # ", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Ask = ", DoubleToStr(MarketInfo(Symbol(),MODE_ASK), MarketInfo(Symbol(),MODE_DIGITS)));
         }
         else
         {
            err = GetLastError();
            Print("Error!. Break Even #", OrderTicket(), " order modify failed with error(",err,")");
         }
       }
   }
}
    
 
double CalcDistance(double risk, double lotsize)
{
   risk=AccountBalance()*risk/100;
   return (risk/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/lotsize);
}

 
double GetLastProfit(double& lotsize)
{
   int t=OrdersTotal();
   double p=0;
   datetime mt=0;
   
   for (int i=t-1;i>=0;i--)
   {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderCloseTime()>mt)
         {
            mt=OrderCloseTime();
            p=OrderProfit();
            lotsize=OrderLots();
         }
      }
   }
   
   return (p);
}

Some brokers offer IB be able to try to be able to get the IBS to bring clients to trade in the broker.
Sometimes some IB  they offer additional services in forex, which could help a trader, and by joining their ib one could receive these services.

As I worked with a few ibs here are a few things traders can be watching out for:
1. Make sure the product or service the IB provides is legit, and not always just fund managment

2. Fully know the broker that the ib is promoting make sure you also have direct access to someone at the broker, this way you can have direct info from the broker


Some people become IB and are greedy, sometimes they lure investors into their IB and trade for the investor just to generate lot volume so they can earn the IB rebates, so when joining make sure you are not joining something where they will just use a scalper to drain your money.

Scalps M5

//+------------------------------------------------------------------+
//                        DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//
//                   Copyright ©2017, https://mt4talk.com
//                     MT4talk Expert Advisor Generator
//                        https://mt4talk.com/eagenerator/
//
// THIS EXPERT ADVISOR (EA) HAS BEEN GENERATED USING MT4talk EA GENERATOR. 
// 
// Disclaimer: This EA is provided to you "AS-IS", and MT4talk disclaims any warranty
// or liability obligations to you of any kind. 
//
// FREE EA LICENSE
// This EA is provided to you for free of charge! You can share this EA on any website or any forums. 
//
// CFTC RULE 4.41
// HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED 
// RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-
// OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, 
// IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING 
// MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.
//
// U.S. Government Required Disclaimer.
// Commodity Futures Trading Commission Futures and Options trading has large potential rewards, but also large potential risk. 
// You must be aware the risks and be willing to accept them in order to invest in the futures and options markets. 
// Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to Buy/Sell futures or options.
// No representation is being made that any account will or is likely to achieve profits or losses similar 
// to those discussed on this website. The past performance of any trading system or methodology is not necessarily 
// indicative of future results.
//
// USE THIS EA AT YOUR OWN RISK. 
//
//                      DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//+------------------------------------------------------------------+

#property copyright "Copyright 2017"
#property link      "https://mt4talk.com"
#property version   "1.00"
#property strict
extern int Money_Management=0;
extern int Magic_Number=123454321;
extern int Max_Nr_Of_Trades=6;
extern bool Hidden=false;
extern int Martingale_Type=0;
extern bool Close_opposit_signal=true;
extern double Stop_Loss=0;
extern double Take_Profit=0;
extern double Trailing_Stop=0;
extern int Max_Nr_Of_Buy_Trades=0;
extern int Max_Nr_Of_Sell_Trades=0; 
extern bool DayFilter=false; 
extern bool TimeFilter=false;
 
double Risk=0;

double Martingale_Value=0;

bool FixSL=0;
int Money_Management=-1;

int cntmartin=0;
double ts=0;
double be=0;
double sl,tp;
int mp;
datetime lasttrade;


 

 

int OnInit() 
 
{ 
    mp=1;
    if (Digits==5 || Digits==3) mp=10; 
    lasttrade=TimeCurrent();
    cntmartin=0;
    
    if (Money_Management==1)   
    {
       Stop_Loss=Stop_Loss/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Take_Profit=Take_Profit/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Break_Even=Break_Even/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Trailing_Stop=Trailing_Stop/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
    }

    //---
    return(INIT_SUCCEEDED);

} 

 
void OnDeinit(const int reason)
 
{} 

 
void OnTick()
{
    bool TradeAllow=false;
    bool buy_signal=false;
    bool sell_signal=false;
    double sl;
    double tp;
    double lotsize;
    
 
    buy_signal=GetSignal(OP_BUY);
    sell_signal=GetSignal(OP_SELL);
 
    //---       
    if((CloseSignal(OP_BUY)) ||
        (sell_signal && Close_opposit_signal))
    {
      CloseOrders(OP_BUY);
    }
    if((CloseSignal(OP_SELL)) ||
        (buy_signal && Close_opposit_signal))
    {
      CloseOrders(OP_SELL);
    }
 
    if((Max_Nr_Of_Trades>0 && GetNrOfTrades(6)<Max_Nr_Of_Trades)||
        Max_Nr_Of_Trades==0)
    {
        if((Max_Nr_Of_Buy_Trades>0 && GetNrOfTrades(OP_BUY)<Max_Nr_Of_Trades)||
            Max_Nr_Of_Trades==0)
        {
            if(buy_signal)
            {
                if (Money_Management==2)
                {
                    double entry;
        
                    entry=MarketInfo(Symbol(),MODE_ASK);
                    if(FixSL)
                    {    
                        sl=NormalizeDouble(entry-Stop_Loss*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        Lotsize=NormalizeDouble(CalcLotsize(Symbol(),entry,sl,Risk),2);
                        tp=NormalizeDouble(entry+CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    else
                    {
                        sl=NormalizeDouble(entry-CalcDistance(Stop_Loss,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        tp=NormalizeDouble(entry+CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    
                }
                   
                   
                if (GetLastProfit(lotsize)<0 && Martingale_Type>0)
                {
                    Lotsize=lotsize;
                    cntmartin++;
                }
                else
                {
                    cntmartin=0;
                }
                  
                if (Martingale_Type==1)//Increment
                {
                    Lotsize+=Martingale_Value;
                }
                        
                if (Martingale_Type==2)//Multipli
                {
                     Lotsize*=Martingale_Value;
                }
                OpenOrder(OP_BUY);
            }
        }
        if((Max_Nr_Of_Sell_Trades>0 && GetNrOfTrades(OP_SELL)<Max_Nr_Of_Sell_Trades)||
            Max_Nr_Of_Sell_Trades==0)
        {
            if(sell_signal)
            {
                if (Money_Management==2)
                {
                    double entry;
                    entry=MarketInfo(Symbol(),MODE_BID);
                    if(FixSL)
                    {
                        sl=NormalizeDouble(entry+Stop_Loss*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));
                        Lotsize=NormalizeDouble(CalcLotsize(Symbol(),entry,sl,Risk),2);
                        tp=NormalizeDouble(entry-CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    else
                    {
                        sl=NormalizeDouble(entry+CalcDistance(Stop_Loss,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        tp=NormalizeDouble(entry-CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                }
                
                
                if (GetLastProfit(lotsize)<0 && Martingale_Type>0)
                {
                    Lotsize=lotsize;
                    cntmartin++;
                }
                else
                {
                    cntmartin=0;
                }
                  
                if (Martingale_Type==1)//Increment
                {
                    Lotsize+=Martingale_Value;
                }
                        
                if (Martingale_Type==2)//Multipli
                {
                     Lotsize*=Martingale_Value;
                }
                OpenOrder(OP_SELL);
            }
        }
    }
}
       
 
 
bool GetSignal(int type)
{
    bool b=false;
     
 
    if(type==OP_BUY)
    {
 
 
            if((iClose(Symbol(),60,0)>=iMA(Symbol(),60,50,0,1,1,0)) &&() )
            {
                b=true;
            }
            
        } 
 
    if(type==OP_SELL)
    {
 
            if((iClose(Symbol(),60,0)<=iMA(Symbol(),60,50,0,1,1,0)) ||() )
            {
                b=true;
            }
            
        } 
 
    return(b);
} 
 
bool CloseSignal(int type)
{
    bool b=false;
     
 
    if(type==OP_BUY)
    {
            if(iMA(Symbol(),60,20,0,1,1,0)<iMA(Symbol(),60,50,0,1,1,0))
            {
               b=true;
            }
        } 
 
    if(type==OP_SELL)
    {
            if(iMA(Symbol(),60,20,0,1,1,0)>iMA(Symbol(),60,50,0,1,1,0))
            {
               b=true;
            }
        } 
 
    return(b);
}
 
void OpenOrder(int type)
{
   int ticket=-1;
   int err=0;
  
    if(type==OP_BUY)
    {
        ticket = OrderSend(Symbol(), OP_BUY, Lotsize, MarketInfo(Symbol(), MODE_ASK), 10, 0, 0,"", Magic_Number);       
        if(ticket<0)
        {
            err=GetLastError();
            //Print ('Error!. Cannot Open BUY, failed with error : ',err);
        }
        else
        {
            if(Money_Management<2)
            {
                sl=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK)-Stop_Loss*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
                tp=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK)+Take_Profit*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
            }
            OrderModify(ticket, MarketInfo(Symbol(), MODE_ASK), sl, tp,0);//open price=MarketInfo(Symbol(), MODE_ASK)
        }
    }

    if(type==OP_SELL)
    {
        ticket = OrderSend(Symbol(), OP_BUY, Lotsize, MarketInfo(Symbol(), MODE_BID), 10, 0, 0,"", Magic_Number);       
        if(ticket<0)
        {
            err=GetLastError();
            //Print ('Error!. Cannot Open BUY, failed with error : ',err);
        }
        else
        {
            if(Money_Management<2)
            {
                sl=NormalizeDouble(MarketInfo(Symbol(), MODE_BID)+Stop_Loss*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
                tp=NormalizeDouble(MarketInfo(Symbol(), MODE_BID)-Take_Profit*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
            }
            OrderModify(ticket, MarketInfo(Symbol(), MODE_BID), sl, tp,0);//open price=MarketInfo(Symbol(), MODE_ASK)
        }
    }
}
 
void CloseOrders(int type)
{
   int total  = OrdersTotal();
   for (int i = total-1 ; i >=0 ; i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && 
        OrderMagicNumber() == Magic_Number && 
        OrderSymbol() == Symbol() && 
        type==OrderType()) 
        {
            switch(OrderType())
            {
                case OP_BUY:
                {
                    OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),10);
                    break;  
                }
                                  
                case OP_SELL:
                {
                    OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),10);
                    break;
                }
            }             
        }
    }
}
 
bool IsNewBar()
{
    if (lasttrade<iTime(Symbol(),0,0))
    {
        lasttrade=iTime(Symbol(),0,0);
        return (true);
    }
    return (false);
}
int GetNrOfTrades(int type)
{
   int t=0;
   
   int total = OrdersTotal();
   int count;
   if(type==OP_BUY || type==OP_SELL)
   {
       for(count = total - 1; count >= 0; count--)
       {
          if(!OrderSelect(count, SELECT_BY_POS, MODE_TRADES)) continue;
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderType()==type)
          {
             t++;
          }
       }
       return (t);
   }
   else if(type==6)
   {
       for(count = total - 1; count >= 0; count--)
       {
          if(!OrderSelect(count, SELECT_BY_POS, MODE_TRADES)) continue;
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
          {
             t++;
          }
       }
       return (t);
   }
   return(t);
}
    
 
double CalcLotsize(string symbol,double entry, double sl,double risk)
{
   
   double qty,riskm,dist; 
   dist=MathAbs(entry-sl)/MarketInfo(symbol,MODE_POINT);
   riskm=AccountBalance()*risk/100;
   
   qty=riskm/(dist*MarketInfo(symbol,MODE_TICKVALUE));  
   return( NormalizeDouble(qty,2) );
}
    
 
void Trailing(double Trailing_Stop)
{
  int err;
   double sl = 0;
   bool result;
   
   //
   sl = OrderStopLoss();
   if(OrderType() == OP_BUY)
   {
      if((MarketInfo(Symbol(),MODE_BID) > (OrderOpenPrice() + Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT))) )
      {                        
         
         if(OrderStopLoss() == 0) sl = MarketInfo(Symbol(),MODE_BID) - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT);
         if(OrderStopLoss() != 0 && MarketInfo(Symbol(),MODE_BID) >= OrderStopLoss() + Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT)) sl = MarketInfo(Symbol(),MODE_BID) - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT);
         while(IsTradeContextBusy()) Sleep(100);
         if(sl > OrderStopLoss())
         {
            ResetLastError();
            result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
            //
            if (result)
            {               
               Print("Trailing Stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(OrderStopLoss(), MarketInfo(Symbol(),MODE_DIGITS)), "; Bid = ", DoubleToStr(MarketInfo(Symbol(),MODE_BID), MarketInfo(Symbol(),MODE_DIGITS)));
            }
            else
            {
               err = GetLastError();
               Print("Error!. Trailing Stop #", OrderTicket(), " order modify failed with error(",err,")");
            }
         }
      }
   }//if(OrderType() == OP_BUY)
   //
   if(OrderType() == OP_SELL)
   {
      
      if((MarketInfo(Symbol(),MODE_ASK) < (OrderOpenPrice() - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT))))
      {
         
         if(OrderStopLoss() == 0) sl = MarketInfo(Symbol(),MODE_ASK) + (Trailing_Stop*mp)*MarketInfo(Symbol(),MODE_POINT);
         if(OrderStopLoss() != 0 && MarketInfo(Symbol(),MODE_ASK) <= OrderStopLoss() - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT)) sl = MarketInfo(Symbol(),MODE_ASK) + (Trailing_Stop*mp)*MarketInfo(Symbol(),MODE_POINT);
         while(IsTradeContextBusy()) Sleep(100);
         if(sl < OrderStopLoss())
         {
            ResetLastError();
            result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
            //
            if (result)
            {
               Print("Trailing Stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Ask = ", DoubleToStr(MarketInfo(Symbol(),MODE_ASK), MarketInfo(Symbol(),MODE_DIGITS)));
            }
            else
            {
               err = GetLastError();
               Print("Error!. Trailing Stop #", OrderTicket(), " order modify failed with error(",err,")");
            }
         }
      }
   }
}
    
 
void ManageTrades()
{
   int t=OrdersTotal();
   for(int i=t-1;i>=0;i--)
   {
      if(OrderSelect(i,SELECT_BY_POS))
      {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
         {
            if (!Hidden)
            {
                if (Money_Management==2)
                {
                    ts=CalcDistance(Trailing_Stop,OrderLots());//OrderLots
                    be=CalcDistance(Break_Even,OrderLots()); 
                }
                else
                {
                    ts=Trailing_Stop;
                    be=Break_Even;
                }
                
                if (Break_Even>0)
                {
                    BreakEven(be);
                }
                if (Trailing_Stop>0)
                {
                    Trailing(ts);
                }
            }
           
         
         }
      }
   }//for end
}
    
 
    
void BreakEven(double Break_Even)
{
   bool result;
   double sl;
   int err;
   //
   ResetLastError();
   if(OrderType() == OP_BUY)
   {
       if(OrderStopLoss() >= OrderOpenPrice()) return;
       
       if (MarketInfo(Symbol(),MODE_BID) >= OrderOpenPrice() + Break_Even*mp*MarketInfo(Symbol(),MODE_POINT))
       {
         sl= OrderOpenPrice() ;
         while(IsTradeContextBusy()) Sleep(100);
         result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
         if (result)
         {
            Print("Break Even stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Bid = ", DoubleToStr(MarketInfo(Symbol(),MODE_BID), MarketInfo(Symbol(),MODE_DIGITS)));
         }
         else
         {
            err = GetLastError();
            Print("Error!. Break Even #", OrderTicket(), " order modify failed with error(",err,")");
         }
       }
   }
   //
   if (OrderType() == OP_SELL) 
   {
       if (OrderStopLoss() <= OrderOpenPrice() && OrderStopLoss() != 0) return;
       
       if (MarketInfo(Symbol(),MODE_ASK) <= OrderOpenPrice() - Break_Even*mp*MarketInfo(Symbol(),MODE_POINT))
       {
         sl = OrderOpenPrice() ;
         while(IsTradeContextBusy()) Sleep(100);
         result = OrderModify(OrderTicket(),OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
         if (result)
         {           
            Print("Break Even stop updated: # ", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Ask = ", DoubleToStr(MarketInfo(Symbol(),MODE_ASK), MarketInfo(Symbol(),MODE_DIGITS)));
         }
         else
         {
            err = GetLastError();
            Print("Error!. Break Even #", OrderTicket(), " order modify failed with error(",err,")");
         }
       }
   }
}
    
 
double CalcDistance(double risk, double lotsize)
{
   risk=AccountBalance()*risk/100;
   return (risk/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/lotsize);
}

 
double GetLastProfit(double& lotsize)
{
   int t=OrdersTotal();
   double p=0;
   datetime mt=0;
   
   for (int i=t-1;i>=0;i--)
   {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderCloseTime()>mt)
         {
            mt=OrderCloseTime();
            p=OrderProfit();
            lotsize=OrderLots();
         }
      }
   }
   
   return (p);
}

Scalper

//+------------------------------------------------------------------+
//                        DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//
//                   Copyright ©2017, https://mt4talk.com
//                     MT4talk Expert Advisor Generator
//                        https://mt4talk.com/eagenerator/
//
// THIS EXPERT ADVISOR (EA) HAS BEEN GENERATED USING MT4talk EA GENERATOR. 
// 
// Disclaimer: This EA is provided to you "AS-IS", and MT4talk disclaims any warranty
// or liability obligations to you of any kind. 
//
// FREE EA LICENSE
// This EA is provided to you for free of charge! You can share this EA on any website or any forums. 
//
// CFTC RULE 4.41
// HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED 
// RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-
// OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, 
// IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING 
// MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.
//
// U.S. Government Required Disclaimer.
// Commodity Futures Trading Commission Futures and Options trading has large potential rewards, but also large potential risk. 
// You must be aware the risks and be willing to accept them in order to invest in the futures and options markets. 
// Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to Buy/Sell futures or options.
// No representation is being made that any account will or is likely to achieve profits or losses similar 
// to those discussed on this website. The past performance of any trading system or methodology is not necessarily 
// indicative of future results.
//
// USE THIS EA AT YOUR OWN RISK. 
//
//                      DO NOT DELETE THIS HEADER
//             DELETING THIS HEADER IS COPYRIGHT INFRIGMENT 
//+------------------------------------------------------------------+

#property copyright "Copyright 2017"
#property link      "https://mt4talk.com"
#property version   "1.00"
#property strict
extern int Money_Management=0;
extern int Magic_Number=12345;
extern int Max_Nr_Of_Trades=200;
extern int Max_Nr_Of_Sell_Trades=200;
extern int Max_Nr_Of_Buy_Trades=200;
extern bool Hidden=false;
extern int Martingale_Type=0;
extern bool Close_opposit_signal=true;
extern double Stop_Loss=0;
extern double Take_Profit=0;
extern double Trailing_Stop=0; 
extern bool DayFilter=false; 
extern bool TimeFilter=false;
 
double Risk=0;

double Martingale_Value=0;

bool FixSL=0;
int Money_Management=-1;

int cntmartin=0;
double ts=0;
double be=0;
double sl,tp;
int mp;
datetime lasttrade;


 

 

int OnInit() 
 
{ 
    mp=1;
    if (Digits==5 || Digits==3) mp=10; 
    lasttrade=TimeCurrent();
    cntmartin=0;
    
    if (Money_Management==1)   
    {
       Stop_Loss=Stop_Loss/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Take_Profit=Take_Profit/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Break_Even=Break_Even/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
       Trailing_Stop=Trailing_Stop/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/Lotsize;
    }

    //---
    return(INIT_SUCCEEDED);

} 

 
void OnDeinit(const int reason)
 
{} 

 
void OnTick()
{
    bool TradeAllow=false;
    bool buy_signal=false;
    bool sell_signal=false;
    double sl;
    double tp;
    double lotsize;
    
 
    buy_signal=GetSignal(OP_BUY);
    sell_signal=GetSignal(OP_SELL);
 
    //---       
    if((CloseSignal(OP_BUY)) ||
        (sell_signal && Close_opposit_signal))
    {
      CloseOrders(OP_BUY);
    }
    if((CloseSignal(OP_SELL)) ||
        (buy_signal && Close_opposit_signal))
    {
      CloseOrders(OP_SELL);
    }
 
    if((Max_Nr_Of_Trades>0 && GetNrOfTrades(6)<Max_Nr_Of_Trades)||
        Max_Nr_Of_Trades==0)
    {
        if((Max_Nr_Of_Buy_Trades>0 && GetNrOfTrades(OP_BUY)<Max_Nr_Of_Trades)||
            Max_Nr_Of_Trades==0)
        {
            if(buy_signal)
            {
                if (Money_Management==2)
                {
                    double entry;
        
                    entry=MarketInfo(Symbol(),MODE_ASK);
                    if(FixSL)
                    {    
                        sl=NormalizeDouble(entry-Stop_Loss*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        Lotsize=NormalizeDouble(CalcLotsize(Symbol(),entry,sl,Risk),2);
                        tp=NormalizeDouble(entry+CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    else
                    {
                        sl=NormalizeDouble(entry-CalcDistance(Stop_Loss,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        tp=NormalizeDouble(entry+CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    
                }
                   
                   
                if (GetLastProfit(lotsize)<0 && Martingale_Type>0)
                {
                    Lotsize=lotsize;
                    cntmartin++;
                }
                else
                {
                    cntmartin=0;
                }
                  
                if (Martingale_Type==1)//Increment
                {
                    Lotsize+=Martingale_Value;
                }
                        
                if (Martingale_Type==2)//Multipli
                {
                     Lotsize*=Martingale_Value;
                }
                OpenOrder(OP_BUY);
            }
        }
        if((Max_Nr_Of_Sell_Trades>0 && GetNrOfTrades(OP_SELL)<Max_Nr_Of_Sell_Trades)||
            Max_Nr_Of_Sell_Trades==0)
        {
            if(sell_signal)
            {
                if (Money_Management==2)
                {
                    double entry;
                    entry=MarketInfo(Symbol(),MODE_BID);
                    if(FixSL)
                    {
                        sl=NormalizeDouble(entry+Stop_Loss*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));
                        Lotsize=NormalizeDouble(CalcLotsize(Symbol(),entry,sl,Risk),2);
                        tp=NormalizeDouble(entry-CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                    else
                    {
                        sl=NormalizeDouble(entry+CalcDistance(Stop_Loss,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS));     
                        tp=NormalizeDouble(entry-CalcDistance(Take_Profit,Lotsize)*mp*Point(),(int)MarketInfo(Symbol(),MODE_DIGITS)); 
                    }
                }
                
                
                if (GetLastProfit(lotsize)<0 && Martingale_Type>0)
                {
                    Lotsize=lotsize;
                    cntmartin++;
                }
                else
                {
                    cntmartin=0;
                }
                  
                if (Martingale_Type==1)//Increment
                {
                    Lotsize+=Martingale_Value;
                }
                        
                if (Martingale_Type==2)//Multipli
                {
                     Lotsize*=Martingale_Value;
                }
                OpenOrder(OP_SELL);
            }
        }
    }
}
       
 
 
bool GetSignal(int type)
{
    bool b=false;
     
 
    if(type==OP_BUY)
    {
 
            if(iHigh(Symbol(),0,12)<iOpen(Symbol(),0,0))
            {
               b=true;
            }
        } 
 
    if(type==OP_SELL)
    {
            if(iHigh(Symbol(),0,12)>iOpen(Symbol(),0,0))
            {
               b=true;
            }
        } 
 
    return(b);
} 
 
bool CloseSignal(int type)
{
    bool b=false;
     
 
    if(type==OP_BUY)
    {
            if(iLow(Symbol(),0,10)>iClose(Symbol(),0,10))
            {
               b=true;
            }
        } 
 
    if(type==OP_SELL)
    {
            if(iLow(Symbol(),0,10)<iClose(Symbol(),0,10))
            {
               b=true;
            }
        } 
 
    return(b);
}
 
void OpenOrder(int type)
{
   int ticket=-1;
   int err=0;
  
    if(type==OP_BUY)
    {
        ticket = OrderSend(Symbol(), OP_BUY, Lotsize, MarketInfo(Symbol(), MODE_ASK), 10, 0, 0,"", Magic_Number);       
        if(ticket<0)
        {
            err=GetLastError();
            //Print ('Error!. Cannot Open BUY, failed with error : ',err);
        }
        else
        {
            if(Money_Management<2)
            {
                sl=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK)-Stop_Loss*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
                tp=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK)+Take_Profit*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
            }
            OrderModify(ticket, MarketInfo(Symbol(), MODE_ASK), sl, tp,0);//open price=MarketInfo(Symbol(), MODE_ASK)
        }
    }

    if(type==OP_SELL)
    {
        ticket = OrderSend(Symbol(), OP_BUY, Lotsize, MarketInfo(Symbol(), MODE_BID), 10, 0, 0,"", Magic_Number);       
        if(ticket<0)
        {
            err=GetLastError();
            //Print ('Error!. Cannot Open BUY, failed with error : ',err);
        }
        else
        {
            if(Money_Management<2)
            {
                sl=NormalizeDouble(MarketInfo(Symbol(), MODE_BID)+Stop_Loss*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
                tp=NormalizeDouble(MarketInfo(Symbol(), MODE_BID)-Take_Profit*mp*MarketInfo(Symbol(),MODE_POINT), MarketInfo(Symbol(),MODE_DIGITS));
            }
            OrderModify(ticket, MarketInfo(Symbol(), MODE_BID), sl, tp,0);//open price=MarketInfo(Symbol(), MODE_ASK)
        }
    }
}
 
void CloseOrders(int type)
{
   int total  = OrdersTotal();
   for (int i = total-1 ; i >=0 ; i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && 
        OrderMagicNumber() == Magic_Number && 
        OrderSymbol() == Symbol() && 
        type==OrderType()) 
        {
            switch(OrderType())
            {
                case OP_BUY:
                {
                    OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),10);
                    break;  
                }
                                  
                case OP_SELL:
                {
                    OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),10);
                    break;
                }
            }             
        }
    }
}
 
bool IsNewBar()
{
    if (lasttrade<iTime(Symbol(),0,0))
    {
        lasttrade=iTime(Symbol(),0,0);
        return (true);
    }
    return (false);
}
int GetNrOfTrades(int type)
{
   int t=0;
   
   int total = OrdersTotal();
   int count;
   if(type==OP_BUY || type==OP_SELL)
   {
       for(count = total - 1; count >= 0; count--)
       {
          if(!OrderSelect(count, SELECT_BY_POS, MODE_TRADES)) continue;
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderType()==type)
          {
             t++;
          }
       }
       return (t);
   }
   else if(type==6)
   {
       for(count = total - 1; count >= 0; count--)
       {
          if(!OrderSelect(count, SELECT_BY_POS, MODE_TRADES)) continue;
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
          {
             t++;
          }
       }
       return (t);
   }
   return(t);
}
    
 
double CalcLotsize(string symbol,double entry, double sl,double risk)
{
   
   double qty,riskm,dist; 
   dist=MathAbs(entry-sl)/MarketInfo(symbol,MODE_POINT);
   riskm=AccountBalance()*risk/100;
   
   qty=riskm/(dist*MarketInfo(symbol,MODE_TICKVALUE));  
   return( NormalizeDouble(qty,2) );
}
    
 
void Trailing(double Trailing_Stop)
{
  int err;
   double sl = 0;
   bool result;
   
   //
   sl = OrderStopLoss();
   if(OrderType() == OP_BUY)
   {
      if((MarketInfo(Symbol(),MODE_BID) > (OrderOpenPrice() + Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT))) )
      {                        
         
         if(OrderStopLoss() == 0) sl = MarketInfo(Symbol(),MODE_BID) - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT);
         if(OrderStopLoss() != 0 && MarketInfo(Symbol(),MODE_BID) >= OrderStopLoss() + Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT)) sl = MarketInfo(Symbol(),MODE_BID) - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT);
         while(IsTradeContextBusy()) Sleep(100);
         if(sl > OrderStopLoss())
         {
            ResetLastError();
            result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
            //
            if (result)
            {               
               Print("Trailing Stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(OrderStopLoss(), MarketInfo(Symbol(),MODE_DIGITS)), "; Bid = ", DoubleToStr(MarketInfo(Symbol(),MODE_BID), MarketInfo(Symbol(),MODE_DIGITS)));
            }
            else
            {
               err = GetLastError();
               Print("Error!. Trailing Stop #", OrderTicket(), " order modify failed with error(",err,")");
            }
         }
      }
   }//if(OrderType() == OP_BUY)
   //
   if(OrderType() == OP_SELL)
   {
      
      if((MarketInfo(Symbol(),MODE_ASK) < (OrderOpenPrice() - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT))))
      {
         
         if(OrderStopLoss() == 0) sl = MarketInfo(Symbol(),MODE_ASK) + (Trailing_Stop*mp)*MarketInfo(Symbol(),MODE_POINT);
         if(OrderStopLoss() != 0 && MarketInfo(Symbol(),MODE_ASK) <= OrderStopLoss() - Trailing_Stop*mp*MarketInfo(Symbol(),MODE_POINT)) sl = MarketInfo(Symbol(),MODE_ASK) + (Trailing_Stop*mp)*MarketInfo(Symbol(),MODE_POINT);
         while(IsTradeContextBusy()) Sleep(100);
         if(sl < OrderStopLoss())
         {
            ResetLastError();
            result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
            //
            if (result)
            {
               Print("Trailing Stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Ask = ", DoubleToStr(MarketInfo(Symbol(),MODE_ASK), MarketInfo(Symbol(),MODE_DIGITS)));
            }
            else
            {
               err = GetLastError();
               Print("Error!. Trailing Stop #", OrderTicket(), " order modify failed with error(",err,")");
            }
         }
      }
   }
}
    
 
void ManageTrades()
{
   int t=OrdersTotal();
   for(int i=t-1;i>=0;i--)
   {
      if(OrderSelect(i,SELECT_BY_POS))
      {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
         {
            if (!Hidden)
            {
                if (Money_Management==2)
                {
                    ts=CalcDistance(Trailing_Stop,OrderLots());//OrderLots
                    be=CalcDistance(Break_Even,OrderLots()); 
                }
                else
                {
                    ts=Trailing_Stop;
                    be=Break_Even;
                }
                
                if (Break_Even>0)
                {
                    BreakEven(be);
                }
                if (Trailing_Stop>0)
                {
                    Trailing(ts);
                }
            }
           
         
         }
      }
   }//for end
}
    
 
    
void BreakEven(double Break_Even)
{
   bool result;
   double sl;
   int err;
   //
   ResetLastError();
   if(OrderType() == OP_BUY)
   {
       if(OrderStopLoss() >= OrderOpenPrice()) return;
       
       if (MarketInfo(Symbol(),MODE_BID) >= OrderOpenPrice() + Break_Even*mp*MarketInfo(Symbol(),MODE_POINT))
       {
         sl= OrderOpenPrice() ;
         while(IsTradeContextBusy()) Sleep(100);
         result = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
         if (result)
         {
            Print("Break Even stop updated: #", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Bid = ", DoubleToStr(MarketInfo(Symbol(),MODE_BID), MarketInfo(Symbol(),MODE_DIGITS)));
         }
         else
         {
            err = GetLastError();
            Print("Error!. Break Even #", OrderTicket(), " order modify failed with error(",err,")");
         }
       }
   }
   //
   if (OrderType() == OP_SELL) 
   {
       if (OrderStopLoss() <= OrderOpenPrice() && OrderStopLoss() != 0) return;
       
       if (MarketInfo(Symbol(),MODE_ASK) <= OrderOpenPrice() - Break_Even*mp*MarketInfo(Symbol(),MODE_POINT))
       {
         sl = OrderOpenPrice() ;
         while(IsTradeContextBusy()) Sleep(100);
         result = OrderModify(OrderTicket(),OrderOpenPrice(), NormalizeDouble(sl, MarketInfo(Symbol(),MODE_DIGITS)), OrderTakeProfit(), 0, CLR_NONE);
         if (result)
         {           
            Print("Break Even stop updated: # ", OrderTicket(), "; SL = ", DoubleToStr(sl, MarketInfo(Symbol(),MODE_DIGITS)), "; Ask = ", DoubleToStr(MarketInfo(Symbol(),MODE_ASK), MarketInfo(Symbol(),MODE_DIGITS)));
         }
         else
         {
            err = GetLastError();
            Print("Error!. Break Even #", OrderTicket(), " order modify failed with error(",err,")");
         }
       }
   }
}
    
 
double CalcDistance(double risk, double lotsize)
{
   risk=AccountBalance()*risk/100;
   return (risk/MarketInfo(Symbol(),MODE_TICKVALUE)/mp/lotsize);
}

 
double GetLastProfit(double& lotsize)
{
   int t=OrdersTotal();
   double p=0;
   datetime mt=0;
   
   for (int i=t-1;i>=0;i--)
   {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderCloseTime()>mt)
         {
            mt=OrderCloseTime();
            p=OrderProfit();
            lotsize=OrderLots();
         }
      }
   }
   
   return (p);
}

Here is my new EA vision, I has a scalper_turbo setting which will make small but frequent profit. Please remember to give feedback.

148

(18 replies, posted in Forex E-books.)

I think in this forum there were somewhere a book about how ti make efficient scalper robots or someone recommended it here cant remember exactly

149

(4 replies, posted in Ask the Forex Expert)

I have attached an Scalper EA. I want to use the EA one Direction Long or Short (Buy or Sell).But When I run the EA  one direction (Long or Short) it has show Error (Can't open order).but when I select Long and Short at a time it run Smothy. If any body fix the Error I will be highly pleased and oblized thereby.

Thanks and best wishes

REZA KHAN

thanks , but please indicate the time frame best for the EA scalper robot and the broker you have used for it. moreover have you tried it on a live account ?

Posts found: 141 to 150 of 857

Pages Previous 1 13 14 15 16 17 86 Next

Scalper → ► MT4talk - FREE Forex Robots and more... → Search results


NOTE: Hacked or illegal versions of copyrighted Forex robots are highly prohibited on MT4talk.com. If you upload any illegal version of any copyrighted Forex robot, your forum account will be banned. No exceptions.

 

IMPORTANT: MT4talk.com is a public Forex forum, where forum members can upload open source Forex robots to share with other members. MT4talk.com forum does not sell or rent Forex robots, and does not provide guarantee or support for the uploaded Forex robots! If you have any question about any Forex robot, please open a forum topic! If you have a question about your forum account, contact: mt4talk@gmail.com

CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

Disclaimer - No representation is being made that any Forex account will or is likely to achieve profits or losses similar to those shown on backtests in this forum. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. 
All information on this forum is for educational purposes only and is not intended to provide financial advice. Any statements posted by forum members about profits or income expressed or implied, do not represent a guarantee. Your actual trading may result in losses as no trading system is guaranteed. You accept full responsibilities for your actions, trades, profit or loss, and agree to hold the MT4talk team and forum members of this information harmless in any and all ways.


Copyright MT4talk.com Forum Rules - Privacy Policy.