Wednesday 31 August 2011

FX-PriceBoard - MT4 Indicator

This is a Forex Price Quotes Board - MetaTrader MT4 Indicator

Get an overview of where the strength and weakness lies in the individual currencies.

Forex Price Board displaysReal Time
  • Forex Exchange Rates 
  • Metal Prices
  • Futures
  • Indices

Once the code is finalised it will be released here as an ex4 download
Also see: http://nigel-forex.blogspot.co.uk/2016/02/fx-priceboard-mt5-indicator.html







Tuesday 23 August 2011

FX-Invaders - MT4 Indicator

To give you an idea of the flexability of MT4, text and label object can be drawn or plotted progmatically, during an episode of insanity i created a MT4 Indicator called FX-Invaders... This gives you an idea of what can be done with MQL4.

Although i had not completed this script it was fun to watch Invaders swarm around a particular currency launching a bombardment... showing that particular currency to be weak. Once i have some free time i may finish this script and publish it here on my Nigel Forex Blog :)

I was having some fun with this, including the function names... I had to laugh at this one:
ExecuteSaucerAttack("CHF", "USD", "heavy", 5);

FX-Invaders (c)2010 Nigel Martin

Algo Trading - TedTalks

I recently watched an excellent TEDGlobal talk by Kevin Slavin - He is an algorithm expert from the USA.

It appears that the algorithms responsible for Amazons pricing model went mad and decided that a book - "The Making of a Fly" had a fair value of $1.7m this later increased to $23.6 million plus shipping and handling!

Kevin talks about the "Flash Crash of 2.45" where 9% was wiped off the Dow. This phenomenon occured due to automated algorithmic trading.

It is said that 70% of the trading on the US stock market is based on algorithmic trading. It is for that reason i concentrate my efforts on Automated Forex Trading Systems.

Kevin Slavin: How algorithms shape our world 

http://www.youtube.com/watch?v=TDaFwnOiKVE


Comments welcome !

FX Order Info - MT4 Indicator

Download FX Order Info Indicator for MetaTrader 4 - Features

Order Info provides you with an overview of  
BUY or SELL, CURRENT or PENDING Orders
on a single currency pair.

See your Grid Trades and Multi Order Positions at a glance 





FX Order Info Displays Real Time:
  • Order Quantity
  • Number of Lots
  • Total Pips Profit
  • Total Money Profit
  • % of Balance (per position)
  • % of Free Margin (per position)



Download
Version: 1.0
Release Date: SEPT 2011

FX OrderInfo-v1.0.ex4


Release Notes
Only tested on Demo Account with MetaTrader 4 - Alpari Version 4.00 Build 402
Coded to handle 2, 3,4 and 5 Digit Brokers - To be tested  
 
Bugs List / Criticisms
Only works with black background
Not tested with (example) EURUSDm Symbol Names
FX-OrderInfo must be the first Indicator attached to chart

Bugs Fixed List
n/a

Future Improvements
  • Do look up on AccountCurrency and convert to £ $ € ¥
  • Provide alternative color scheme for non black backgrounds
  • "FX-OrderInfo must be the first Indicator attached to chart"
    - Allow indicator to work in any subwindow
  • MetaTrader 5 Version
Documentation
TBA

Licence
Expires: End 2012
Free Version works with Demo Account Only
Live Account KEY available on request $20
Software supplied as is with no warranty
Software (c)2011 Nigel Martin

Source Code
Price on Application

Purchase
This Version is FREE








Monday 22 August 2011

GridTraderPro - In Development. $1m - $19m in 25 Trades

Here is a sample of my GridTraderPro EA that i have been developing over the last few months. The returns are sky high as is the risk and the drawdowns. At this time i am not prepared to release the souce code to all and sundry. however should you be able to make a major contribution to this work then i may release the source code on an individual basis.

I do intent to publish as much detail as i can, thus prompting constructive discussion.

This "Strategy Tester Report" shows GridTraderPro on the EURUSD producing some quite respectable returns over a 2 month period. It has to be remembered that this is cherry picked to show what can happen. Similarly $1m can turn in to ZERO in just a few trades. The MaxRiskPerTrade is set to 25% of free margin - which in my opinion is insane, tweaking it down to say 10% (or less) could be a more reasonable risk factor.

GridTraderPro

GridTraderPro - $1 million > $19 million in 2 months

MQL4 Trailing Stop and Exit

The standard MT4 Platform is usually supplied with an example Expert Advisor called "Moving Average.mq4" Within this script is a function called CheckForClose() This function can be expaned upon to deal with trailing stops &/or exits. This particlar code block uses the Magic number parameter to select the correct order. Just call the function TrailingStops() from within the start loop.
 #define MAGIC 20110725  
 // or get this from  
 // extern int EA_Unique_No = 444888;  
 extern int TrailingStop = 400; // as in 40 pips for 5 Digit broker

 //+------------------------------------------------------------------+  
 //| Check for Exits / Trailing Stops                |  
 //+------------------------------------------------------------------+  
 void TrailingStop()  
 {  
   //---- go trading only for first tiks of new bar  
   if(Volume[0]>1) return;  
   //----  
   for(int i=0;i<OrdersTotal();i++)  
   {  
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)    break;  
    if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;  
    //---- check order type  
    if(OrderType()==OP_BUY)  
    {  
      // orig  
      //if(Open[1]>ma && Close[1]<ma) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);  
      //break;  
      // Check for trailing stop  
      if(TrailingStop > 0)  
      {  
       if(Bid-OrderOpenPrice() > Point*TrailingStop)  
       {  
         if(OrderStopLoss() < Bid-Point*TrailingStop)  
         {  
          OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);  
          return(0);  
         }  
       }  
      }  
    } // /if buy  
    if(OrderType()==OP_SELL)  
    {  
      // Check for trailing stop  
      if(TrailingStop > 0)  
      {  
       if((OrderOpenPrice()-Ask) > (Point*TrailingStop))  
       {  
         if((OrderStopLoss() > (Ask+Point*TrailingStop)) || (OrderStopLoss()==0))  
         {  
          OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);  
          return(0);  
         }  
       }  
      }       
    }  
   }  
   //----  
 }  

