Author: Copyright � 2008, IBFX.com
Orders Execution
It automatically opens orders when conditions are reached
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
5.00 %
Total Trades 110
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.08
Gross Profit 6.80
Gross Loss -125.62
Total Net Profit -118.82
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
10.00 %
Total Trades 146
Won Trades 18
Lost trades 128
Win Rate 0.12 %
Expected payoff -4.30
Gross Profit 72.00
Gross Loss -700.39
Total Net Profit -628.39
-100%
-50%
0%
50%
100%
Quick Buy
//+-------------------------------------------------------------------------+
//|                                                    IBFX - Quick Buy.mq4 |
//+-------------------------------------------------------------------------+
#property copyright "Copyright © 2008, IBFX.com"
#property link      "www.ibfx.com"
//----
int start()
 {
      /*+-------------------------------------------------------------------------+
         Because these scripts are meant to execute fast there are no user 
         external inputs. Make sure to modify the settings below, then compile 
         the script before assigning a hot key to it and using it.
         The magicNumber HAS TO TO BE THE SAME ON ALL SCRIPTS if you change it 
         here make sure to change it on all scripts!!!
         Do not forget to click on COMPILE once your changes have been made!!!
      +-------------------------------------------------------------------------+*/
         int   MagicNumber = 1375; 
      double          Risk = 1.0;       
         int      StopLoss = 95;     // Number in Pips ie: 50 for 50 pips.
         int  ProfitTarget = 20;     // Number in Pips ie: 50 for 50 pips.
         int      Slippage = 3;
        bool      MiniLots = True;  // Does your broker offer mini micro lots such as 0.01 lot?
      string    Commentary = " Manual Buy ";
      string      FontName = "Arial";
         int      FontSize = 12;
      
      //+-------------------------------------------------------------------------+
      //|               DO NOT MODIFY ANYTHING BELOW THIS LINE!!!                 |
      //+-------------------------------------------------------------------------+
      //---- A few checks before we get started
      if( !IsConnected()   ) { Alert( Commentary + " - No Connection!!" );               return(0); }
      
      //---- Specific Vars
      int        Action = OP_BUY;
      double  InitPrice = Ask;
      
      //---- Global Vars
        bool      Done = False;
      string   Symbole = Symbol();
         int    Ticket = 0; 
         int ErrorCode = 0;
      double   MaxLots = MarketInfo( Symbole, MODE_MAXLOT );
      double      Lots = MM( Symbole, Risk, MiniLots );
      
      
      //---- Let's place the order.  
      while( !Done )
      {     
         double FillPrice = Ask;
         double StopPrice = Bid;
                  		
         if( MathAbs( InitPrice - FillPrice ) > Slippage * Point ) { Done = true; }  
         Comment( "Placing Long Order, please wait ..." );						   
         Wait();
         Ticket = OrderSend( Symbole, Action, Lots, FillPrice, Slippage * Point, StopLong( StopPrice, StopLoss ), TakeLong(FillPrice, ProfitTarget), Commentary, MagicNumber, 0, CLR_NONE );
         if( Ticket >= 0 )   { Done = true; }
         else 
         {
            ErrorCode = GetLastError();
                 if( ErrorCode == 4109 ) { Alert( Commentary + " - You did not allow live trading!" ); Done = true; }
            else if( ErrorCode ==  134 ) { Alert( Commentary + " - Not enough Money!" );               Done = true; }
            else if( ErrorCode ==  138 || ErrorCode ==  136 || ErrorCode ==  135 ) { Alert( Commentary + " - Requote/Slippage, run the script again" ); Done = true; }
            else                         { Alert( Commentary +  " Error: " + ErrorCode ); }
         }
      }
      Comment("");
       
   //----
   return(0);
}
//+-------------------------------------------------------------------------+

//+-------------------------------------------------------------------------+
//+                               Wait                                      +
//+-------------------------------------------------------------------------+
void Wait() { while( IsTradeContextBusy() ) { Sleep(50); } }
//+-------------------------------------------------------------------------+

//+-------------------------------------------------------------------------+
//| Calculate Stop Short                                                    |
//+-------------------------------------------------------------------------+
double StopLong(double price,int stop)
{
 if(stop==0) { return(0); }
 else        { return(price-(stop*Point)); }
}
//+-------------------------------------------------------------------------+
//| Calculate Profit Target Long                                            |
//+-------------------------------------------------------------------------+
double TakeLong(double price,int take)
{
 if(take==0) {  return(0);}
 else        {  return(price+(take*Point));}
}
//+-------------------------------------------------------------------------+

//+-------------------------------------------------------------------------+
//|                      Money Managment                                    |   
//+-------------------------------------------------------------------------+   
double MM( string Sym, double Risk, bool BrokerAllowsFractionalLots )
{
 double MinLots = MarketInfo(Sym,MODE_MINLOT);
 double MaxLots = MarketInfo(Sym,MODE_MAXLOT);
 double Leverage = AccountLeverage();
 double LotSize = MarketInfo(Sym,MODE_LOTSIZE);
 double LotStep = MarketInfo(Sym,MODE_LOTSTEP);
 
 double FinalAccountBalance =  MathMin( AccountBalance(), AccountEquity() );
 int NormalizationFactor = 0;
 double Lots = 0.0;
 
 if(LotStep == 0.01) { NormalizationFactor = 2; }
 if(LotStep == 0.1)  { NormalizationFactor = 1; }
   
 if( BrokerAllowsFractionalLots == true)
 {
   Lots = (FinalAccountBalance*(Risk/100.0))/(LotSize/Leverage);
   Lots = StrToDouble(DoubleToStr(Lots, NormalizationFactor));
   if (Lots < MinLots) { Lots = MinLots; }
   if (Lots > MaxLots) { Lots = MaxLots; }
 }
 else if(BrokerAllowsFractionalLots == false)
 {
   Lots = (FinalAccountBalance*(Risk/100.0))/(LotSize/Leverage);
   Lots = MathRound(Lots);
   if (Lots < MinLots) { Lots = MinLots; }
   if (Lots > MaxLots) { Lots = MaxLots; }
 }
 return( Lots );
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---