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
0.00 %
Total Trades 263
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -4.69
Gross Profit 4.00
Gross Loss -1238.77
Total Net Profit -1234.77
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
4.00 %
Total Trades 136
Won Trades 5
Lost trades 131
Win Rate 0.04 %
Expected payoff -3.80
Gross Profit 19.80
Gross Loss -536.13
Total Net Profit -516.33
-100%
-50%
0%
50%
100%
Quick Sell
//+-------------------------------------------------------------------------+
//|                                                   IBFX - Quick Sell.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 Sell ";
      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_SELL;
      double  InitPrice = Bid;
      
      //---- 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 );
      Comment( " Placing Short Order, please wait ..." );	
      //---- Let's place the order.  
      while( !Done )
      {     
         double FillPrice = Bid;
         double StopPrice = Ask;
                  
         if( MathAbs( InitPrice - FillPrice ) > Slippage * Point ) { Done = true; }  						            								   					   
              Wait();
              Ticket = OrderSend( Symbole, Action, Lots, FillPrice, Slippage * Point, StopShort( StopPrice, StopLoss ), TakeShort(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 StopShort(double price,int stop)
{
 if(stop==0) { return(0); }
 else        { return(price+(stop*Point)); }
}
//+-------------------------------------------------------------------------+
//| Calculate Profit Target Short                                           |
//+-------------------------------------------------------------------------+
double TakeShort(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 ---