MQL4 Magic Number Provision

This include script assigns a preset magic number to an EA, it can be useful during development as it means you you dont have to manually reassign the magic number to the EA every time you recompile it.

I placed all this code in an include file called "Inc_AssignMagic.mq4" and then referenced it in my EA using the directive: #include <Inc_AssignMagic.mqh>


From OrderSend you can call the function AssignMagic(Symbol()) to populate the magic number for the order. Please note this is not suitable for multiple time frames, but could be easy adapted.

//+------------------------------------------------------------------+
//|                                              Inc_AssignMagic.mqh |
//|                               Copyright © Jul 2011, Nigel Martin |
//|                                  http://nigel-forex.blogspot.com |
//+------------------------------------------------------------------+
//#property copyright "©2011, Nigel Martin"
//#property link      "http://nigex-forex.blogspot.com"

// Version 1.0

//+------------------------------------------------------------------+
//| Return Magic Number                                              |
//+------------------------------------------------------------------+

 int AssignMagic(string symbol)
 {
    // AUD
    if(symbol == "AUDCAD") { return(111111); }
    if(symbol == "AUDJPY") { return(111222); }
    if(symbol == "AUDNZD") { return(111333); }
    if(symbol == "AUDUSD") { return(111444); }

    // CAD
    if(symbol == "CADJPY") { return(333111); }
  
    // CHF
    if(symbol == "CHFJPY") { return(333222); }
  
    // EUR
    if(symbol == "EURAUD") { return(555111); }
    if(symbol == "EURCAD") { return(555222); }
    if(symbol == "EURCHF") { return(555333); }
    if(symbol == "EURGBP") { return(555444); }
    if(symbol == "EURJPY") { return(555555); }
    if(symbol == "EURUSD") { return(555666); }
  
    // GBP
    if(symbol == "GBPCHF") { return(777111); }
    if(symbol == "GBPJPY") { return(777222); }
    if(symbol == "GBPUSD") { return(777222); }

    // JPY
  
    // NZD
    if(symbol == "NZDUSD") { return(014111); }

    // USD
    if(symbol == "USDCAD") { return(021111); }
    if(symbol == "USDCHF") { return(021222); }
    if(symbol == "USDJPY") { return(021333); }
  
    return(0);       
 }

Formatting Source code for your Blog - MQL4 MQL5 ASP PHP CSS JavaScript HTML ASP.Net C# VB.Net Visual Basic

Here is a very useful Source Code Formatter which is very handy if you write a blog Its great, there are no need for hosted css files or anything ... Just copy your source code in the box ... press the go button and then copy out the formatted html ... brilliant !

http://codeformatter.blogspot.com/2009/06/about-code-formatter.html

Here is an example

 //+------------------------------------------------------------------+ 
//| 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) break; 
   if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) 
    { 
     if(OrderType()==OP_BUY) buys++; 
     if(OrderType()==OP_SELL) sells++; 
    } 
   } 
    
  // return orders volume 
  if(buys>0) return(buys); 
  else    return(-sells); 
} 
  

You can configure a number of format settings, however this is the code block i use for this blog:

 
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> 
Your Code Block</code></pre> 

Nigel Forex Blog - Welcome

Thanks for dropping by my forex blog ! I have studied technical analysis of Forex Markets for a number of years now; and have come to the realisation that i may as well be flipping a coin (or burgers)

I have coded and backtested numerous automated TA trading systems (MT4) with negative results. Although, I have doubled forex demo accounts in one week using pivot points and also trendline analysis, only to give it all back in half the time. I cannot seem to achieve any consistancy with TA.

Dare i say that TA does in fact work... Thats if the definition of "working" is to blow up your account. Although TA must be a gift from the gods for bucket shops who push it with their "TA 101 Resources and Education" and hundreds of lagging indicators included in their trading platforms ... So i am quite happy with TA, as it probably goes towards ensuring there is fresh supply of new losers entering the market every day.

No doubt i will get flamed for this at some point, i dont care, thats my stance :) 

My focus has turned to Order Management, Risk/Reward and Position Sizing; using Grid Trading techniques. According to many forums and blog posts "The Grid Trade has been done to death" 

- However i am not sure that i can agree with this is as i have been working on the ongoing development of an MT4 Expert Advisor - i have called it GridTraderPro (©2011 Nigel Martin) Through out back tests i have observed a smooth equity curve producing 20x the initial account deposit in just 2 months. $1m become $20m .. Now these are the kind of profits i had been looking for.  

I will be publishing a number of Grid Trading articles and MT4 Scripts that maybe useful to others in their trading. 

Good Trading 
Nigel 


HIGH RISK WARNING & DISCLAIMER: Forex trading carries a high level of risk that may not be suitable for all investors. Leverage creates additional risk and loss exposure. Before you decide to trade foreign exchange, carefully consider your investment objectives, experience level, and risk tolerance. You could lose some or all of your initial investment; 

All the information in Nigel-Forex Blog website is for educational purposes only and is not intended to provide financial advise. Any statements about profit or income, expressed or implied, does 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 and loss; and you agree, not to hold Nigel Forex, its owners and operators responsible for your actions. 

No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. In fact, there are frequently sharp diferences between hypothetical performance results and the actual results subsequently achieved by any trading program. Hypothetical trading does not involve any financial risk and no hypothetical trading record can completely account for the impact of financial risk in actual trading.