<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeremy Whittaker &#187; Metatrader</title>
	<atom:link href="http://www.jeremywhittaker.com/category/forex/metatrader-forex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeremywhittaker.com</link>
	<description>Building robots using MetaTrader to exploit the simplicity of the world</description>
	<lastBuildDate>Thu, 16 Jun 2011 06:38:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Whittaker Hourly ATR volatility indicator for Metatrader</title>
		<link>http://www.jeremywhittaker.com/2011/06/15/whittaker-hourly-atr-indicator-for-metatrader/</link>
		<comments>http://www.jeremywhittaker.com/2011/06/15/whittaker-hourly-atr-indicator-for-metatrader/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 06:33:14 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[average true range]]></category>
		<category><![CDATA[ex4]]></category>
		<category><![CDATA[forex atr]]></category>
		<category><![CDATA[forex average true range]]></category>
		<category><![CDATA[Hourly atr]]></category>
		<category><![CDATA[metatrader]]></category>
		<category><![CDATA[mql4]]></category>
		<category><![CDATA[Whittaker Hourly ATR]]></category>
		<category><![CDATA[WhittakerHourlyATR]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=1039</guid>
		<description><![CDATA[I started to think recently about the ATR indicator and how it may be useful in markets that open and close.  However, it seems to me the indicator is completely flawed at measuring volatility in the Forex markets.  My theory behind this opinion is the simple fact that the Forex markets are open 24 hours [...]]]></description>
			<content:encoded><![CDATA[<p>I started to think recently about the ATR indicator and how it may be useful in markets that open and close.  However, it seems to me the indicator is completely flawed at measuring volatility in the Forex markets.  My theory behind this opinion is the simple fact that the Forex markets are open 24 hours a day.  So how could averaging the low volatile hours before a major market open (New York, London, or Asia) be relevant?</p>
<p>Traders who are well versed in Forex understand that even though the markets are open 24 hours a day there are best trading hours for different strategies.  This is simply due to the fact that there exists common low volatile hours and common high volatile hours.  For instance the New York and London opens you can expect the Forex markets to move.</p>
<p>So when I decided to create this indicator I had to think of what variables I would be measuring.  It was then I came up with the following theory.  Why not measure the average range of the same hour over a period of look back days.  Then take the average range of the current bar and compare it to the average that it was expected to move that hour based on x historical look back days.  This seemed much more relevant to me.  So that is exactly what this indicator will do. </p>
<p>White Line – The range of the current bar (moving average of one bar)</p>
<p>Blue Bar – Means high volatility. If a bar is blue it means the market has moved 150% in that hour than what it was “expected” to do.</p>
<p>Red Bar – Means low volatility.  If a bar is red it means the market has moved 50% in that hour than what it was “expected” to do.</p>
<p>Green Bar – Normal market volatility.  If the bar is green then the range for that bar falls between 50% and 150% of its expectancy.</p>
<p> The Metatrader indicator can be downloaded here:<br />
<a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/06/WhittakerHourlyATR.ex4">WhittakerHourlyATR.ex4</a><br />
<a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/06/WhittakerHourlyATR.mq4">WhittakerHourlyATR.mq4</a></p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/06/whittakerATRDaily.jpg"><img class="aligncenter size-medium wp-image-1040" title="whittakerATRDaily" src="http://www.jeremywhittaker.com/wp-content/uploads/2011/06/whittakerATRDaily-300x135.jpg" alt="" width="300" height="135" /></a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2011%2F06%2F15%2Fwhittaker-hourly-atr-indicator-for-metatrader%2F&amp;title=Whittaker%20Hourly%20ATR%20volatility%20indicator%20for%20Metatrader" id="wpa2a_2"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2011/06/15/whittaker-hourly-atr-indicator-for-metatrader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How MT4 Calculates Spread and How to Manually Change it.</title>
		<link>http://www.jeremywhittaker.com/2011/04/09/how-mt4-calculates-spread-and-how-to-manually-change-it/</link>
		<comments>http://www.jeremywhittaker.com/2011/04/09/how-mt4-calculates-spread-and-how-to-manually-change-it/#comments</comments>
		<pubDate>Sat, 09 Apr 2011 09:26:17 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=1022</guid>
		<description><![CDATA[MT4 has a crude way of calculating the spread on each trade.  It basically takes the current market spread at the time you run your backtest and applies that to all of your trades.  Unfortunately if someone is programming and testing on the weekends all of their results are going to be skewed because of [...]]]></description>
			<content:encoded><![CDATA[<p>MT4 has a crude way of calculating the spread on each trade.  It basically takes the current market spread at the time you run your backtest and applies that to all of your trades.  Unfortunately if someone is programming and testing on the weekends all of their results are going to be skewed because of the fact that the spreads on the weekend/after hours are so high.  You can check the spread that your MT4 platform is going to use by clicking on symbol properties button from within your tester.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/04/Symbol-Properties.jpg"><img class="aligncenter size-full wp-image-1023" title="Symbol Properties" src="http://www.jeremywhittaker.com/wp-content/uploads/2011/04/Symbol-Properties.jpg" alt="" width="299" height="224" /></a></p>
<p>If you want to statically set this variable for your back test purposes you need to download spread changer.  It can be found here.  <a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/04/SpreadChanger.exe">http://www.jeremywhittaker.com/wp-content/uploads/2011/04/SpreadChanger.exe</a></p>
<p>Using this utility is not exactly straightforward.  You need to find the file named Symbols.sel within your MT4 program files directory.  Once you find the Symbols.sel file drag and drop it onto the Spreadchanger.exe utility and it will allow you to modify it. </p>
<p>The last step is you need to add a fake proxy server to your MT4 platform to trick it from accessing the internet.  Because if it can access the server it will over ride your setting.  You must also edit the symbols.sel file while your platform is closed.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2011%2F04%2F09%2Fhow-mt4-calculates-spread-and-how-to-manually-change-it%2F&amp;title=How%20MT4%20Calculates%20Spread%20and%20How%20to%20Manually%20Change%20it." id="wpa2a_4"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2011/04/09/how-mt4-calculates-spread-and-how-to-manually-change-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Swiss Swissy Scalper strategy eurchf</title>
		<link>http://www.jeremywhittaker.com/2011/02/13/swissy-scalper-strategy-eurchf/</link>
		<comments>http://www.jeremywhittaker.com/2011/02/13/swissy-scalper-strategy-eurchf/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 07:19:33 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=941</guid>
		<description><![CDATA[Two strategies built into one conservative and aggressive. Set via input Second strategy labeled aggressive. EUR/CHF 1 hour Stealth mode where Stop loss and profit are not sent to broker. Set via input NFA input enabled on brokers who do not allow for hedging GMT offset input S1 status used for strategy 1 trades Set [...]]]></description>
			<content:encoded><![CDATA[<p>Two strategies built into one conservative and aggressive.  Set via input<br />
Second strategy labeled aggressive.<br />
EUR/CHF 1 hour<br />
Stealth mode where Stop loss and profit are not sent to broker.  Set via input<br />
NFA input enabled on brokers who do not allow for hedging<br />
GMT offset input<br />
S1 status used for strategy 1 trades<br />
Set a slippage input value that cannot be exceeded<br />
Set risk level .01=1% of capital gone if you stop out .05=5% etc.<br />
Maximum stop loss value of 150 adjusts dynamically<br />
Maximum profit value of 15 adjusts dynamically<br />
MMLots function determines how many lots to trade<br />
NormalizeLots function<br />
CountBalance function<br />
RecoveryLot function<br />
RecoverTrades function<br />
Recover function takes two inputs magic number and order type – returns ticket # if match<br />
RefreshOrders function – changes variable to count how many orders are open that do not match magic2 or magic3<br />
Fiforule function – returns true if there are no open orders but not magic2 or magic3 &#038; strategy 1 long open false &#038; strategy 2 short open false &#038; strategy 2 long open false &#038; strategy 2 open false<br />
s1_direction function –<br />
Return 2 if:<br />
CCI 15 minute period 8 greater than 0 or RSI 15 minute period 6 greater than 50 then once this becomes false for one hour<br />
Return 3 if:<br />
CCI 15 minute period 8 less than 0 or RSI 15 minute period 6 less than 5 once this becomes not true for one hour<br />
Return 0 if:<br />
On first run??<br />
Return 1 by default<br />
dayRange_15M function –<br />
If in first hour of trading return highest high of the last 24 hours and the lowest low of the last 24 hours<br />
Else if not first hour take the highest high and lowest low of time since midnight<br />
S1_setRules function –<br />
RSI 15 minute period 6 is in the middle 40-60<br />
Countdown 1hr if cci15m period8 switched or rsi15m period6 switched<br />
If spread1 is exceeded it will still use daydirection_filter<br />
Sets variable spread is greater than allowed<br />
If the spread is greater than allowed set time 21 and time 0 else set time 21 and 1<br />
S1_openBuyRule –<br />
If rsi 15m p6 is not in the middle exit<br />
If the spread is greater than allowed and day direction filter is false exit<br />
If it has been more than 1hr since cci15mp6 >0 or it has been more than 1hr since rsi15mp6 > 50 exit<br />
If less than 1hr since ccim15p6 switch and short exit ??<br />
If spread is too high then if you are in the first 12 hours of trading take the close of previous midnight and compare to the close of this last midnight; if the close of this last midnight is less than the close of the previous midnight exit<br />
If spread is too high then if you are in the second 12 hours of trading take the close of midnight and the close of now.  If the close of now is less than the close of midnight exit<br />
If you make it to the end of all these rules return s1_buy which is a bool so I’m assuming you’re setting all the variables which makes it true??<br />
S1_openSellRule –<br />
bool<br />
Opposite of s1_openBuyRule<br />
S1_closeBuyRule-<br />
1.	 If stealth is set to true or the current take profit is 0 then if take profit variable has been set by input which it has to 10 then return true<br />
2.	 If price below 15m low then return true<br />
3.	Bool12_f is false by default.  However, if set to true then<br />
a.	If cci 15m period 8 greater than 0 or rsi 15m period6 greater than 50 do nothing<br />
b.	If cci 15m period 8 two bars ago less than the cci 15m period 8 from one bar ago and the rsi 15m period 6 two bars ago less than the rsi 15m period 6 on bar ago do nothing<br />
c.	If a and b are false then If order has been open more than 1hr and is not profitable then return true<br />
4.	bool11_t is set true by default<br />
a.	if the order has been open more than 1hr proceed to next step<br />
b.	cci 15m p8 > 0 and rsi 15m period 6 > 50 and trade is profitable then return true<br />
c.	if trade has been open 24 hours return true<br />
s1_closeSellRule<br />
	opposite as s1_closebuyrule<br />
s1_openBuy –<br />
set the stop loss to the low of m_15<br />
however int_200 specificies the largest stop loss.  So if stop loss is greater than int_200 set it to 200<br />
int_20 is the minimum stop loss so if the low of m_15 less than int_20 set it to 20<br />
if the low_m15 is not greater than 0 then stop loss = 20<br />
if the stop loss is greater than allowed by broker then set stop loss to max allowed by broker marketinfo_stoplevel<br />
if stealth is true then tp = 50 else tp =10<br />
if take profit is less than allowed (marketinfo_stoplevel) then set it to the minimum<br />
Open order with parameters<br />
S1_openSell-<br />
	Opposite as s1_openBuy<br />
s1_buyControl<br />
if the current stop loss and take profit equal 0 then<br />
	if stealth_buy_tp_1 < then allowed set to what is allowed marketinfo_stoplevel<br />
	else take_profit_4 = stealth_buy_tp_1<br />
Modify order</p>
<p>If s1_closeBuyRule is true then close order </p>
<p>If int_SL_override is > 0 then modify SL with this value<br />
Function returns orderticket()<br />
run_Strategy1<br />
Find strategy 1 tickets and print them to log<br />
Use time restrictions to allow trading during only certain hours<br />
Trades on Fridays between certain hours and Mondays between certain hours<br />
If an order is found call s1_buyControl</p>
<p>#include <WinUser32.mqh><br />
#include <stdlib.mqh></p>
<p>#import &#8220;AccuScalper.dll&#8221;<br />
   int GetGmtOffset(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, double&#038; a9[], int&#038; a10[]);<br />
   void Activate(string a0, int a1, int a2, string a3, int a4);<br />
   int GetState();<br />
   int GetStatus();<br />
   int Increment(string a0);<br />
   bool Decrement(int a0);<br />
   bool IsTradeTime(int a0, int a1, int a2, int a3, int a4);<br />
   bool s1_Buy(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, int a8, int a9);<br />
   bool s1_Sell(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, int a8, int a9);<br />
   bool s2_Buy(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7);<br />
   bool s2_Sell(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7);<br />
   bool s1_Init(int a0, int&#038; a1[], int&#038; a2[], int&#038; a3[], int&#038; a4[], int&#038; a5[], int&#038; a6[], int&#038; a7[], int&#038; a8[], int&#038; a9[], int&#038; a10[], int&#038; a11[], double&#038; a12[], double&#038; a13[], double&#038; a14[], double&#038; a15[], int&#038; a16[], int&#038; a17[], int&#038; a18[], int&#038; a19[], int&#038; a20[], int&#038; a21[]);<br />
   bool s2_Init(int a0, int&#038; a1[], int&#038; a2[], int&#038; a3[], double&#038; a4[], int&#038; a5[], int&#038; a6[], int&#038; a7[], int&#038; a8[], double&#038; a9[], double&#038; a10[], double&#038; a11[], int&#038; a12[], int&#038; a13[], int&#038; a14[], int&#038; a15[], int&#038; a16[], int&#038; a17[]);<br />
#import</p>
<p>extern string Ver.1.00 = &#8220;&#8221;;<br />
extern string _1 = &#8220;System Parameters&#8221;;<br />
extern bool Stealth = TRUE;<br />
extern bool Aggressive_true_from_input = TRUE;<br />
extern bool NFA = TRUE;<br />
extern double GmtOffset = -5.0;<br />
extern bool AutoLocalGmtOffset = FALSE;<br />
extern bool AutoServerGmtOffset = FALSE;<br />
extern int magic_2 = 989898;<br />
extern int magic_3 = 123232;<br />
string ReceiptCode = &#8220;111111&#8243;;<br />
extern string _2 = &#8220;Comment Position&#8221;;<br />
extern int TopPadding = 30;<br />
extern int LeftPadding = 20;<br />
extern color TextColor1 = WhiteSmoke;<br />
extern color TextColor2 = LightGray;<br />
extern string _3 = &#8220;Strategy Parameters&#8221;;<br />
extern int Slippage = 3;<br />
extern bool SendEmails = FALSE;<br />
extern string OrderComments = &#8220;&#8221;;<br />
extern string _4 = &#8220;Order Management&#8221;;<br />
extern double LotSize = 0.1;<br />
extern string _5 = &#8220;Ratio Order Management&#8221;;<br />
extern double RiskLevel = 0.2;<br />
extern bool RecoveryMode = TRUE;<br />
bool bool1_f = FALSE;<br />
double double_1000 = 1000.0;<br />
double double_p2 = 0.2;<br />
bool bool2_t = FALSE;<br />
bool bool_t_if_initialize_variables = TRUE;<br />
bool bool_t_if_agressive = TRUE;<br />
int int_3 = 3;<br />
bool bool_if_true_shift_time = TRUE;<br />
int time_hour_equal_1_or_0;<br />
int current_time;<br />
int current_time_minus_gmt;<br />
double time_hour_1;<br />
int time_of_midnight;<br />
int spread_1;<br />
int g_spread_288;<br />
int marketinfo_stoplevel;<br />
double p0001_div_point_or_1;<br />
double lots_2;<br />
double account_balance_x;<br />
bool bool_not_testing = FALSE;<br />
int int_x4 = 0;<br />
int int_x5 = 0;<br />
int int_x6;<br />
string email_subject;<br />
string gs_344;<br />
string gs_352;<br />
int timeframe_M15 = PERIOD_M15;<br />
int buy_tp_10 = 10;<br />
int int_50 = 50;<br />
int int_200 = 200;<br />
int int_20 = 20;<br />
int int_0 = 0;<br />
int color_2 = 16711680;<br />
int color_3 = 255;<br />
int period_6 = 6;<br />
int period_20 = 20;<br />
int period_8 = 8;<br />
double double_70 = 70.0;<br />
double double_30 = 30.0;<br />
double double_64 = 64.0;<br />
double double_36 = 36.0;<br />
bool bool_if_true_rsi_1M_20 = TRUE;<br />
bool bool8_t = TRUE;<br />
bool bool_if_true_get_15M_range = TRUE;<br />
int number_of_hours_to_shift = 12;<br />
bool bool_if_true_rsi15m_period6 = TRUE;<br />
int rsi_15m_middle = 20;<br />
bool bool11_t = TRUE;<br />
bool bool12_f = FALSE;<br />
double double_1 = 1.0;<br />
double double_24 = 24.0;<br />
bool bool13_t = TRUE;<br />
double dbl_hr_multiplier_countdown_2 = 1.0;<br />
double dbl_hr_multiplier_countdown = 1.0;<br />
bool bool14_f = FALSE;<br />
int int_multiply_for_spread = 0;<br />
bool bool_using_daydirection_filter = TRUE;<br />
bool bool16_t = TRUE;<br />
int time_hour_21 = 21;<br />
int time_hour_equal_1 = 1;<br />
int time_hour_21b = 21;<br />
int time_hour_0 = 0;<br />
int timeframe_M5 = PERIOD_M5;<br />
int int_35 = 35;<br />
int int_60 = 60;<br />
int int_200b = 200;<br />
int int_20c = 20;<br />
double percent_range_1 = 1.0;<br />
int int_0d = 0;<br />
int color_5 = 16748574;<br />
int color_6 = 9639167;<br />
int int_36_always_36 = 36;<br />
int period_168 = 168;<br />
int period_275 = 275;<br />
bool bool17_always_true = TRUE;<br />
bool bool_cci_m5_period275 = FALSE;<br />
bool bool19_always_true = TRUE;<br />
double double_1e = 1.0;<br />
double double_12 = 12.0;<br />
double double_24b = 24.0;<br />
bool bool_ask_less_low_m5_true = FALSE;<br />
bool bool21_f = FALSE;<br />
int int_0_always_0 = 0;<br />
bool bool_day_direction_filter = TRUE;<br />
bool bool23_t = TRUE;<br />
int time_hour_21c = 21;<br />
int int_4 = 4;<br />
int time_hour_21d = 21;<br />
int int_0f = 0;<br />
int int_0g = 0;<br />
int int_0h = 0;<br />
int int_0i = 0;<br />
int gi_672;<br />
int gi_676;<br />
int gi_680;<br />
int gi_684;<br />
double profit_made = 0.0;<br />
double int_profit_made = 0.0;<br />
bool bool_margin_less_margin_req = FALSE;<br />
bool bool25;<br />
bool bool_T_mon_fri;<br />
int gi_716;<br />
int num_orders_NOTmagic2or3 = 0;<br />
int ticket_strategy_1_long_open = -2;<br />
int ticket_strategy_1_short_open = -2;<br />
double order_profit = 0.0;<br />
double order_profit_2 = 0.0;<br />
int ticket_strategy_2_long_open = -2;<br />
int ticket_strategy_2_short_open = -2;<br />
double g_ord_profit_756 = 0.0;<br />
double g_ord_profit_764 = 0.0;<br />
int int_0j = 0;<br />
int int_0k = 0;<br />
int int_0l = 0;<br />
int int_0m = 0;<br />
double rsi_15M_Period6;<br />
double rsi_15M_Period6_offset_1;<br />
double rsi_15M_Period6_offset_2;<br />
double rsi_1M_Period20;<br />
double cci_15M_Period8;<br />
double cci_15M_Period8_offset_1;<br />
double cci_15M_Period8_offset_2;<br />
double ma_15M_period8;<br />
bool bool_rsi15M_p6_in_middle = TRUE;<br />
bool bool_rsi15M_p6_in_middle_b = TRUE;<br />
double high_M15 = 0.0;<br />
double low_M15 = 0.0;<br />
bool bool_if_true_spread_grtr_allow = FALSE;<br />
int stealth_buy_tp_1 = 0;<br />
int sl_bid_minus_low = 0;<br />
int stealth_sell_tp_1 = 0;<br />
int sell_sl_1 = 0;<br />
int time_equal_21;<br />
int time_equal_0;<br />
int if_2_long_3_short = 0;<br />
int two_long_3_short = 0;<br />
int within_1hr_cci_rsi_switched;<br />
int datetime_cci_rsi_15m_short = 0;<br />
int datetime_cci_rsi_15m_long = 0;<br />
int g_ticket_940 = 0;<br />
int g_datetime_944 = 0;<br />
int g_ticket_948 = 0;<br />
int g_datetime_952 = 0;<br />
bool bool30_t = TRUE;<br />
int datetime_15m_shift_1 = 0;<br />
int datetime_15m_shift_1_b = 0;<br />
int gi_968 = 0;<br />
double cci_M5_Period168;<br />
double cci_M5_Period275;<br />
double high_m5;<br />
double low_M5;<br />
double high_3;<br />
double low_3;<br />
bool bool_spread = FALSE;<br />
int gi_1024 = 0;<br />
int range_1 = 0;<br />
int gi_1032 = 0;<br />
int percent_of_range_M5 = 0;<br />
int time_x;<br />
int gi_1044;<br />
int g_ticket_1048 = -1;<br />
int gi_1052;<br />
int gi_1056;<br />
int g_datetime_1060;<br />
int g_datetime_1064;<br />
double g_ord_open_price_1068;<br />
int g_ticket_1076 = -1;<br />
int gi_1080;<br />
int gi_1084;<br />
int g_datetime_1088;<br />
int g_datetime_1092;<br />
double g_ord_open_price_1096;<br />
bool bool32_t = TRUE;<br />
int g_datetime_1108 = 0;<br />
int g_datetime_1112 = 0;<br />
string gsa_1116[] = {&#8220;.&#8221;, &#8220;..&#8221;, &#8220;&#8230;&#8221;, &#8220;&#8230;.&#8221;, &#8220;&#8230;..&#8221;};<br />
int gi_unused_1120 = 0;<br />
int gi_unused_1124 = 0;<br />
string gs_1128 = &#8220;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&#8221;;<br />
bool bool33_f = FALSE;</p>
<p>int S1_CheckSymbol() {<br />
   int lia_0[1];<br />
   int lia_4[1];<br />
   int lia_8[1];<br />
   int lia_12[1];<br />
   int lia_16[1];<br />
   int lia_20[1];<br />
   int lia_24[1];<br />
   int lia_28[1];<br />
   int lia_32[1];<br />
   int lia_36[1];<br />
   int lia_40[1];<br />
   double lda_44[1];<br />
   double lda_48[1];<br />
   double lda_52[1];<br />
   double lda_56[1];<br />
   int lia_60[1];<br />
   int lia_64[1];<br />
   int lia_68[1];<br />
   int lia_72[1];<br />
   int lia_76[1];<br />
   int lia_80[1];<br />
   if (s1_Init(int_x6, lia_0, lia_4, lia_8, lia_12, lia_16, lia_20, lia_24, lia_28, lia_32, lia_36, lia_40, lda_44, lda_48, lda_52, lda_56, lia_60, lia_64, lia_68, lia_72, lia_76, lia_80)) {<br />
      buy_tp_10 = lia_0[0];<br />
      int_200 = lia_4[0];<br />
      int_20 = lia_8[0];<br />
      int_0 = lia_12[0];<br />
      period_6 = lia_16[0];<br />
      period_20 = lia_20[0];<br />
      period_8 = lia_24[0];<br />
      double_70 = lia_28[0];<br />
      double_30 = lia_32[0];<br />
      double_64 = lia_36[0];<br />
      double_36 = lia_40[0];<br />
      double_1 = lda_44[0];<br />
      double_24 = lda_48[0];<br />
      dbl_hr_multiplier_countdown_2 = lda_52[0];<br />
      dbl_hr_multiplier_countdown = lda_56[0];<br />
      int_multiply_for_spread = lia_60[0];<br />
      time_hour_21 = lia_64[0];<br />
      time_hour_equal_1 = lia_68[0];<br />
      time_hour_21b = lia_72[0];<br />
      time_hour_0 = lia_76[0];<br />
      timeframe_M15 = lia_80[0];<br />
      return (1);<br />
   }<br />
   return (0);<br />
}</p>
<p>int S2_CheckSymbol() {<br />
   int lia_0[1];<br />
   int lia_4[1];<br />
   int lia_8[1];<br />
   int lia_12[1];<br />
   double lda_16[1];<br />
   int lia_20[1];<br />
   int lia_24[1];<br />
   int lia_28[1];<br />
   double lda_32[1];<br />
   double lda_36[1];<br />
   double lda_40[1];<br />
   int lia_44[1];<br />
   int lia_48[1];<br />
   int lia_52[1];<br />
   int lia_56[1];<br />
   int lia_60[1];<br />
   int lia_64[1];<br />
   if (s2_Init(int_x6, lia_0, lia_4, lia_8, lda_16, lia_12, lia_20, lia_24, lia_28, lda_32, lda_36, lda_40, lia_44, lia_48, lia_52, lia_56, lia_60, lia_64)) {<br />
      int_35 = lia_0[0];<br />
      int_200b = lia_4[0];<br />
      int_20c = lia_8[0];<br />
      percent_range_1 = lda_16[0];<br />
      int_0d = lia_12[0];<br />
      int_36_always_36 = lia_20[0];<br />
      period_168 = lia_24[0];<br />
      period_275 = lia_28[0];<br />
      double_1e = lda_32[0];<br />
      double_12 = lda_36[0];<br />
      double_24b = lda_40[0];<br />
      int_0_always_0 = lia_44[0];<br />
      time_hour_21c = lia_48[0];<br />
      int_4 = lia_52[0];<br />
      time_hour_21d = lia_56[0];<br />
      int_0f = lia_60[0];<br />
      timeframe_M5 = lia_64[0];<br />
      return (1);<br />
   }<br />
   return (0);<br />
}</p>
<p>int init() {<br />
   double l_global_var_8;<br />
   double ld_16;<br />
   if (bool_if_true_shift_time) time_hour_equal_1_or_0 = 0;<br />
   else time_hour_equal_1_or_0 = 1;<br />
   int_x6 = Increment(Symbol());<br />
   gi_676 = LeftPadding;<br />
   gi_672 = TopPadding;<br />
   if (gi_680 != LeftPadding || gi_684 != TopPadding) {<br />
      gi_680 = LeftPadding;<br />
      gi_684 = TopPadding;<br />
   } else GetPos(0, gi_676, gi_672);<br />
   int_0h = 0;<br />
   int_0g = 0;<br />
   email_subject = &#8220;Swissy Accu-Scalper&#8221; + &#8221; ver: &#8221; + &#8220;1.00&#8243; + &#8221; Symbol: &#8221; + Symbol();<br />
   PrintLN(email_subject, TextColor2);<br />
   PrintSep();<br />
   ObjectsRedraw();<br />
   for (int l_count_0 = 0; !IsStopped() &#038;&#038; !IsConnected() || StringLen(AccountName()) <= 0; l_count_0++) {<br />
      PrintLN("Waiting for connection" + PPrint(l_count_0), TextColor1, 2, 2);<br />
      ObjectsRedraw();<br />
      Sleep(150);<br />
   }<br />
   PrintLN("Authentication...", TextColor1, 2, 2);<br />
   ObjectsRedraw();<br />
   int int_authorization = 0;<br />
   ReceiptCode = StringTrimLeft(StringTrimRight(ReceiptCode));<br />
   ReceiptCode = StringSubstr(ReceiptCode, StringLen(ReceiptCode) - 8);<br />
   if (StringLen(ReceiptCode) <= 0) {<br />
      if (GlobalVariableCheck("GV_AccuScalper_REC")) {<br />
         l_global_var_8 = GlobalVariableGet("GV_AccuScalper_REC");<br />
         ReceiptCode = Base36Encode(l_global_var_8);<br />
      } else int_authorization |= 32;  //32 in binary is 100000<br />
   } else {<br />
      ld_16 = Base36Decode(ReceiptCode);<br />
      if (GlobalVariableSet("GV_AccuScalper_REC", ld_16) == 0) int_authorization |= 64; //64 in binary is 1000000<br />
   }<br />
   Activate("1.00", AccountNumber(), IsDemo(), StringTrimLeft(StringTrimRight(ReceiptCode)), 1);<br />
   int_x4 = GetState();<br />
   int_x4 |= int_authorization;<br />
   PrintResponse(int_x4, 2, 2);<br />
   PrintSep();<br />
   ObjectsRedraw();<br />
   bool bool_t_if_initialize = FALSE;<br />
   bool bool_true_init_and_aggressive = FALSE;<br />
   bool_t_if_initialize = S1_CheckSymbol();<br />
   bool_true_init_and_aggressive = S2_CheckSymbol();<br />
   if (bool_t_if_initialize) {<br />
      bool_t_if_initialize_variables = TRUE;<br />
      if (Aggressive_true_from_input) bool_t_if_agressive = bool_true_init_and_aggressive;<br />
      else bool_t_if_agressive = FALSE;<br />
   } else {<br />
      if (bool_true_init_and_aggressive) {<br />
         bool_t_if_initialize_variables = FALSE;<br />
         bool_t_if_agressive = TRUE;<br />
      } else {<br />
         bool_t_if_agressive = FALSE;<br />
         bool_t_if_initialize_variables = FALSE;<br />
      }<br />
   }<br />
   if (!bool_t_if_initialize_variables &#038;&#038; !bool_t_if_agressive) {<br />
      gs_344 = "Error:";<br />
      gs_352 = "This currency is not supported!";<br />
   } else {<br />
      gs_344 = "Aggressive_true_from_input:";<br />
      gs_352 = BPrint(bool_t_if_initialize_variables &#038;&#038; bool_t_if_agressive);<br />
      if (Aggressive_true_from_input &#038;&#038; !(bool_t_if_initialize_variables &#038;&#038; bool_t_if_agressive)) gs_352 = gs_352 + " (not supported)";<br />
   }<br />
   PrintLN(gs_344);<br />
   PrintLN(gs_352, TextColor2, int_0h, int_0g - 1, 5 * (StringLen(gs_344) + 1));<br />
   PrintSep();<br />
   ObjectsRedraw();<br />
   if (!bool_t_if_initialize_variables &#038;&#038; !bool_t_if_agressive) MessageBox("You have selected the wrong currency pair!\nPlease attach Accu-Scalper to a EURCHF chart.", email_subject + ": Warning", MB_ICONEXCLAMATION);<br />
   account_balance_x = double_1000;<br />
   int_x5 = 0;<br />
   if (!IsTesting()) bool_not_testing = TRUE;<br />
   return (0);<br />
}</p>
<p>int deinit() {<br />
   Decrement(int_x6);<br />
   if (IsTesting()) {<br />
      if (!IsVisualMode()) {<br />
         PrintLN("GmtOffset:");<br />
         PrintLN(DoubleToStr(GmtOffset, 1), TextColor2, int_0h, int_0g - 1, 55);<br />
         PrintSep();<br />
         PrintLN("Digits:");<br />
         PrintLN(Digits, TextColor2, int_0h, int_0g - 1, 35);<br />
         PrintLN("spread_1:");<br />
         PrintLN(StringConcatenate(DoubleToStr(spread_1 / p0001_div_point_or_1, 1), " (", spread_1, " pips)"), TextColor2, int_0h, int_0g - 1, 40);<br />
         PrintSep();<br />
      }<br />
      return (0);<br />
   }<br />
   switch (UninitializeReason()) {<br />
   case REASON_CHARTCLOSE:<br />
   case REASON_REMOVE:<br />
      Deleteobjects(0, int_0i);<br />
      int_0i = 0;<br />
      break;<br />
   case REASON_RECOMPILE:<br />
   case REASON_CHARTCHANGE:<br />
   case REASON_PARAMETERS:<br />
   case REASON_ACCOUNT:<br />
      Deleteobjects(1, int_0i);<br />
      int_0i = 1;<br />
   }<br />
   return (0);<br />
}</p>
<p>int waitForContext() {<br />
   for (int l_count_0 = 0; IsTradeContextBusy() &#038;&#038; l_count_0 < 20; l_count_0++) Sleep(15);<br />
   if (l_count_0 >= 20) Print(&#8220;Trade context is buisy more than &#8220;, DoubleToStr(15 * l_count_0 / 1000, 2), &#8221; seconds&#8221;);<br />
   else<br />
      if (l_count_0 > 0) Print(&#8220;Trade context was buisy &#8220;, DoubleToStr(15 * l_count_0 / 1000, 2), &#8221; seconds&#8221;);<br />
   return (l_count_0);<br />
}</p>
<p>int openOrder(int order_type_1, double lots_1, double price_1, double take_profit_1, double stop_loss_1, int magic_1, color color_1, bool stealth) {<br />
   int l_error_68;<br />
   double take_profit_2 = 0;<br />
   double stop_loss_2 = 0;<br />
   if (!stealth) {<br />
      take_profit_2 = take_profit_1;<br />
      stop_loss_2 = stop_loss_1;<br />
   }<br />
   waitForContext();<br />
   int ticket_1 = OrderSend(Symbol(), order_type_1, lots_1, price_1, Slippage * p0001_div_point_or_1, stop_loss_2, take_profit_2, OrderComments, magic_1, 0, color color_1);<br />
   if (ticket_1 > 0) {<br />
      if (stealth) {<br />
         if (OrderSelect(ticket_1, SELECT_BY_TICKET)) {<br />
            waitForContext();<br />
            OrderModify(ticket_1, OrderOpenPrice(), stop_loss_1, take_profit_1, 0, color_1);<br />
         }<br />
      }<br />
      if (SendEmails) SendMail(email_subject, &#8220;Open &#8221; + OpPrint(order_type_1) + &#8220;: [" + Symbol() + "] &#8221; + NormalizeDouble(price_1, Digits));<br />
   } else {<br />
      l_error_68 = GetLastError();<br />
      if (!stealth) return (openOrder(order_type_1, lots_1, price_1, take_profit_1, stop_loss_1, magic_1, color_1, 1));<br />
      Print(OpPrint(order_type_1) + &#8221; operation failed &#8211; error(&#8220;, l_error_68, &#8220;): &#8220;, ErrorDescription(l_error_68));<br />
   }<br />
   return (ticket_1);<br />
}<br />
//closes 2 different strategies orders<br />
//close buy ai_0 =0<br />
//close sell ai_0 =1<br />
//closes order at ask or bid respectively of buy or sell<br />
int closeOrder(int int_closebuy_0_closesell_1, color a_color_4) {<br />
   double l_price_8;<br />
   int l_error_20;<br />
   for (int l_count_16 = 0; l_count_16 < 20; l_count_16++) {<br />
      if (waitForContext() > 5) RefreshRates();<br />
      if (int_closebuy_0_closesell_1 == 0) l_price_8 = Bid;<br />
      else l_price_8 = Ask;<br />
      if (OrderClose(OrderTicket(), OrderLots(), l_price_8, Slippage * p0001_div_point_or_1, a_color_4)) return (-1);<br />
      l_error_20 = GetLastError();<br />
      Print(&#8220;Order close operation failed &#8211; error(&#8220;, l_error_20, &#8220;): &#8220;, ErrorDescription(l_error_20));<br />
      RefreshRates();<br />
   }<br />
   Print(&#8220;Order close operation failed&#8221;);<br />
   return (OrderTicket());<br />
}</p>
<p>double MMLots(double ad_0, double ad_8, int &#038;ai_16) {<br />
   return (NormalizeLots(ad_0 * ad_8 / MarketInfo(Symbol(), MODE_MARGINREQUIRED) / (AccountLeverage() / 100.0), ai_16));<br />
}</p>
<p>double NormalizeLots(double ad_0, int &#038;ai_8) {<br />
   double lot_step = MarketInfo(Symbol(), MODE_LOTSTEP);<br />
   double min_lot = MarketInfo(Symbol(), MODE_MINLOT);<br />
   double max_lot = MarketInfo(Symbol(), MODE_MAXLOT);<br />
   double ld_ret_12 = MathCeil(ad_0 / lot_step) * lot_step;<br />
   ai_8 = 0;<br />
   if (ld_ret_12 < min_lot) {<br />
      ld_ret_12 = min_lot;<br />
      ai_8 = -1;<br />
   }<br />
   if (ld_ret_12 > max_lot) {<br />
      ld_ret_12 = max_lot;<br />
      ai_8 = 1;<br />
   }<br />
   return (ld_ret_12);<br />
}</p>
<p>void CountBalance(double ad_0) {<br />
   profit_made += ad_0;<br />
   if (int_profit_made < profit_made) int_profit_made = profit_made;<br />
}</p>
<p>double RecoveryLot(double ad_0) {<br />
   int switch_max_or_min_lot_exceeded;<br />
   if (int_profit_made > profit_made &#038;&#038; int_0j > int_0l) return (NormalizeLots(2.0 * ad_0, switch_max_or_min_lot_exceeded));<br />
   int_0l = int_0j;<br />
   return (ad_0);<br />
}<br />
//runs countbalance function<br />
int RecoverTrades() {<br />
   int l_count_0 = 0;<br />
   profit_made = 0;<br />
   int_profit_made = 0;<br />
   for (int l_pos_4 = OrdersHistoryTotal() &#8211; 1; l_pos_4 >= 0; l_pos_4&#8211;) {<br />
      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_HISTORY)) {<br />
         if (OrderMagicNumber() != magic_2 &#038;&#038; OrderMagicNumber() != magic_3) continue;<br />
         CountBalance(OrderProfit());<br />
         l_count_0++;<br />
      }<br />
   }<br />
   return (l_count_0);<br />
}</p>
<p>//Go through all the orders return the ticket if magic number and order type match else return -1<br />
int Recover(int a_magic_0, int order_type_3) {<br />
   for (int l_pos_8 = OrdersTotal() &#8211; 1; l_pos_8 >= 0; l_pos_8&#8211;) {<br />
      if (OrderSelect(l_pos_8, SELECT_BY_POS)) {<br />
         if (OrderMagicNumber() == a_magic_0) {<br />
            if (OrderSymbol() == Symbol())<br />
               if (OrderType() == order_type_3) return (OrderTicket());<br />
         }<br />
      }<br />
   }<br />
   return (-1);<br />
}</p>
<p>//go through all orders if order is not magic_2 and not magic_3 increment num_orders_NOTmagic2or3 by 1<br />
void RefreshOrders() {<br />
   num_orders_NOTmagic2or3 = 0;<br />
   for (int l_pos_0 = OrdersTotal() &#8211; 1; l_pos_0 >= 0; l_pos_0&#8211;) {<br />
      if (OrderSelect(l_pos_0, SELECT_BY_POS)) {<br />
         if (OrderSymbol() == Symbol())<br />
            if (OrderMagicNumber() != magic_2 &#038;&#038; OrderMagicNumber() != magic_3) num_orders_NOTmagic2or3++;<br />
      }<br />
   }<br />
}</p>
<p>//return 1 or true if num_orders_notmagic2or3 false &#038;&#038;<br />
//ticket_strategy_1_longOPen false &#038;&#038;<br />
// ticket_strategy_1_short_open false &#038;&#038;<br />
//ticket_strategy_2_long_open false &#038;&#038;<br />
//ticket_strategy_2_short_open false</p>
<p>int FIFOrule() {<br />
   return (num_orders_NOTmagic2or3 <= 0 &#038;&#038; ticket_strategy_1_long_open < 0 &#038;&#038; ticket_strategy_1_short_open < 0 &#038;&#038; ticket_strategy_2_long_open < 0 &#038;&#038; ticket_strategy_2_short_open < 0);<br />
}</p>
<p>//returns 2 for long after 1hr of cci_15m_period8 > 0 or rsi_15m_period6 > 50<br />
//returns 3 for short after 1 hr of cci_15m_period8 < 0 or rsi_15m_period6 < 50<br />
//if returns 2 then you have been in a short period more than an Hour<br />
//if returns 3 then you have been in a long period for more than an hour<br />
int s1_direction() {<br />
   if (cci_15M_Period8 >= 0.0 || rsi_15M_Period6 >= 50.0) datetime_cci_rsi_15m_long = current_time;<br />
   if (cci_15M_Period8 <= 0.0 || rsi_15M_Period6 <= 50.0) datetime_cci_rsi_15m_short = current_time;<br />
   if (datetime_cci_rsi_15m_long > 0 &#038;&#038; current_time &#8211; datetime_cci_rsi_15m_long > 3600.0 * dbl_hr_multiplier_countdown_2) return (2);<br />
   if (datetime_cci_rsi_15m_short > 0 &#038;&#038; current_time &#8211; datetime_cci_rsi_15m_short > 3600.0 * dbl_hr_multiplier_countdown_2) return (3);<br />
   if (datetime_cci_rsi_15m_long == 0 || datetime_cci_rsi_15m_short == 0) return (0);<br />
   return (1);<br />
}</p>
<p>//if you are within the first hour of the day sets high_M15 &#038;&#038; low_m15 as the high and low of yesterday.<br />
//Else set high_m15 to the high of today and low_m15 to todays low<br />
void dayRange_15M() {<br />
   int l_shift_0;<br />
   if (current_time &#8211; time_of_midnight < 3600.0 * number_of_hours_to_shift) l_shift_0 = iBarShift(NULL, timeframe_M15, time_of_midnight - 86400);<br />
   else l_shift_0 = iBarShift(NULL, timeframe_M15, time_of_midnight);<br />
   high_M15 = iHigh(NULL, timeframe_M15, iHighest(NULL, timeframe_M15, MODE_HIGH, l_shift_0 - time_hour_equal_1_or_0, time_hour_equal_1_or_0));<br />
   low_M15 = iLow(NULL, timeframe_M15, iLowest(NULL, timeframe_M15, MODE_LOW, l_shift_0 - time_hour_equal_1_or_0, time_hour_equal_1_or_0));<br />
}</p>
<p>//rsi_15m_period6 set<br />
//rsi_15m_period6_offset_1 Set<br />
//rsi_15m_period6_offset_2 set<br />
//if bool_if_true_rsi_1m_20 = true set it<br />
//set cci_15m_period8<br />
//set cci_15m_period8 offset_1<br />
//set cci_15m_period8 offset_2<br />
//set ma_15m_period8<br />
//sets bool_rsi15m_p6_in_middle true or false<br />
//if </p>
<p>void s1_setRules() {<br />
   int two_for_long_3_for_short;<br />
   HideTestIndicators(TRUE);<br />
   rsi_15M_Period6 = iRSI(NULL, timeframe_M15, period_6, PRICE_CLOSE, time_hour_equal_1_or_0);<br />
   rsi_15M_Period6_offset_1 = iRSI(NULL, timeframe_M15, period_6, PRICE_CLOSE, time_hour_equal_1_or_0 + 1);<br />
   rsi_15M_Period6_offset_2 = iRSI(NULL, timeframe_M15, period_6, PRICE_CLOSE, time_hour_equal_1_or_0 + 2);<br />
   if (bool_if_true_rsi_1M_20) rsi_1M_Period20 = iRSI(NULL, PERIOD_M1, period_20, PRICE_CLOSE, time_hour_equal_1_or_0);<br />
   cci_15M_Period8 = iCCI(NULL, timeframe_M15, period_8, PRICE_TYPICAL, time_hour_equal_1_or_0);<br />
   cci_15M_Period8_offset_1 = iCCI(NULL, timeframe_M15, period_8, PRICE_TYPICAL, time_hour_equal_1_or_0 + 1);<br />
   cci_15M_Period8_offset_2 = iCCI(NULL, timeframe_M15, period_8, PRICE_TYPICAL, time_hour_equal_1_or_0 + 2);<br />
   ma_15M_period8 = iMA(NULL, timeframe_M15, period_8, 0, MODE_SMA, PRICE_MEDIAN, time_hour_equal_1_or_0);<br />
   if (bool_if_true_rsi15m_period6) {<br />
      if (rsi_15M_Period6 >= 50 &#8211; rsi_15m_middle / 2 &#038;&#038; rsi_15M_Period6 <= rsi_15m_middle / 2 + 50) {<br />
         bool_rsi15M_p6_in_middle = TRUE;<br />
         bool_rsi15M_p6_in_middle_b = TRUE;<br />
      }<br />
   }<br />
   if (bool_if_true_get_15M_range) dayRange_15M();<br />
   if (bool13_t) {<br />
      two_for_long_3_for_short = if_2_long_3_short;<br />
      if_2_long_3_short = s1_direction();//2 for long 3 for short<br />
      if (two_for_long_3_for_short != if_2_long_3_short) {<br />
         two_long_3_short = two_for_long_3_for_short;<br />
         if (if_2_long_3_short == 1) within_1hr_cci_rsi_switched = current_time + 3600.0 * dbl_hr_multiplier_countdown;<br />
      }<br />
   }<br />
   if (int_multiply_for_spread > 0) {<br />
      if (spread_1 > int_multiply_for_spread * p0001_div_point_or_1) {<br />
         if (g_spread_288 < spread_1) {<br />
            Print("Strategy1: Safe spread limit exceeded: spread = ", spread_1);<br />
            if (bool_using_daydirection_filter) Print("Strategy1: Using DayDirection filter");<br />
         }<br />
         bool_if_true_spread_grtr_allow = TRUE;<br />
      } else bool_if_true_spread_grtr_allow = FALSE;<br />
   }<br />
   HideTestIndicators(FALSE);<br />
   if (bool_if_true_spread_grtr_allow) {<br />
      time_equal_21 = time_hour_21b;<br />
      time_equal_0 = time_hour_0;<br />
      return;<br />
   }<br />
   time_equal_21 = time_hour_21;<br />
   time_equal_0 = time_hour_equal_1;<br />
}</p>
<p>//exit if rsi is not in the middle<br />
//if spread is too high exit<br />
//if daydirection filter false exit<br />
//if first 12 hours of day then exit if 5M close is less than 5M close of 24hrs ago<br />
//if last 12 hours of day then exit if 5M close is less than 5M close of midnight<br />
//if all the tests pass then call s1_Buy<br />
int s1_openBuyRule() {<br />
   double close_M5_2;<br />
   double close_M5;<br />
   int bar_with_open_time_1;<br />
   int bar_with_open_time_2;<br />
   if (!bool_rsi15M_p6_in_middle) return (0);//exit if rsi 15m period 6 is not in the middle between 40-60<br />
   if (bool_if_true_spread_grtr_allow &#038;&#038; !bool_using_daydirection_filter) return (0);//exit if spread greater than allowed  ?? using daydirection filter=false<br />
   if (bool13_t) {//equals true by default<br />
      if (if_2_long_3_short == 2) return (0);<br />
      if (current_time <= within_1hr_cci_rsi_switched)//60 minute countdown is not over yet<br />
         if (two_long_3_short == 2) return (0);<br />
   }<br />
   if (bool14_f || bool_if_true_spread_grtr_allow) {<br />
      if (current_time - time_of_midnight < 43200.0) {//12 hours<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M15, time_of_midnight - 86400);//24 hours<br />
         bar_with_open_time_2 = iBarShift(NULL, timeframe_M15, time_of_midnight);<br />
      } else {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M15, time_of_midnight);<br />
         bar_with_open_time_2 = time_hour_equal_1_or_0;<br />
      }<br />
      close_M5 = iClose(NULL, timeframe_M15, bar_with_open_time_1);<br />
      close_M5_2 = iClose(NULL, timeframe_M15, bar_with_open_time_2);<br />
      if (close_M5_2 < close_M5) return (0);<br />
   }<br />
   return (s1_Buy(Ask, cci_15M_Period8, rsi_15M_Period6, rsi_1M_Period20, ma_15M_period8, double_30, double_36, buy_tp_10 * p0001_div_point_or_1 * Point, bool8_t, bool_if_true_rsi_1M_20));<br />
}</p>
<p>//exit if rsi is not in the middle<br />
//if spread is too high exit<br />
//if daydirection filter false exit<br />
//if first 12 hours of day then exit if 5M close is greater than 5M close of 24hrs ago<br />
//if last 12 hours of day then exit if 5M close is greater than 5M close of midnight<br />
//if all the tests pass then call s1_sell<br />
int s1_openSellRule() {<br />
   double close_M5_2;<br />
   double close_M5;<br />
   int bar_with_open_time_1;<br />
   int bar_with_open_time_2;<br />
   if (!bool_rsi15M_p6_in_middle_b) return (0);<br />
   if (bool_if_true_spread_grtr_allow &#038;&#038; !bool_using_daydirection_filter) return (0);<br />
   if (bool13_t) {<br />
      if (if_2_long_3_short == 3) return (0);<br />
      if (current_time <= within_1hr_cci_rsi_switched) //60 minute countdown<br />
         if (two_long_3_short == 3) return (0);<br />
   }<br />
   if (bool14_f || bool_if_true_spread_grtr_allow) {<br />
      if (current_time - time_of_midnight < 43200.0) {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M15, time_of_midnight - 86400);<br />
         bar_with_open_time_2 = iBarShift(NULL, timeframe_M15, time_of_midnight);<br />
      } else {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M15, time_of_midnight);<br />
         bar_with_open_time_2 = time_hour_equal_1_or_0;<br />
      }<br />
      close_M5 = iClose(NULL, timeframe_M15, bar_with_open_time_1);<br />
      close_M5_2 = iClose(NULL, timeframe_M15, bar_with_open_time_2);<br />
      if (close_M5_2 > close_M5) return (0);<br />
   }<br />
   return (s1_Sell(Bid, cci_15M_Period8, rsi_15M_Period6, rsi_1M_Period20, ma_15M_period8, double_70, double_64, buy_tp_10 * p0001_div_point_or_1 * Point, bool8_t, bool_if_true_rsi_1M_20));<br />
}</p>
<p>bool s1_closeBuyRule() {<br />
   if (Stealth || OrderTakeProfit() == 0.0) {<br />
      if (buy_tp_10 > 0)<br />
         if (NormalizeDouble(Bid &#8211; OrderOpenPrice(), Digits) >= NormalizeDouble(buy_tp_10 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (OrderStopLoss() == 0.0) {<br />
      if (sl_bid_minus_low > 0)<br />
         if (NormalizeDouble(OrderOpenPrice() &#8211; Ask, Digits) >= NormalizeDouble(sl_bid_minus_low * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (bool12_f) {//always equals false..is input<br />
      if (g_ticket_940 != OrderTicket()) {<br />
         g_datetime_944 = OrderOpenTime();<br />
         g_ticket_940 = OrderTicket();<br />
      }<br />
      if (cci_15M_Period8 >= 0.0 || rsi_15M_Period6 >= 50.0) g_datetime_944 = current_time;<br />
      if (cci_15M_Period8_offset_2 < cci_15M_Period8_offset_1 &#038;&#038; rsi_15M_Period6_offset_2 < rsi_15M_Period6_offset_1) g_datetime_944 = iTime(NULL, timeframe_M15, time_hour_equal_1_or_0);<br />
      if (current_time - g_datetime_944 > 3600.0 * double_1 &#038;&#038; OrderProfit() < 0.0) return (TRUE);<br />
   }<br />
   if (bool11_t) {<br />
      if (current_time - OrderOpenTime() > 3600.0 * double_1) {<br />
         if (cci_15M_Period8 > 0.0 &#038;&#038; rsi_15M_Period6 > 50.0 &#038;&#038; OrderProfit() > 0.0) return (TRUE);<br />
         if (current_time &#8211; OrderOpenTime() > 3600.0 * double_24) return (TRUE);<br />
      }<br />
   }<br />
   return (FALSE);<br />
}</p>
<p>bool s1_closeSellRule() {<br />
   if (Stealth || OrderTakeProfit() == 0.0) {<br />
      if (buy_tp_10 > 0)<br />
         if (NormalizeDouble(OrderOpenPrice() &#8211; Ask, Digits) >= NormalizeDouble(buy_tp_10 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (OrderStopLoss() == 0.0) {<br />
      if (sell_sl_1 > 0)<br />
         if (NormalizeDouble(Bid &#8211; OrderOpenPrice(), Digits) >= NormalizeDouble(sell_sl_1 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (bool12_f) {<br />
      if (g_ticket_948 != OrderTicket()) {<br />
         g_datetime_952 = OrderOpenTime();<br />
         g_ticket_948 = OrderTicket();<br />
      }<br />
      if (cci_15M_Period8 <= 0.0 || rsi_15M_Period6 <= 50.0) g_datetime_952 = current_time;<br />
      if (cci_15M_Period8_offset_2 > cci_15M_Period8_offset_1 &#038;&#038; rsi_15M_Period6_offset_2 > rsi_15M_Period6_offset_1) g_datetime_952 = iTime(NULL, timeframe_M15, time_hour_equal_1_or_0);<br />
      if (current_time &#8211; g_datetime_952 > 3600.0 * double_1 &#038;&#038; OrderProfit() < 0.0) return (TRUE);<br />
   }<br />
   if (bool11_t) {<br />
      if (current_time - OrderOpenTime() > 3600.0 * double_1) {<br />
         if (cci_15M_Period8 < 0.0 &#038;&#038; rsi_15M_Period6 < 50.0 &#038;&#038; OrderProfit() > 0.0) return (TRUE);<br />
         if (current_time &#8211; OrderOpenTime() > 3600.0 * double_24) return (TRUE);<br />
      }<br />
   }<br />
   return (FALSE);<br />
}<br />
//Open buy order with a stop loss of the low of M15.  However, if this value is > 200 then the stop loss<br />
// becomes int200 or 200<br />
//However, if you are still below int_20 for a stop loss then int_20 becomes stop loss<br />
//if stealth=true  take profit = int_50 or 50 pips if stealth=false then take profit = buy_tp_10 or 10 pips<br />
int s1_openBuy() {<br />
   double take_profit_3 = 0;<br />
   double stop_bid_minus_range = 0;<br />
   if (low_M15 > 0.0) {<br />
      sl_bid_minus_low = (Bid &#8211; low_M15 + Point * p0001_div_point_or_1) / Point;<br />
      if (int_200 > 0 &#038;&#038; sl_bid_minus_low > int_200 * p0001_div_point_or_1) sl_bid_minus_low = int_200 * p0001_div_point_or_1;<br />
      if (sl_bid_minus_low < int_20 * p0001_div_point_or_1) sl_bid_minus_low = int_20 * p0001_div_point_or_1;<br />
   } else sl_bid_minus_low = int_20 * p0001_div_point_or_1;<br />
   if (sl_bid_minus_low < marketinfo_stoplevel) sl_bid_minus_low = marketinfo_stoplevel;<br />
   if (Stealth) stealth_buy_tp_1 = int_50 * p0001_div_point_or_1;<br />
   else stealth_buy_tp_1 = buy_tp_10 * p0001_div_point_or_1;<br />
   if (stealth_buy_tp_1 < marketinfo_stoplevel) stealth_buy_tp_1 = marketinfo_stoplevel;<br />
   stop_bid_minus_range = NormalizeDouble(Bid - sl_bid_minus_low * Point, Digits);<br />
   take_profit_3 = NormalizeDouble(Ask + stealth_buy_tp_1 * Point, Digits);<br />
   return (openOrder(OP_BUY, lots_2, Ask, take_profit_3, stop_bid_minus_range, magic_2, color_2, 0));<br />
}</p>
<p>int s1_openSell() {<br />
   double take_profit_3 = 0;<br />
   double stop_bid_minus_range = 0;<br />
   if (high_M15 > 0.0) {<br />
      sell_sl_1 = (high_M15 &#8211; Ask + Point * p0001_div_point_or_1) / Point;<br />
      if (int_200 > 0 &#038;&#038; sell_sl_1 > int_200 * p0001_div_point_or_1) sell_sl_1 = int_200 * p0001_div_point_or_1;<br />
      if (sell_sl_1 < int_20 * p0001_div_point_or_1) sell_sl_1 = int_20 * p0001_div_point_or_1;<br />
   } else sell_sl_1 = int_20 * p0001_div_point_or_1;<br />
   if (sell_sl_1 < marketinfo_stoplevel) sell_sl_1 = marketinfo_stoplevel;<br />
   if (Stealth) stealth_sell_tp_1 = int_50 * p0001_div_point_or_1;<br />
   else stealth_sell_tp_1 = buy_tp_10 * p0001_div_point_or_1;<br />
   if (stealth_sell_tp_1 < marketinfo_stoplevel) stealth_sell_tp_1 = marketinfo_stoplevel;<br />
   stop_bid_minus_range = NormalizeDouble(Ask + sell_sl_1 * Point, Digits);<br />
   take_profit_3 = NormalizeDouble(Bid - stealth_sell_tp_1 * Point, Digits);<br />
   return (openOrder(OP_SELL, lots_2, Bid, take_profit_3, stop_bid_minus_range, magic_2, color_3, 0));<br />
}</p>
<p>int s1_buyControl() {<br />
   int li_ret_16;<br />
   double take_profit_4 = OrderTakeProfit();<br />
   double stop_loss_3 = OrderStopLoss();<br />
   if (take_profit_4 == 0.0 || stop_loss_3 == 0.0) {<br />
      if (take_profit_4 == 0.0) {<br />
         if (stealth_buy_tp_1 < marketinfo_stoplevel) stealth_buy_tp_1 = marketinfo_stoplevel;<br />
         take_profit_4 = NormalizeDouble(Ask + stealth_buy_tp_1 * Point, Digits);<br />
      }<br />
      if (stop_loss_3 == 0.0) {<br />
         if (sl_bid_minus_low < marketinfo_stoplevel) sl_bid_minus_low = marketinfo_stoplevel;<br />
         stop_loss_3 = NormalizeDouble(Bid - sl_bid_minus_low * Point, Digits);<br />
      }<br />
      waitForContext();<br />
      OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss_3, take_profit_4, 0, Green);<br />
   }<br />
   if (s1_closeBuyRule()) {<br />
      li_ret_16 = closeOrder(0, Violet);<br />
      if (li_ret_16 < 0) return (li_ret_16);<br />
   }<br />
   if (int_0 > 0) {<br />
      if (Bid &#8211; OrderOpenPrice() > Point * p0001_div_point_or_1 * int_0) {<br />
         if (OrderStopLoss() < Bid - Point * p0001_div_point_or_1 * int_0 || OrderStopLoss() == 0.0) {<br />
            waitForContext();<br />
            OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * p0001_div_point_or_1 * int_0, Digits), OrderTakeProfit(), 0, Green);<br />
         }<br />
      }<br />
   }<br />
   return (OrderTicket());<br />
}</p>
<p>int s1_sellControl() {<br />
   int li_ret_16;<br />
   double take_profit_4 = OrderTakeProfit();<br />
   double stop_loss_3 = OrderStopLoss();<br />
   if (take_profit_4 == 0.0 || stop_loss_3 == 0.0) {<br />
      if (take_profit_4 == 0.0) {<br />
         if (stealth_sell_tp_1 < marketinfo_stoplevel) stealth_sell_tp_1 = marketinfo_stoplevel;<br />
         take_profit_4 = NormalizeDouble(Bid - stealth_sell_tp_1 * Point, Digits);<br />
      }<br />
      if (stop_loss_3 == 0.0) {<br />
         if (sell_sl_1 < marketinfo_stoplevel) sell_sl_1 = marketinfo_stoplevel;<br />
         stop_loss_3 = NormalizeDouble(Ask + sell_sl_1 * Point, Digits);<br />
      }<br />
      waitForContext();<br />
      OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss_3, take_profit_4, 0, Red);<br />
   }<br />
   if (s1_closeSellRule()) {<br />
      li_ret_16 = closeOrder(1, Violet);<br />
      if (li_ret_16 < 0) return (li_ret_16);<br />
   }<br />
   if (int_0 > 0) {<br />
      if (OrderOpenPrice() &#8211; Ask > Point * p0001_div_point_or_1 * int_0) {<br />
         if (OrderStopLoss() > Ask + Point * p0001_div_point_or_1 * int_0 || OrderStopLoss() == 0.0) {<br />
            waitForContext();<br />
            OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * p0001_div_point_or_1 * int_0, Digits), OrderTakeProfit(), 0, Red);<br />
         }<br />
      }<br />
   }<br />
   return (OrderTicket());<br />
}</p>
<p>void run_Strategy1() {<br />
   int time_day_of_week;<br />
   bool25 = TRUE;<br />
   if (ticket_strategy_1_long_open == -2) {<br />
      ticket_strategy_1_long_open = Recover(magic_2, OP_BUY);<br />
      if (ticket_strategy_1_long_open >= 0) {<br />
         OrderSelect(ticket_strategy_1_long_open, SELECT_BY_TICKET);<br />
         OrderPrint();<br />
         Print(&#8220;Strategy1: Order found:&#8221;);<br />
      }<br />
   }<br />
   if (ticket_strategy_1_short_open == -2) {<br />
      ticket_strategy_1_short_open = Recover(magic_2, OP_SELL);<br />
      if (ticket_strategy_1_short_open >= 0) {<br />
         OrderSelect(ticket_strategy_1_short_open, SELECT_BY_TICKET);<br />
         OrderPrint();<br />
         Print(&#8220;Strategy1: Order found:&#8221;);<br />
      }<br />
   }<br />
   s1_setRules();<br />
   if ((time_equal_21 < time_equal_0 &#038;&#038; (time_hour_1 >= time_equal_21 &#038;&#038; time_hour_1 <= time_equal_0 - 1)) || (time_equal_21 >= time_equal_0 &#038;&#038; time_hour_1 >= time_equal_21 || time_hour_1 <= time_equal_0 - 1)) bool25 = TRUE;<br />
   else bool25 = FALSE;<br />
   if (bool25 &#038;&#038; bool16_t) {<br />
      time_day_of_week = TimeDayOfWeek(current_time_minus_gmt);<br />
      if ((time_day_of_week == 5 &#038;&#038; time_hour_1 >= time_equal_21) || (time_day_of_week == 1 &#038;&#038; time_equal_21 >= time_equal_0 &#038;&#038; time_hour_1 <= time_equal_0 - 1)) bool25 = FALSE;<br />
      else<br />
         if (time_day_of_week > 5 || time_day_of_week < 1) bool25 = FALSE;<br />
   }<br />
   if (bool30_t != bool25) {<br />
      if (bool25) int_0j++;<br />
      bool30_t = bool25;<br />
   }<br />
   if (ticket_strategy_1_long_open >= 0) {<br />
      if (OrderSelect(ticket_strategy_1_long_open, SELECT_BY_TICKET)) {<br />
         if (OrderCloseTime() == 0) ticket_strategy_1_long_open = s1_buyControl();<br />
         else ticket_strategy_1_long_open = -1;<br />
         order_profit = OrderProfit();<br />
         if (ticket_strategy_1_long_open < 0) CountBalance(order_profit);<br />
      } else {<br />
         ticket_strategy_1_long_open = -2;<br />
         order_profit = 0;<br />
      }<br />
   }<br />
   if (ticket_strategy_1_short_open >= 0) {<br />
      if (OrderSelect(ticket_strategy_1_short_open, SELECT_BY_TICKET)) {<br />
         if (OrderCloseTime() == 0) ticket_strategy_1_short_open = s1_sellControl();<br />
         else ticket_strategy_1_short_open = -1;<br />
         order_profit_2 = OrderProfit();<br />
         if (ticket_strategy_1_short_open < 0) CountBalance(order_profit_2);<br />
      } else {<br />
         ticket_strategy_1_short_open = -2;<br />
         order_profit_2 = 0;<br />
      }<br />
   }<br />
   int li_0 = s1_openBuyRule();<br />
   int orders_in_history = s1_openSellRule();<br />
   if (!bool25 || !gi_716 || bool_margin_less_margin_req) return;<br />
   if (NFA &#038;&#038; !FIFOrule()) return;<br />
   if (datetime_15m_shift_1 != iTime(NULL, timeframe_M15, time_hour_equal_1_or_0) &#038;&#038; li_0 &#038;&#038; ticket_strategy_1_long_open < 0) {<br />
      ticket_strategy_1_long_open = s1_openBuy();<br />
      if (ticket_strategy_1_long_open < 0) return;<br />
      datetime_15m_shift_1 = iTime(NULL, timeframe_M15, time_hour_equal_1_or_0);<br />
      if (bool_if_true_rsi15m_period6) {<br />
         bool_rsi15M_p6_in_middle = FALSE;<br />
         bool_rsi15M_p6_in_middle_b = TRUE;<br />
      }<br />
      int_0m++;<br />
      return;<br />
   }<br />
   if (datetime_15m_shift_1_b != iTime(NULL, timeframe_M15, time_hour_equal_1_or_0) &#038;&#038; orders_in_history &#038;&#038; ticket_strategy_1_short_open < 0) {<br />
      ticket_strategy_1_short_open = s1_openSell();<br />
      if (ticket_strategy_1_short_open >= 0) {<br />
         datetime_15m_shift_1_b = iTime(NULL, timeframe_M15, time_hour_equal_1_or_0);<br />
         if (bool_if_true_rsi15m_period6) {<br />
            bool_rsi15M_p6_in_middle = TRUE;<br />
            bool_rsi15M_p6_in_middle_b = FALSE;<br />
         }<br />
         int_0m++;<br />
      }<br />
   }<br />
}</p>
<p>void s2_setRules() {<br />
   HideTestIndicators(TRUE);<br />
   if (bool17_always_true || bool19_always_true) cci_M5_Period168 = iCCI(NULL, timeframe_M5, period_168, PRICE_TYPICAL, time_hour_equal_1_or_0);<br />
   if (bool_cci_m5_period275) cci_M5_Period275= iCCI(NULL, timeframe_M5, period_275, PRICE_TYPICAL, time_hour_equal_1_or_0);<br />
   high_m5 = iHigh(NULL, timeframe_M5, iHighest(NULL, timeframe_M5, MODE_HIGH, int_36_always_36, 1));<br />
   low_M5 = iLow(NULL, timeframe_M5, iLowest(NULL, timeframe_M5, MODE_LOW, int_36_always_36, 1));<br />
   if (int_0_always_0 > 0) {<br />
      if (spread_1 > int_0_always_0 * p0001_div_point_or_1) {<br />
         if (g_spread_288 < spread_1) {<br />
            Print("Strategy2: Safe spread limit exceeded: spread = ", spread_1);<br />
            if (bool_day_direction_filter) Print("Strategy2: Using DayDirection filter");<br />
         }<br />
         bool_spread = TRUE;<br />
      } else bool_spread = FALSE;<br />
   }<br />
   HideTestIndicators(TRUE);<br />
   if (bool_spread) {<br />
      time_x = time_hour_21d;<br />
      gi_1044 = int_0f;<br />
      return;<br />
   }<br />
   time_x = time_hour_21c;<br />
   gi_1044 = int_4;<br />
}</p>
<p>int s2_openBuyRule() {<br />
   double close_M5_2;<br />
   double close_M5;<br />
   int bar_with_open_time_1;<br />
   int bar_with_open_time_2;<br />
   if (bool_spread &#038;&#038; !bool_day_direction_filter) return (0);<br />
   if (bool21_f || bool_spread) {<br />
      if (current_time - time_of_midnight < 43200.0) {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M5, time_of_midnight - 86400);<br />
         bar_with_open_time_2 = iBarShift(NULL, timeframe_M5, time_of_midnight);<br />
      } else {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M5, time_of_midnight);<br />
         bar_with_open_time_2 = time_hour_equal_1_or_0;<br />
      }<br />
      close_M5 = iClose(NULL, timeframe_M5, bar_with_open_time_1);<br />
      close_M5_2 = iClose(NULL, timeframe_M5, bar_with_open_time_2);<br />
      if (close_M5_2 < close_M5) return (0);<br />
   }<br />
   return (s2_Buy(Ask, Bid, cci_M5_Period168, cci_M5_Period275, low_M5, high_m5, bool17_always_true, bool_cci_m5_period275));<br />
}</p>
<p>int s2_openSellRule() {<br />
   double close_M5_2;<br />
   double close_M5;<br />
   int bar_with_open_time_1;<br />
   int bar_with_open_time_2;<br />
   if (bool_spread &#038;&#038; !bool_day_direction_filter) return (0);<br />
   if (bool21_f || bool_spread) {<br />
      if (current_time - time_of_midnight < 43200.0) {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M5, time_of_midnight - 86400);<br />
         bar_with_open_time_2 = iBarShift(NULL, timeframe_M5, time_of_midnight);<br />
      } else {<br />
         bar_with_open_time_1 = iBarShift(NULL, timeframe_M5, time_of_midnight);<br />
         bar_with_open_time_2 = time_hour_equal_1_or_0;<br />
      }<br />
      close_M5 = iClose(NULL, timeframe_M5, bar_with_open_time_1);<br />
      close_M5_2 = iClose(NULL, timeframe_M5, bar_with_open_time_2);<br />
      if (close_M5_2 > close_M5) return (0);<br />
   }<br />
   return (s2_Sell(Ask, Bid, cci_M5_Period168, cci_M5_Period275, low_M5, high_m5, bool17_always_true, bool_cci_m5_period275));<br />
}</p>
<p>bool s2_closeBuyRule() {<br />
   double l_ord_profit_0;<br />
   if (Stealth || OrderTakeProfit() == 0.0) {<br />
      if (int_35 > 0)<br />
         if (NormalizeDouble(Bid &#8211; OrderOpenPrice(), Digits) >= NormalizeDouble(int_35 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (OrderStopLoss() == 0.0) {<br />
      if (range_1 > 0)<br />
         if (NormalizeDouble(OrderOpenPrice() &#8211; Ask, Digits) >= NormalizeDouble(range_1 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (bool19_always_true) {<br />
      if (g_ticket_1048 != OrderTicket()) {<br />
         gi_1052 = 0;<br />
         gi_1056 = 0;<br />
         g_datetime_1064 = OrderOpenTime();<br />
         g_datetime_1060 = g_datetime_1064;<br />
         g_ticket_1048 = OrderTicket();<br />
         g_ord_open_price_1068 = OrderOpenPrice();<br />
      }<br />
      l_ord_profit_0 = OrderProfit();<br />
      if (Ask > g_ord_open_price_1068) {<br />
         gi_1052 += current_time &#8211; g_datetime_1060;<br />
         g_datetime_1060 = current_time;<br />
      } else {<br />
         gi_1056 += current_time &#8211; g_datetime_1060;<br />
         g_datetime_1060 = current_time;<br />
      }<br />
      if (current_time &#8211; g_datetime_1064 > 3600.0 * double_1e) {<br />
         if (cci_M5_Period168 > 0.0 &#038;&#038; l_ord_profit_0 > 0.0 &#038;&#038; gi_1052 < gi_1056) return (TRUE);<br />
         if (cci_M5_Period168 > 100.0 &#038;&#038; l_ord_profit_0 > 0.0) return (TRUE);<br />
         if (current_time &#8211; g_datetime_1064 > 3600.0 * double_12 &#038;&#038; l_ord_profit_0 > 0.0) return (TRUE);<br />
         if (current_time &#8211; g_datetime_1064 > 3600.0 * double_24b) return (TRUE);<br />
      }<br />
   }<br />
   if (bool_ask_less_low_m5_true) return (Bid >= high_m5);<br />
   return (Bid >= high_3);<br />
}</p>
<p>bool s2_closeSellRule() {<br />
   double l_ord_profit_0;<br />
   if (Stealth || OrderTakeProfit() == 0.0) {<br />
      if (int_35 > 0)<br />
         if (NormalizeDouble(OrderOpenPrice() &#8211; Ask, Digits) >= NormalizeDouble(int_35 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (OrderStopLoss() == 0.0) {<br />
      if (percent_of_range_M5 > 0)<br />
         if (NormalizeDouble(Bid &#8211; OrderOpenPrice(), Digits) >= NormalizeDouble(percent_of_range_M5 * Point * p0001_div_point_or_1, Digits)) return (TRUE);<br />
   }<br />
   if (bool19_always_true) {<br />
      if (g_ticket_1076 != OrderTicket()) {<br />
         gi_1080 = 0;<br />
         gi_1084 = 0;<br />
         g_datetime_1092 = OrderOpenTime();<br />
         g_datetime_1088 = g_datetime_1092;<br />
         g_ticket_1076 = OrderTicket();<br />
         g_ord_open_price_1096 = OrderOpenPrice();<br />
      }<br />
      l_ord_profit_0 = OrderProfit();<br />
      if (Bid < g_ord_open_price_1096) {<br />
         gi_1080 += current_time - g_datetime_1088;<br />
         g_datetime_1088 = current_time;<br />
      } else {<br />
         gi_1084 += current_time - g_datetime_1088;<br />
         g_datetime_1088 = current_time;<br />
      }<br />
      if (current_time - g_datetime_1092 > 3600.0 * double_1e) {<br />
         if (cci_M5_Period168 < 0.0 &#038;&#038; l_ord_profit_0 > 0.0 &#038;&#038; gi_1080 < gi_1084) return (TRUE);<br />
         if (cci_M5_Period168 < -100.0 &#038;&#038; l_ord_profit_0 > 0.0) return (TRUE);<br />
         if (current_time &#8211; g_datetime_1092 > 3600.0 * double_12 &#038;&#038; l_ord_profit_0 > 0.0) return (TRUE);<br />
         if (current_time &#8211; g_datetime_1092 > 3600.0 * double_24b) return (TRUE);<br />
      }<br />
   }<br />
   if (bool_ask_less_low_m5_true) return (Ask <= low_M5);<br />
   return (Ask <= low_3);<br />
}<br />
//<br />
int s2_openBuy() {<br />
   double take_profit_3 = 0;<br />
   double stop_bid_minus_range = 0;<br />
   if (percent_range_1 > 0.0) {<br />
      range_1 = percent_range_1 * (high_m5 &#8211; low_M5) / Point;<br />
      if (int_200b > 0 &#038;&#038; range_1 > int_200b * p0001_div_point_or_1) range_1 = int_200b * p0001_div_point_or_1;<br />
      if (range_1 < int_20c * p0001_div_point_or_1) range_1 = int_20c * p0001_div_point_or_1;<br />
   } else range_1 = int_20c * p0001_div_point_or_1;<br />
   if (range_1 < marketinfo_stoplevel) range_1 = marketinfo_stoplevel;<br />
   if (Stealth) gi_1024 = int_60 * p0001_div_point_or_1;<br />
   else gi_1024 = int_35 * p0001_div_point_or_1;<br />
   if (gi_1024 < marketinfo_stoplevel) gi_1024 = marketinfo_stoplevel;<br />
   stop_bid_minus_range = NormalizeDouble(Bid - range_1 * Point, Digits);<br />
   take_profit_3 = NormalizeDouble(Ask + gi_1024 * Point, Digits);<br />
   return (openOrder(OP_BUY, lots_2, Ask, take_profit_3, stop_bid_minus_range, magic_3, color_5, 0));<br />
}</p>
<p>int s2_openSell() {<br />
   double take_profit_3 = 0;<br />
   double stop_bid_minus_range = 0;<br />
   if (percent_range_1 > 0.0) {<br />
      percent_of_range_M5 = percent_range_1 * (high_m5 &#8211; low_M5) / Point;<br />
      if (int_200b > 0 &#038;&#038; percent_of_range_M5 > int_200b * p0001_div_point_or_1) percent_of_range_M5 = int_200b * p0001_div_point_or_1;<br />
      if (percent_of_range_M5 < int_20c * p0001_div_point_or_1) percent_of_range_M5 = int_20c * p0001_div_point_or_1;<br />
   } else percent_of_range_M5 = int_20c * p0001_div_point_or_1;<br />
   if (percent_of_range_M5 < marketinfo_stoplevel) percent_of_range_M5 = marketinfo_stoplevel;<br />
   if (Stealth) gi_1032 = int_60 * p0001_div_point_or_1;<br />
   else gi_1032 = int_35 * p0001_div_point_or_1;<br />
   if (gi_1032 < marketinfo_stoplevel) gi_1032 = marketinfo_stoplevel;<br />
   stop_bid_minus_range = NormalizeDouble(Ask + percent_of_range_M5 * Point, Digits);<br />
   take_profit_3 = NormalizeDouble(Bid - gi_1032 * Point, Digits);<br />
   return (openOrder(OP_SELL, lots_2, Bid, take_profit_3, stop_bid_minus_range, magic_3, color_6, 0));<br />
}</p>
<p>int s2_buyControl() {<br />
   int li_ret_16;<br />
   double take_profit_4 = OrderTakeProfit();<br />
   double stop_loss_3 = OrderStopLoss();<br />
   if (take_profit_4 == 0.0 || stop_loss_3 == 0.0) {<br />
      if (take_profit_4 == 0.0) {<br />
         if (gi_1024 < marketinfo_stoplevel) gi_1024 = marketinfo_stoplevel;<br />
         take_profit_4 = NormalizeDouble(Ask + gi_1024 * Point, Digits);<br />
      }<br />
      if (stop_loss_3 == 0.0) {<br />
         if (range_1 < marketinfo_stoplevel) range_1 = marketinfo_stoplevel;<br />
         stop_loss_3 = NormalizeDouble(Bid - range_1 * Point, Digits);<br />
      }<br />
      waitForContext();<br />
      OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss_3, take_profit_4, 0, Green);<br />
   }<br />
   if (s2_closeBuyRule()) {<br />
      li_ret_16 = closeOrder(0, Violet);<br />
      if (li_ret_16 < 0) return (li_ret_16);<br />
   }<br />
   if (int_0d > 0) {<br />
      if (Bid &#8211; OrderOpenPrice() > Point * p0001_div_point_or_1 * int_0d) {<br />
         if (OrderStopLoss() < Bid - Point * p0001_div_point_or_1 * int_0d || OrderStopLoss() == 0.0) {<br />
            waitForContext();<br />
            OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * p0001_div_point_or_1 * int_0d, Digits), OrderTakeProfit(), 0, Green);<br />
         }<br />
      }<br />
   }<br />
   return (OrderTicket());<br />
}</p>
<p>int s2_sellControl() {<br />
   int li_ret_16;<br />
   double take_profit_4 = OrderTakeProfit();<br />
   double stop_loss_3 = OrderStopLoss();<br />
   if (take_profit_4 == 0.0 || stop_loss_3 == 0.0) {<br />
      if (take_profit_4 == 0.0) {<br />
         if (gi_1032 < marketinfo_stoplevel) gi_1032 = marketinfo_stoplevel;<br />
         take_profit_4 = NormalizeDouble(Bid - gi_1032 * Point, Digits);<br />
      }<br />
      if (stop_loss_3 == 0.0) {<br />
         if (percent_of_range_M5 < marketinfo_stoplevel) percent_of_range_M5 = marketinfo_stoplevel;<br />
         stop_loss_3 = NormalizeDouble(Ask + percent_of_range_M5 * Point, Digits);<br />
      }<br />
      waitForContext();<br />
      OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss_3, take_profit_4, 0, Red);<br />
   }<br />
   if (s2_closeSellRule()) {<br />
      li_ret_16 = closeOrder(1, Violet);<br />
      if (li_ret_16 < 0) return (li_ret_16);<br />
   }<br />
   if (int_0d > 0) {<br />
      if (OrderOpenPrice() &#8211; Ask > Point * p0001_div_point_or_1 * int_0d) {<br />
         if (OrderStopLoss() > Ask + Point * p0001_div_point_or_1 * int_0d || OrderStopLoss() == 0.0) {<br />
            waitForContext();<br />
            OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * p0001_div_point_or_1 * int_0d, Digits), OrderTakeProfit(), 0, Red);<br />
         }<br />
      }<br />
   }<br />
   return (OrderTicket());<br />
}</p>
<p>void run_Strategy2() {<br />
   int time_day_of_week;<br />
   bool_T_mon_fri = TRUE;<br />
   if (ticket_strategy_2_long_open == -2) {<br />
      ticket_strategy_2_long_open = Recover(magic_3, OP_BUY);<br />
      if (ticket_strategy_2_long_open >= 0) {<br />
         OrderSelect(ticket_strategy_2_long_open, SELECT_BY_TICKET);<br />
         OrderPrint();<br />
         Print(&#8220;Strategy2: Order found:&#8221;);<br />
      }<br />
   }<br />
   if (ticket_strategy_2_short_open == -2) {<br />
      ticket_strategy_2_short_open = Recover(magic_3, OP_SELL);<br />
      if (ticket_strategy_2_short_open >= 0) {<br />
         OrderSelect(ticket_strategy_2_short_open, SELECT_BY_TICKET);<br />
         OrderPrint();<br />
         Print(&#8220;Strategy2: Order found:&#8221;);<br />
      }<br />
   }<br />
   s2_setRules();<br />
   if ((time_x < gi_1044 &#038;&#038; (time_hour_1 >= time_x &#038;&#038; time_hour_1 <= gi_1044 - 1)) || (time_x >= gi_1044 &#038;&#038; time_hour_1 >= time_x || time_hour_1 <= gi_1044 - 1)) bool_T_mon_fri = TRUE;<br />
   else bool_T_mon_fri = FALSE;<br />
   if (bool_T_mon_fri &#038;&#038; bool23_t) {<br />
      time_day_of_week = TimeDayOfWeek(current_time_minus_gmt);<br />
      if ((time_day_of_week == 5 &#038;&#038; time_hour_1 >= time_x) || (time_day_of_week == 1 &#038;&#038; time_x >= gi_1044 &#038;&#038; time_hour_1 <= gi_1044 - 1)) bool_T_mon_fri = FALSE;<br />
      else<br />
         if (time_day_of_week > 5 || time_day_of_week < 1) bool_T_mon_fri = FALSE;<br />
   }<br />
   if (bool32_t != bool_T_mon_fri) {<br />
      if (bool_T_mon_fri) {<br />
         g_ord_profit_756 = 0;<br />
         g_ord_profit_764 = 0;<br />
         int_0k++;<br />
      }<br />
      bool32_t = bool_T_mon_fri;<br />
   }<br />
   if (ticket_strategy_2_long_open >= 0) {<br />
      if (OrderSelect(ticket_strategy_2_long_open, SELECT_BY_TICKET)) {<br />
         if (OrderCloseTime() == 0) ticket_strategy_2_long_open = s2_buyControl();<br />
         else ticket_strategy_2_long_open = -1;<br />
         g_ord_profit_756 = OrderProfit();<br />
         if (ticket_strategy_2_long_open < 0) CountBalance(g_ord_profit_756);<br />
      } else {<br />
         ticket_strategy_2_long_open = -2;<br />
         g_ord_profit_756 = 0;<br />
      }<br />
   }<br />
   if (ticket_strategy_2_short_open >= 0) {<br />
      if (OrderSelect(ticket_strategy_2_short_open, SELECT_BY_TICKET)) {<br />
         if (OrderCloseTime() == 0) ticket_strategy_2_short_open = s2_sellControl();<br />
         else ticket_strategy_2_short_open = -1;<br />
         g_ord_profit_764 = OrderProfit();<br />
         if (ticket_strategy_2_short_open < 0) CountBalance(g_ord_profit_764);<br />
      } else {<br />
         ticket_strategy_2_short_open = -2;<br />
         g_ord_profit_764 = 0;<br />
      }<br />
   }<br />
   int li_0 = s2_openBuyRule();<br />
   int orders_in_history = s2_openSellRule();<br />
   if (!bool_T_mon_fri || !gi_716 || bool_margin_less_margin_req) return;<br />
   if (NFA &#038;&#038; !FIFOrule()) return;<br />
   if (g_datetime_1108 != iTime(NULL, timeframe_M5, time_hour_equal_1_or_0) &#038;&#038; li_0 &#038;&#038; ticket_strategy_2_long_open < 0 &#038;&#038; g_ord_profit_756 >= 0.0) {<br />
      ticket_strategy_2_long_open = s2_openBuy();<br />
      if (ticket_strategy_2_long_open < 0) return;<br />
      g_datetime_1108 = iTime(NULL, timeframe_M5, time_hour_equal_1_or_0);<br />
      high_3 = high_m5;<br />
      low_3 = low_M5;<br />
      g_ord_profit_764 = 0;<br />
      gi_968++;<br />
      return;<br />
   }<br />
   if (g_datetime_1112 != iTime(NULL, timeframe_M5, time_hour_equal_1_or_0) &#038;&#038; orders_in_history &#038;&#038; ticket_strategy_2_short_open < 0 &#038;&#038; g_ord_profit_764 >= 0.0) {<br />
      ticket_strategy_2_short_open = s2_openSell();<br />
      if (ticket_strategy_2_short_open >= 0) {<br />
         g_datetime_1112 = iTime(NULL, timeframe_M5, time_hour_equal_1_or_0);<br />
         high_3 = high_m5;<br />
         low_3 = low_M5;<br />
         g_ord_profit_756 = 0;<br />
         gi_968++;<br />
      }<br />
   }<br />
}</p>
<p>void Refresh(bool ai_0) {<br />
   double lda_4[1];<br />
   int lia_8[4];<br />
   if (ai_0) RefreshRates();<br />
   current_time = TimeCurrent();<br />
   if (!IsTesting() &#038;&#038; AutoServerGmtOffset || AutoLocalGmtOffset) {<br />
      int_x5 = GetGmtOffset(int_x6, TimeYear(current_time), TimeMonth(current_time), TimeDay(current_time), TimeHour(current_time), TimeMinute(current_time), TimeSeconds(current_time), 0, AutoServerGmtOffset, lda_4, lia_8);<br />
      if (int_x5 == 4 &#038;&#038; !AutoLocalGmtOffset) int_x5 = 0;<br />
      else GmtOffset = lda_4[0];<br />
      time_hour_21 = lia_8[0];<br />
      time_hour_equal_1 = lia_8[1];<br />
      time_hour_21c = lia_8[2];<br />
      int_4 = lia_8[3];<br />
   }<br />
   current_time_minus_gmt = current_time &#8211; 3600.0 * GmtOffset;<br />
   time_hour_1 = TimeHour(current_time_minus_gmt);<br />
   time_of_midnight = current_time &#8211; 3600.0 * time_hour_1 &#8211; 60 * TimeMinute(current_time_minus_gmt) &#8211; TimeSeconds(current_time_minus_gmt);<br />
   spread_1 = MarketInfo(Symbol(), MODE_SPREAD);<br />
   marketinfo_stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL);<br />
   p0001_div_point_or_1 = 0.0001 / Point;<br />
   if (Digits < 4) p0001_div_point_or_1 = 100.0 * p0001_div_point_or_1;<br />
}</p>
<p>string BPrint(bool ai_0) {<br />
   if (ai_0) return ("True");<br />
   return ("False");<br />
}</p>
<p>string CPrint(bool ai_0, string as_4, string as_12 = "") {<br />
   if (ai_0) return (as_4);<br />
   return (as_12);<br />
}</p>
<p>string OpPrint(int ai_0) {<br />
   switch (ai_0) {<br />
   case 0:<br />
      return ("Buy");<br />
   case 1:<br />
      return ("Sell");<br />
   }<br />
   return ("Order");<br />
}</p>
<p>string GMPrint(int ai_0) {<br />
   switch (ai_0) {<br />
   case 1:<br />
      return ("automatic: server");<br />
   case 2:<br />
      return ("automatic: server");<br />
   case 4:<br />
      return ("automatic: local");<br />
   }<br />
   return ("manual");<br />
}</p>
<p>string DPrint(int ai_0) {<br />
   switch (ai_0) {<br />
   case 1:<br />
      return ("Correction");<br />
   case 3:<br />
      return ("Upward Impulse");<br />
   case 2:<br />
      return ("Downward Impulse");<br />
   }<br />
   return ("");<br />
}</p>
<p>string PPrint(int ai_0) {<br />
   int orders_in_history = MathMod(ai_0, 5);<br />
   return (gsa_1116[orders_in_history]);<br />
}</p>
<p>string PrintStatus(int ai_0) {<br />
   switch (ai_0) {<br />
   case 1:<br />
      return ("Assessing market volume");<br />
   case 2:<br />
      return ("Checking volatility");<br />
   case 3:<br />
      return ("Monitoring spread");<br />
   case 4:<br />
      return ("Determining direction");<br />
   case 5:<br />
      return ("Reviewing price range");<br />
   case 6:<br />
      return ("Calculating probability");<br />
   }<br />
   return ("");<br />
}</p>
<p>void PrintResponse(int ai_0, int ai_4 = -1, int ai_8 = -1) {<br />
   if (ai_4 == -1) ai_4 = int_0h;<br />
   if (ai_8 == -1) ai_8 = int_0g;<br />
   int_0h = ai_4;<br />
   int_0g = ai_8;<br />
   if (ai_0 &#038; 16384 > 0) PrintLN(&#8220;Authenticated&#8221;, TextColor1);//binary 100000000000000<br />
   else PrintLN(&#8220;Authentication failed &#8211; error(&#8221; + ai_0 + &#8220;)&#8221;, TextColor1);<br />
   if (ai_0 &#038; 512 > 0) PrintLN(&#8220;Attention: Upgrade available&#8221;, TextColor1);//100000000<br />
   if (ai_0 &#038; 1024 > 0) PrintLN(&#8220;Error: Upgrade required&#8221;, TextColor1);//1000000000<br />
   if (ai_0 &#038; 1 > 0) PrintLN(&#8220;Error: WinINet initialisation failed&#8221;, TextColor1);//binary 1<br />
   if (ai_0 &#038; 2 > 0) PrintLN(&#8220;Error: WinINet connection failed&#8221;, TextColor1);//binary 10<br />
   if (ai_0 &#038; 4 > 0) PrintLN(&#8220;Error: Invalid account number&#8221;, TextColor1);//binary 100<br />
   if (ai_0 &#038; 8 > 0) PrintLN(&#8220;Error: Invalid account status&#8221;, TextColor1);//binary 1000<br />
   if (ai_0 &#038; 16 > 0) PrintLN(&#8220;Error: Dll and Expert versions mismatch&#8221;, TextColor1);//binary 10000<br />
   if (ai_0 &#038; 128 > 0) PrintLN(&#8220;Error: Unable to retrieve authentication code&#8221;, TextColor1);//binary 1000000<br />
   if (ai_0 &#038; 256 > 0) PrintLN(&#8220;Error: Server response failure&#8221;, TextColor1);//binary 10000000<br />
   if (ai_0 &#038; 2048 > 0) PrintLN(&#8220;Error: Invalid authorisation details&#8221;, TextColor1);//10000000000<br />
   if (ai_0 &#038; 4096 > 0) PrintLN(&#8220;Error: Authorisation declined&#8221;, TextColor1);//100000000000<br />
}</p>
<p>string GetObjName(int ai_0) {<br />
   return (StringConcatenate(&#8220;Swissy Accu-Scalper&#8221;, &#8221; lb: &#8220;, ai_0));<br />
}</p>
<p>void GetPos(int ai_0, int &#038;ai_4, int &#038;ai_8) {<br />
   string l_name_12 = GetObjName(ai_0);<br />
   if (ObjectFind(l_name_12) == 0) {<br />
      ai_4 = ObjectGet(l_name_12, OBJPROP_XDISTANCE);<br />
      ai_8 = ObjectGet(l_name_12, OBJPROP_YDISTANCE);<br />
   }<br />
}</p>
<p>void PrintLN(string a_text_0, color a_color_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) {<br />
   if (a_color_8 == CLR_NONE) a_color_8 = TextColor1;<br />
   if (ai_12 == -1) ai_12 = int_0h;<br />
   if (ad_16 == -1.0) ad_16 = int_0g;<br />
   string l_name_28 = GetObjName(ai_12);<br />
   if (ObjectFind(l_name_28) != 0) {<br />
      ObjectCreate(l_name_28, OBJ_LABEL, 0, 0, 0);<br />
      ObjectSet(l_name_28, OBJPROP_CORNER, 0);<br />
   }<br />
   ObjectSetText(l_name_28, a_text_0, 8, &#8220;Tahoma&#8221;, a_color_8);<br />
   ObjectSet(l_name_28, OBJPROP_XDISTANCE, gi_676 + ai_24);<br />
   ObjectSet(l_name_28, OBJPROP_YDISTANCE, gi_672 + 14.0 * ad_16);<br />
   if (int_0g < ad_16 + 1.0) int_0g = ad_16 + 1.0;<br />
   if (int_0h < ai_12 + 1) int_0h = ai_12 + 1;<br />
   if (int_0i < ai_12) int_0i = ai_12;<br />
}</p>
<p>void PrintSep(int ai_0 = -1, double ad_4 = -1.0, int ai_12 = 0) {<br />
   if (ai_0 == -1) ai_0 = int_0h;<br />
   if (ad_4 == -1.0) ad_4 = int_0g;<br />
   PrintLN("_______", TextColor2, ai_0, ad_4 - 0.3, ai_12);<br />
   if (int_0g < ad_4 + 1.0) int_0g = ad_4 + 1.0;<br />
}</p>
<p>void Deleteobjects(int ai_0, int ai_4) {<br />
   for (int switch_max_or_min_lot_exceeded = ai_0; switch_max_or_min_lot_exceeded <= ai_4; switch_max_or_min_lot_exceeded++) ObjectDelete(GetObjName(switch_max_or_min_lot_exceeded));<br />
}</p>
<p>double Base36Decode(string as_0) {<br />
   int li_24;<br />
   as_0 = StringUpper(as_0);<br />
   int l_str_len_8 = StringLen(as_0);<br />
   double ld_ret_12 = 0;<br />
   for (int li_20 = 0; li_20 < l_str_len_8; li_20++) {<br />
      li_24 = StringFind(gs_1128, StringSubstr(as_0, l_str_len_8 - li_20 - 1, 1));<br />
      ld_ret_12 += li_24 * MathPow(36, li_20);<br />
   }<br />
   return (ld_ret_12);<br />
}</p>
<p>string Base36Encode(double ad_0) {<br />
   string l_str_concat_8 = "";<br />
   for (ad_0 = MathAbs(ad_0); ad_0 >= 1.0; ad_0 = MathFloor(ad_0 / 36.0)) l_str_concat_8 = StringConcatenate(StringSubstr(gs_1128, MathMod(ad_0, 36), 1), l_str_concat_8);<br />
   return (l_str_concat_8);<br />
}</p>
<p>string StringUpper(string as_0) {<br />
   int switch_max_or_min_lot_exceeded;<br />
   int li_20;<br />
   int l_str_len_16 = StringLen(as_0);<br />
   for (int li_12 = 0; li_12 < l_str_len_16; li_12++) {<br />
      li_20 = 0;<br />
      switch_max_or_min_lot_exceeded = StringGetChar(as_0, li_12);<br />
      if (switch_max_or_min_lot_exceeded > &#8216;`&#8217; &#038;&#038; switch_max_or_min_lot_exceeded < '{') li_20 = switch_max_or_min_lot_exceeded - 32;<br />
      if (switch_max_or_min_lot_exceeded > &#8216;ß&#8217; &#038;&#038; switch_max_or_min_lot_exceeded < 256) li_20 = switch_max_or_min_lot_exceeded - 32;<br />
      if (switch_max_or_min_lot_exceeded == '¸') li_20 = 168;<br />
      if (li_20 > 0) as_0 = StringSetChar(as_0, li_12, li_20);<br />
   }<br />
   return (as_0);<br />
}</p>
<p>int start() {<br />
   int orders_in_history;<br />
   int switch_max_or_min_lot_exceeded;<br />
   if (!bool_t_if_initialize_variables &#038;&#038; !bool_t_if_agressive) return (0);<br />
   int li_0 = GetState();<br />
   if (Bars < 100) {<br />
      Print("Bars less than 100");<br />
      return (0);<br />
   }<br />
   if (bool_not_testing) {<br />
      bool_not_testing = FALSE;<br />
      orders_in_history = RecoverTrades();<br />
      Print("Orders in history: ", orders_in_history, " profit made: ", DoubleToStr(profit_made, 2));<br />
   }<br />
   if (bool1_f &#038;&#038; RiskLevel > 0.0) {<br />
      if (bool2_t) while (AccountBalance() < account_balance_x / (double_p2 + 1.0)) account_balance_x /= (double_p2 + 1.0); //account_balance_x = double_1000; which is 1000 //double_p2=.2 // = 694<br />
      while (AccountBalance() > account_balance_x) account_balance_x *= (double_p2 + 1.0); //while account balance > 694 then account_balance_x=832<br />
      lots_2 = MMLots(RiskLevel, account_balance_x, switch_max_or_min_lot_exceeded);<br />
   } else {<br />
      if (RiskLevel > 0.0) {<br />
         lots_2 = MMLots(RiskLevel, AccountFreeMargin(), switch_max_or_min_lot_exceeded);<br />
         if (RecoveryMode) lots_2 = RecoveryLot(lots_2);<br />
      } else lots_2 = NormalizeLots(LotSize, switch_max_or_min_lot_exceeded);<br />
   }<br />
   double margin_required_times_x = NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED) * lots_2, 8);<br />
   g_spread_288 = spread_1;<br />
   Refresh(0);<br />
   bool_margin_less_margin_req = NormalizeDouble(AccountFreeMargin(), <img src='http://www.jeremywhittaker.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> < margin_required_times_x;<br />
   gi_716 = IsTradeTime(Symbol(), TimeYear(current_time_minus_gmt), TimeMonth(current_time_minus_gmt), TimeDay(current_time_minus_gmt), int_3);<br />
   if (NFA) RefreshOrders();<br />
   if (bool_t_if_initialize_variables) run_Strategy1();<br />
   Refresh(1);<br />
   bool_margin_less_margin_req = NormalizeDouble(AccountFreeMargin(), <img src='http://www.jeremywhittaker.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> < margin_required_times_x;<br />
   if (bool_t_if_agressive) run_Strategy2();<br />
   if (IsTesting() &#038;&#038; !IsVisualMode()) return (0);<br />
   GetPos(0, gi_676, gi_672);<br />
   int_0h = 0;<br />
   int_0g = 0;<br />
   PrintLN(email_subject, TextColor2);<br />
   PrintSep();<br />
   PrintResponse(int_x4);<br />
   PrintSep();<br />
   PrintLN(gs_344);<br />
   PrintLN(gs_352, TextColor2, int_0h, int_0g - 1, 5 * (StringLen(gs_344) + 1));<br />
   PrintSep();<br />
   string ls_20 = DoubleToStr(GmtOffset, 1);<br />
   if (!IsTesting()) ls_20 = StringConcatenate(ls_20, " (", GMPrint(int_x5), ")");<br />
   PrintLN("ServerTime:");<br />
   PrintLN(TimeToStr(current_time), TextColor2, int_0h,   - 1, 60);<br />
   PrintLN("UtcTime:");<br />
   PrintLN(TimeToStr(current_time_minus_gmt), TextColor2, int_0h, int_0g - 1, 45);<br />
   PrintLN("GmtOffset:");<br />
   PrintLN(ls_20, TextColor2, int_0h, int_0g - 1, 55);<br />
   PrintSep();<br />
   PrintLN("Digits:");<br />
   PrintLN(Digits, TextColor2, int_0h, int_0g - 1, 35);<br />
   PrintLN("Spread:");<br />
   PrintLN(StringConcatenate(DoubleToStr(spread_1 / p0001_div_point_or_1, 1), " (", spread_1, " pips)"), TextColor2, int_0h, int_0g - 1, 40);<br />
   PrintSep();<br />
   PrintLN("Lot:");<br />
   PrintLN(DoubleToStr(lots_2, 2), TextColor2, int_0h, int_0g - 1, 25);<br />
   switch (switch_max_or_min_lot_exceeded) {<br />
   case 1:<br />
      PrintLN("Maximum Lot size exeeded!");<br />
      break;<br />
   case -1:<br />
      PrintLN("Minimum Lot size exeeded!");<br />
   }<br />
   if (bool33_f != bool_margin_less_margin_req) {<br />
      if (bool_margin_less_margin_req) Print("Not enough money! Available margin = ", DoubleToStr(AccountFreeMargin(), 2), ", Required margin = ", DoubleToStr(margin_required_times_x, 2));<br />
      bool33_f = bool_margin_less_margin_req;<br />
   }<br />
   if (bool_margin_less_margin_req) {<br />
      PrintSep();<br />
      PrintLN("Not enough money!");<br />
      PrintLN("Available margin =");<br />
      PrintLN(DoubleToStr(AccountFreeMargin(), 2), TextColor2, int_0h, int_0g - 1, 90);<br />
      PrintLN("Required margin =");<br />
      PrintLN(DoubleToStr(margin_required_times_x, 2), TextColor2, int_0h, int_0g - 1, 90);<br />
   }<br />
   PrintSep();<br />
   if (IsTesting()) PrintLN("Backtesting");<br />
   else PrintLN(PrintStatus(GetStatus()));<br />
   PrintSep();<br />
   if (bool_t_if_initialize_variables &#038;&#038; bool13_t) {<br />
      if (if_2_long_3_short == 0) PrintLN("Analyzing market");<br />
      else PrintLN(DPrint(if_2_long_3_short) + " detected");<br />
      if (current_time <= within_1hr_cci_rsi_switched &#038;&#038; if_2_long_3_short != two_long_3_short &#038;&#038; two_long_3_short != 0) PrintLN(DPrint(two_long_3_short) + " fading: " + TimeToStr(within_1hr_cci_rsi_switched - current_time, TIME_SECONDS));<br />
   } else PrintLN(CPrint(bool25 || bool_T_mon_fri, "Running", "Collecting Data"));<br />
   if (NFA &#038;&#038; num_orders_NOTmagic2or3 > 0) {<br />
      PrintSep();<br />
      PrintLN(&#8220;Waiting for trades to close: &#8220;);<br />
      PrintLN(num_orders_NOTmagic2or3, TextColor2, int_0h, int_0g &#8211; 1, 125);<br />
   }<br />
   if (ticket_strategy_1_long_open >= 0 || ticket_strategy_1_short_open >= 0 || ticket_strategy_2_long_open >= 0 || ticket_strategy_1_short_open >= 0) {<br />
      PrintSep();<br />
      if (ticket_strategy_1_long_open >= 0) PrintLN(&#8220;Strategy1: Long position open&#8221;);<br />
      if (ticket_strategy_1_short_open >= 0) PrintLN(&#8220;Strategy1: Short position open&#8221;);<br />
      if (ticket_strategy_2_long_open >= 0) PrintLN(&#8220;Strategy2: Long position open&#8221;);<br />
      if (ticket_strategy_2_short_open >= 0) PrintLN(&#8220;Strategy2: Short position open&#8221;);<br />
   }<br />
   Deleteobjects(int_0h, int_0i);<br />
   int_0i = int_0h &#8211; 1;<br />
   ObjectsRedraw();<br />
   return (0);<br />
}</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2011%2F02%2F13%2Fswissy-scalper-strategy-eurchf%2F&amp;title=Swiss%20Swissy%20Scalper%20strategy%20eurchf" id="wpa2a_6"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2011/02/13/swissy-scalper-strategy-eurchf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is MarketInfo(Symbol(), MODE_STOPLEVEL) in MT4</title>
		<link>http://www.jeremywhittaker.com/2011/02/12/what-is-marketinfosymbol-mode_stoplevel-in-mt4/</link>
		<comments>http://www.jeremywhittaker.com/2011/02/12/what-is-marketinfosymbol-mode_stoplevel-in-mt4/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 04:40:51 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=939</guid>
		<description><![CDATA[Recently I ran across this command in a strategy I was decompiling. Here is an example of how to properly use MarketInfo(Symbol(), MODE_STOPLEVEL) if (My_stop_loss < MarketInfo(Symbol(), MODE_STOPLEVEL) My_stop_loss= MarketInfo(Symbol(), MODE_STOPLEVEL); What this line of code basically does is take your existing stop loss value. If it is lower than the allowed amount from your [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I ran across this command in a strategy I was decompiling.  Here is an example of how to properly use MarketInfo(Symbol(), MODE_STOPLEVEL)</p>
<p>if (My_stop_loss < MarketInfo(Symbol(), MODE_STOPLEVEL) My_stop_loss= MarketInfo(Symbol(), MODE_STOPLEVEL);</p>
<p>What this line of code basically does is take your existing stop loss value.  If it is lower than the allowed amount from your broker it sets your stop loss to the minimum amount allowed. In this example it is a long trade.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2011%2F02%2F12%2Fwhat-is-marketinfosymbol-mode_stoplevel-in-mt4%2F&amp;title=What%20is%20MarketInfo%28Symbol%28%29%2C%20MODE_STOPLEVEL%29%20in%20MT4" id="wpa2a_8"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2011/02/12/what-is-marketinfosymbol-mode_stoplevel-in-mt4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a SMA or simple moving average cross alert with email in Metatrader or MQL4</title>
		<link>http://www.jeremywhittaker.com/2011/01/12/creating-a-sma-or-simple-moving-average-cross-alert-with-email-in-metatrader-or-mql4/</link>
		<comments>http://www.jeremywhittaker.com/2011/01/12/creating-a-sma-or-simple-moving-average-cross-alert-with-email-in-metatrader-or-mql4/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 01:45:41 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[alert]]></category>
		<category><![CDATA[cross]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[metatrader]]></category>
		<category><![CDATA[mql4]]></category>
		<category><![CDATA[simple moving average]]></category>
		<category><![CDATA[sma]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=928</guid>
		<description><![CDATA[Below is a link and the code to create a simple SMA moving average crossover in Metatrader. MQ4 format EX4 format //+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ //&#124; Moving Average Cross Alert.mq4 &#124; //&#124; Copyright © 2010, Jeremy Whittaker &#124; //&#124; http://www.JeremyWhittaker.com &#124; //+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ #property copyright &#8220;Copyright © 2010, Jeremy Whittaker&#8221; #property link &#8220;http://www.JeremyWhittaker.com&#8221; #property indicator_chart_window #property indicator_buffers 4 #property [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a link and the code to create a simple SMA moving average crossover in Metatrader.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/01/Moving%20Average%20Cross%20Alert.mq4">MQ4 format</a><br />
<a href="http://www.jeremywhittaker.com/wp-content/uploads/2011/01/Moving%20Average%20Cross%20Alert.ex4">EX4 format</a></p>
<p><em>//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
//|                                   Moving Average Cross Alert.mq4 |<br />
//|                               Copyright © 2010, Jeremy Whittaker |<br />
//|                                   http://www.JeremyWhittaker.com |<br />
//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
#property copyright &#8220;Copyright © 2010, Jeremy Whittaker&#8221;<br />
#property link      &#8220;http://www.JeremyWhittaker.com&#8221;</p>
<p>#property indicator_chart_window<br />
#property indicator_buffers 4<br />
#property indicator_color1 Red<br />
#property indicator_color2 Aqua<br />
#property indicator_color3 Red<br />
#property indicator_color4 Aqua</p>
<p>//&#8212;- External Variables<br />
extern int Period1 = 20;<br />
extern int Period2 = 100;<br />
extern bool Email    = True;</p>
<p>//&#8212;- Indicators<br />
int    nShift, digit, digits;<br />
int    i,j,limit,counted_bars;</p>
<p>//&#8212;- Buffers<br />
double ExtMapBuffer1[];<br />
double ExtMapBuffer2[];<br />
double ExtMapBuffer3[];<br />
double ExtMapBuffer4[];   </p>
<p>//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
//| Custom indicator initialization function                         |<br />
//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
int init()<br />
   {<br />
//&#8212;- Draw Lines<br />
      SetIndexStyle(0,DRAW_LINE);<br />
      SetIndexBuffer(0,ExtMapBuffer1);</p>
<p>      SetIndexStyle(1,DRAW_LINE);<br />
      SetIndexBuffer(1,ExtMapBuffer2);  </p>
<p>//&#8212;- Draw Arrows<br />
      SetIndexStyle(2, DRAW_ARROW, 0, 1);    // Fleche vers le haut<br />
      SetIndexArrow(2, 233);<br />
      SetIndexBuffer(2, ExtMapBuffer3);</p>
<p>      SetIndexStyle(3, DRAW_ARROW, 0, 1);    // Fleche vers le bas<br />
      SetIndexArrow(3, 234);<br />
      SetIndexBuffer(3, ExtMapBuffer4);</p>
<p>//&#8212;-<br />
      watermark();<br />
//&#8212;-<br />
         return(0);<br />
      }<br />
//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
//| Custom indicator deinitialization function                       |<br />
//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
int deinit()<br />
   {<br />
//&#8212;-</p>
<p>//&#8212;-<br />
      return(0);<br />
   }</p>
<p>//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
//| Custom indicator iteration function                              |<br />
//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
int start()<br />
   {<br />
   double   Ma1,Ma2, Ma1Previous, Ma2Previous;</p>
<p>      counted_bars=IndicatorCounted();<br />
//&#8212;-<br />
      if(counted_bars<0)<br />
         return(-1);<br />
      if(counted_bars>0)<br />
         counted_bars&#8211;;<br />
      limit=Bars-counted_bars;<br />
      for(i=0; i
<limit; i++)<br />
         {<br />
         Ma1=iMA(NULL,0,Period1,0,MODE_SMA,PRICE_CLOSE,i);<br />
         Ma1Previous=iMA(NULL,0,Period1,0,MODE_SMA,PRICE_CLOSE,i+1);<br />
         ExtMapBuffer1[i]=Ma1;</p>
<p>         Ma2=iMA(NULL,0,Period2,0,MODE_SMA,PRICE_CLOSE,i);<br />
         Ma2Previous=iMA(NULL,0,Period2,0,MODE_SMA,PRICE_CLOSE,i+1);<br />
         ExtMapBuffer2[i]=Ma2;<br />
         }</p>
<p>      if(Ma1>Ma2 &#038;&#038; Ma1Previous<Ma2Previous)<br />
         {<br />
         if(NewBar()==true)<br />
            {<br />
            ExtMapBuffer3[0] = Low[0] - iATR(Symbol(),0,10,0)*0.25;<br />
            Alert("Long Trade setup coming ",Period1, " has just crossed above ",Period2,".  The current Price ",Close[1]," for ", Symbol(),"-",Period());<br />
            PlaySound("alert.wav");<br />
            if (Email)<br />
               {<br />
               SendMail("Long Trade setup confirmed", "Trade setup confirmed "+DoubleToStr(Ma1, digits)+" has just crossed above "+DoubleToStr(Ma2, digits)+" for "+Symbol()+"-"+Period());<br />
               }<br />
            }<br />
         }<br />
      if(Ma1<Ma2 &#038;&#038; Ma1Previous>Ma2Previous)<br />
         {<br />
         if(NewBar()==true)<br />
            {<br />
            ExtMapBuffer4[0] = High[0] + iATR(Symbol(),0,10,0)*0.25;<br />
            if(NewBar()==true)<br />
               {<br />
               Alert(&#8220;Short Trade setup coming &#8220;,Period1, &#8221; has just crossed below &#8220;,Period2,&#8221;.  The current Price &#8220;,Close[1],&#8221; for &#8220;, Symbol(),&#8221;-&#8221;,Period());<br />
               PlaySound(&#8220;alert.wav&#8221;);<br />
               if (Email)<br />
                  {<br />
                  SendMail(&#8220;Short Trade setup confirmed&#8221;, &#8220;Trade setup confirmed &#8220;+DoubleToStr(Ma1, digits)+&#8221; has just crossed below &#8220;+DoubleToStr(Ma2, digits)+&#8221; for &#8220;+Symbol()+&#8221;-&#8221;+Period());<br />
                  }<br />
               }<br />
            }<br />
         }  </p>
<p>//&#8212;-</p>
<p>      return(0);<br />
   }<br />
//+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+</p>
<p>void watermark()<br />
  {<br />
   ObjectCreate(&#8220;JeremyWhittaker&#8221;, OBJ_LABEL, 0, 0, 0);<br />
   ObjectSetText(&#8220;JeremyWhittaker&#8221;, &#8220;JeremyWhittaker.com&#8221;, 8, &#8220;Arial&#8221;, RoyalBlue);<br />
   ObjectSet(&#8220;JeremyWhittaker&#8221;, OBJPROP_CORNER, 2);<br />
   ObjectSet(&#8220;JeremyWhittaker&#8221;, OBJPROP_XDISTANCE, 5);<br />
   ObjectSet(&#8220;JeremyWhittaker&#8221;, OBJPROP_YDISTANCE, 10);<br />
   return(0);<br />
  }</p>
<p>   bool NewBar()<br />
	   {<br />
	   static datetime lastbar;<br />
	   datetime curbar = Time[0];<br />
	   if(lastbar!=curbar)<br />
		   {<br />
		   lastbar=curbar;<br />
		   return (true);<br />
		   }<br />
	   else<br />
		   {<br />
		   return(false);<br />
		   }<br />
	   }   </em></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2011%2F01%2F12%2Fcreating-a-sma-or-simple-moving-average-cross-alert-with-email-in-metatrader-or-mql4%2F&amp;title=Creating%20a%20SMA%20or%20simple%20moving%20average%20cross%20alert%20with%20email%20in%20Metatrader%20or%20MQL4" id="wpa2a_10"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2011/01/12/creating-a-sma-or-simple-moving-average-cross-alert-with-email-in-metatrader-or-mql4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up Metatrader for better backtesting quality</title>
		<link>http://www.jeremywhittaker.com/2010/12/28/setting-up-metatrader-for-better-backtesting-quality/</link>
		<comments>http://www.jeremywhittaker.com/2010/12/28/setting-up-metatrader-for-better-backtesting-quality/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 21:52:02 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[backtest]]></category>
		<category><![CDATA[backtesting]]></category>
		<category><![CDATA[metatrader]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[quality]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=918</guid>
		<description><![CDATA[If you&#8217;re working with a default installation of MT4 or Metatrader chances are you modeling quality is not very good. I have composed this post to show how I import data into MT4 for better backtesting performance. First thing you need is high quality historical data in CSV format. I have found Forex Tester to [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re working with a default installation of MT4 or Metatrader chances are you modeling quality is not very good.  I have composed this post to show how I import data into MT4 for better backtesting performance.</p>
<p>First thing you need is high quality historical data in CSV format.  I have found Forex Tester to be very beneficial for that, <a href="http://www.forextester.com/data/datasources.html">http://www.forextester.com/data/datasources.html</a>.</p>
<p>1.	You will want to download the file that pertains to the pair you will be trading.</p>
<p>2.	The next step is unzipping the file using a simple Zip program.</p>
<p>3.	Before proceeding to import your new data you will want to go ahead and delete all of your old data first.  So that you are not mixing the two up.  If you are running Windows7 or Windows Vista you have to look in two locations for the .hst files and delete all of them.  If however you are running Windows XP you need to only look in one.  These locations can vary greatly depending what broker you download your platform from.  I use Interbank but you will have to look and mind and figure out where yours are.  Or you can just search your entire hard drive for *.hst files.<br />
C:\Program Files (x86)\Interbank FX Trader 4 &#8211; B\history<br />
C:\Users\%username%\AppData\Local\VirtualStore\Program Files (x86)\Interbank FX Trader 4 &#8211; B\history\IBFX-MT4 Mini-2</p>
<p>4.	Now that you have unzipped the files they should be in .CSV format.  From here you can now open your Metatrader platform.  Then go to tools>options click on the chart tab and change the “max bars in history” and “max bars in chart” to 999999999.  Once you close this window Metatrader will adjust to the highest possible setting automatically.</p>
<p>5.	You will now want to go to tools>history center.  Double click your currency pair that you are trying to import.  Then double click on the 1m timeframe underneath it.  Now click on the import button.  Browse to the location of the .txt file that you extracted in step 2.  You may have to change the rows setting to 0.  If it works correctly you will be able to see every row from the file that you are importing.  Click ok and all of your 1m data is now complete.</p>
<p>6.	The next step is to generate your 5m 10m 30m 60m 240m 1440m and 10080m data.  This will get all of the commonly used timeframes.  You can also do custom ones if you wish.</p>
<p>7.	To do this you need to go to navigator from Metatrader terminal.  Select the scripts from the navigator window and look for one named “period_converter”. </p>
<p>8.	Open a 1m chart of the currency pair that you just imported.</p>
<p>9.	Now double click on period_converter</p>
<p>10.	It’s going to ask you for an input labeled “ExtPeriodMultiplier”.  The default value is 3.  Change this to 5 to generate your 5 minute chart data.</p>
<p>11.	If you have your terminal window open in Metatrader select the experts tab.  You will see something that says period_converter GBPUSDm,M1: 726279 record(s) written.  This is how you know it is complete.  </p>
<p>12.	Double click period converter again.  This time select 10 for 10 minute chart.  Continue doing steps 10 and 11 until you have created your 5m 10m 30m 60m 240m 1440m and 10080m data.  You are now ready to move on to your next currency pair.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2010%2F12%2F28%2Fsetting-up-metatrader-for-better-backtesting-quality%2F&amp;title=Setting%20up%20Metatrader%20for%20better%20backtesting%20quality" id="wpa2a_12"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2010/12/28/setting-up-metatrader-for-better-backtesting-quality/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Analyzing Power of 27 (End of a Trend)</title>
		<link>http://www.jeremywhittaker.com/2010/12/22/analyzing-power-of-27-end-of-a-trend/</link>
		<comments>http://www.jeremywhittaker.com/2010/12/22/analyzing-power-of-27-end-of-a-trend/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 05:53:21 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[ea]]></category>
		<category><![CDATA[end of a trend]]></category>
		<category><![CDATA[metatrader]]></category>
		<category><![CDATA[MT4]]></category>
		<category><![CDATA[power of 27]]></category>
		<category><![CDATA[rob booker]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=901</guid>
		<description><![CDATA[I always enjoy reading the research the Rob Booker puts into his work.  Recently he posted a blog about analyzing the power of 27 or the end of a trend.  The complete post can be found here, http://robbooker.posterous.com/35098406. The theory seemed simply enough so I decided to write a robot to test out this same [...]]]></description>
			<content:encoded><![CDATA[<p>I always enjoy reading the research the Rob Booker puts into his work.  Recently he posted a blog about analyzing the power of 27 or the end of a trend.  The complete post can be found here, <a href="http://robbooker.posterous.com/35098406">http://robbooker.posterous.com/35098406</a>.</p>
<p>The theory seemed simply enough so I decided to write a robot to test out this same theory.  I however took it a step farther.  I wanted to develop this into a trading strategy rather than just a simple statistical analysis which will only create a hypothesis.</p>
<p>I created the expert advisor in MT4 or MetaTrader.  The EA can be found here, <a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/11/Kruger.ex4">http://www.jeremywhittaker.com/wp-content/uploads/2010/11/Kruger.ex4</a></p>
<p>This EA has not been specifically built for a timeframe.  You can however add it to any timeframe and test the results until you end up with something you like. </p>
<p>For long trades the EA does as follows:</p>
<ol>
<li>On every bar that closes - Is my close higher than the low of the previous bar?  What about for the last X bars?  X can be modified to your preference using the input labeled &#8221;barsToUpTrend&#8221;.</li>
<li>If rule 1 is true it will count how many open positions you currently have.  You can adjust this number through an input labeled &#8220;POS_num_max&#8221; change the amount of open positions allowed at any given time.</li>
<li>If rule 1 is true call my money management.  Which is AccountFreeMargin/100000*Risk_percent.  Risk_percent can be changed via the input labeled Risk_percent.</li>
<li>Once rule 2 &amp; 3 are done processing the EA will determine the ATR of the last X bars.  This variable can be changed through the input labeled &#8220;atrPeriodForClose&#8221;.  It will then take that ATR and multiply it by the variable labeled &#8220;percentAtrTP&#8221;.  This will become your take profit level.  The concept for this rule is simple.  I do not believe in fixed stop loss or take profit values as they cannot dynamically adjust with the market.  Therefore I always use a percentage of the ATR as my stop loss and take profit.</li>
<li>As with rule 4 the stop loss is determined with as a percentage of the ATR which is adjustable via this variable &#8220;percentAtrSL&#8221;.</li>
</ol>
<p>For short trades:</p>
<ol>
<li>On every bar that closes &#8211; Is my close lower than the high of the previous bar?  What about for the last X bars?  X can be modified to your preference using the input labeled &#8220;barsToDownTrend&#8221;.</li>
<li>If rule 1 is true it will count how many open positions you currently have.  You can adjust this number through an input labeled &#8220;POS_num_max&#8221; change the amount of open positions allowed at any given time.</li>
<li>If rule 1 is true call my money management.  Which is AccountFreeMargin/100000*Risk_percent.  Risk_percent can be changed via the input labeled Risk_percent.</li>
<li>Once rule 2 &amp; 3 are done processing the EA will determine the ATR of the last X bars.  This variable can be changed through the input labeled &#8220;atrPeriodForClose&#8221;.  It will then take that ATR and multiply it by the variable labeled &#8220;percentAtrTP&#8221;.  This will become your take profit level.  The concept for this rule is simple.  I do not believe in fixed stop loss or take profit values as they cannot dynamically adjust with the market.  Therefore I always use a percentage of the ATR as my stop loss and take profit.</li>
<li>As with rule 4 the stop loss is determined with as a percentage of the ATR which is adjustable via this variable &#8220;percentAtrSL&#8221;.</li>
</ol>
<p> </p>
<p>I hope the information provided here is useful to anyone trying to develop a profitable strategy.  Happy analyzing!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2010%2F12%2F22%2Fanalyzing-power-of-27-end-of-a-trend%2F&amp;title=Analyzing%20Power%20of%2027%20%28End%20of%20a%20Trend%29" id="wpa2a_14"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2010/12/22/analyzing-power-of-27-end-of-a-trend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Distributed Processing or Backtesting of Forex Strategies Using MQL5</title>
		<link>http://www.jeremywhittaker.com/2010/10/31/distributed-processing-or-backtesting-of-forex-strategies-using-mql5/</link>
		<comments>http://www.jeremywhittaker.com/2010/10/31/distributed-processing-or-backtesting-of-forex-strategies-using-mql5/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 21:14:16 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Forex]]></category>
		<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[MQL5]]></category>
		<category><![CDATA[currencies]]></category>
		<category><![CDATA[distributed processing]]></category>
		<category><![CDATA[ea]]></category>
		<category><![CDATA[expert advisor]]></category>
		<category><![CDATA[hostname]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[metatester]]></category>
		<category><![CDATA[metatester64]]></category>
		<category><![CDATA[MQL]]></category>
		<category><![CDATA[mql4]]></category>
		<category><![CDATA[MT4]]></category>
		<category><![CDATA[mt5]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[processing power]]></category>
		<category><![CDATA[processor]]></category>
		<category><![CDATA[remote agent]]></category>
		<category><![CDATA[remote processing]]></category>
		<category><![CDATA[scalable]]></category>
		<category><![CDATA[strategies]]></category>
		<category><![CDATA[tcp port]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=864</guid>
		<description><![CDATA[I have recently started to dabble in MQL5. It is the new language used by the MT5 platform for currency trading. One of the greatest features that I can see so far is the ability to scale your processing. At first this theory might sound a bit advanced but I will show you how easy [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently started to dabble in MQL5.  It is the new language used by the MT5 platform for currency trading.  One of the greatest features that I can see so far is the ability to scale your processing.  At first this theory might sound a bit advanced but I will show you how easy it can be.</p>
<p>If you have ever used MQL4 or MT4 then you know one of the biggest drawbacks is the application will only use one of your processors when you are backtesting a strategy.  Another one of the biggest drawbacks is if your backtests has tons of data it can take literally hours or days to crunch your test.  This is a big nuisance.  However, with MQL5 these problems have been resolved.</p>
<p>First let&#8217;s take a look at a backtest.  You can see in this image below that I&#8217;m running 8 processors in my current machine.  They are all being utilized.  You can also see the &#8220;remote&#8221; agents which is emtpy.  Below I will take you through the steps of creating a remote agent.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/distributed_processing.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/distributed_processing-1024x177.jpg" alt="" title="distributed_processing" width="1024" height="177" class="aligncenter size-large wp-image-874" /></a></p>
<p>The first thing you want to do is search your PC for a file named metatester.exe or metatester64.exe.  Depending if you are planning on deploying a 64-bit remote agent or a 32-bit remote agent.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester.jpg" alt="" title="metatester" width="852" height="433" class="aligncenter size-full wp-image-872" /></a></p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester64.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester64.jpg" alt="" title="metatester64" width="854" height="436" class="aligncenter size-full wp-image-873" /></a></p>
<p>The next thing you are going to want to do is copy this file to your remote PC which will be doing the remote processing.  I created a folder on my remote PC on the root of my C:\ drive named metatester.  So my full path will be C:\MetaTester\metatester.exe</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester-on-drive.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester-on-drive.jpg" alt="" title="metatester on drive" width="780" height="313" class="aligncenter size-full wp-image-871" /></a></p>
<p>Once I have copied this file to my remote machine I&#8217;m going to run it.  Below is what you will see when you do this.  There are only 2 options the password you want to use and the port you want to use.  In my case for demo purposes I use MySecurePassword and port 2000 (the default) then I simply click the add button.  If your remote PC has multiple processors then you should increase the TCP port to 2001 and add another service instance.  You should do this for as many processors as your remote machine has.  Incrementing the port number by one every time.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester5-agent.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester5-agent.jpg" alt="" title="metatester5 agent" width="569" height="408" class="aligncenter size-full wp-image-870" /></a></p>
<p>If you now open your services console you will see a new service set on startup on your remote machine.  You will see multiple instances of this if you have more than 1 processor.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester-service.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/metatester-service.jpg" alt="" title="metatester service" width="1010" height="564" class="aligncenter size-full wp-image-869" /></a></p>
<p>Now that we have successfully deployed a remote agent we must go back to our main machine where we are backtesting our EA or expert advisor.  From the Agents tab on the strategy tester window you are going to want to right click on &#8220;Remote&#8221; and select &#8220;Add&#8221;, see below.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/add.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/add.jpg" alt="" title="add" width="783" height="319" class="aligncenter size-full wp-image-868" /></a></p>
<p>You will now see the image below.  You can type in anything for the first field which is &#8220;name&#8221; it does not matter.  For the second field you must type in the IP address of your other machine or hostname. Then simply type the password in from when you configured the service and click ok.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/agent-settings.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/agent-settings.jpg" alt="" title="agent settings" width="418" height="251" class="aligncenter size-full wp-image-867" /></a></p>
<p>That is it you can see now you have successfully added a remote agent.  Mine is erased to protect the identify of my computer.  </p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/new-remote-agent.jpg"><img src="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/new-remote-agent.jpg" alt="" title="new remote agent" width="772" height="318" class="aligncenter size-full wp-image-866" /></a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2010%2F10%2F31%2Fdistributed-processing-or-backtesting-of-forex-strategies-using-mql5%2F&amp;title=Distributed%20Processing%20or%20Backtesting%20of%20Forex%20Strategies%20Using%20MQL5" id="wpa2a_16"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2010/10/31/distributed-processing-or-backtesting-of-forex-strategies-using-mql5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whittaker COT Index Variant-A</title>
		<link>http://www.jeremywhittaker.com/2010/03/03/whittaker-cot-index-variant-a/</link>
		<comments>http://www.jeremywhittaker.com/2010/03/03/whittaker-cot-index-variant-a/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 06:39:51 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Forex]]></category>
		<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[Commercial]]></category>
		<category><![CDATA[Commitment of Traders]]></category>
		<category><![CDATA[cot]]></category>
		<category><![CDATA[MQL]]></category>
		<category><![CDATA[mql4]]></category>
		<category><![CDATA[MT4]]></category>
		<category><![CDATA[Non-Commercial]]></category>
		<category><![CDATA[Non-Reportable]]></category>
		<category><![CDATA[Open Interest]]></category>
		<category><![CDATA[Reportable]]></category>
		<category><![CDATA[volume]]></category>
		<category><![CDATA[WCOTI]]></category>
		<category><![CDATA[Whittaker COT Index]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=644</guid>
		<description><![CDATA[If you are a currency trader it can be quite annoying when you cannot access volume data as you can in other markets. This can be instrumental to ones success if your strategy from another insrument outside of Forex requires some type of volume indicator. Although it is not perfect you can use the futures [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a currency trader it can be quite annoying when you cannot access volume data as you can in other markets. This can be instrumental to ones success if your strategy from another insrument outside of Forex requires some type of volume indicator. Although it is not perfect you can use the futures market COT or Commitment of Traders report to gauge this.</p>
<p>Since 2000 the COT reports are released weekly. However, you must keep in mind the reports are released on Friday but reflect data from Tuesday. As the reports are closed off on Tuesday but not published until 3 days later.</p>
<p>When it comes to the COT report there are a few different sections that are valuable:</p>
<p><strong>Commercial</strong>: These are organizations that use the futures market to hedge their positions. They are not traders by nature. They only use futures to guarantee their profits for the future.<br />
<strong>Non-Commercial</strong>: These are the speculators who trade the futures market for a living. They include hedge funds and other individuals who speculate the market and make the requirements that are set by the CFTC.<br />
<strong>Reportable</strong>: Positions held above specific reporting levels set by the CFTC.<br />
<strong>Non-Reportable</strong>: These are individuals or organizations who do not meet the minimum requirements set forth by the CFTC to be categorized.<br />
<strong>Open Interest</strong>: The open interest is the amount of futures or options contracts which are not offset by another transaction.</p>
<p>The Whittaker COT Index Variant-A is an MT4 or MQL4 indicator. Basically what it will do is go through the data from the COT report and extract the above sections. It will then as a percentage let you know how many traders are long in each category.</p>
<p>To use this indicator you must visit the CFTC website and weekly download the updated report. Here is a link to the report that must be downloaded, <a href="http://www.cftc.gov/MarketReports/CommitmentsofTraders/HistoricalCompressed/index.htm">http://www.cftc.gov/MarketReports/CommitmentsofTraders/HistoricalCompressed/index.htm</a></p>
<p>Use the image below to make sure you&#8217;re downloading the correct link. Save this file to C:\Program Files (x86)\Interbank FX Trader 4\experts\files. This path is obviously because I use InterbankFX. Depending on your broker this path may be different.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/03/cot1.jpg"><img class="aligncenter size-full wp-image-856" title="cot" src="http://www.jeremywhittaker.com/wp-content/uploads/2010/03/cot1.jpg" alt="" width="804" height="479" /></a> You first must unzip the file that you downloaded. You can do this with any &#8220;zip&#8221; software. Once you extract this file it must be converted to CSV format for MetaTrader to read it.You can do this by opening the file located at C:\Program Files (x86)\Interbank FX Trader 4\experts\files\annual.xls with Microsoft Excel. Once it is open in Excel go to file&gt;save as. From the save as type window select CSV(Comma Delimited) (*.csv). You will want to name the file annual.xls.csv this by default is what Whitaker COT Index will be looking for.</p>
<p>The actual Whittaker COT Index variant-A can be downloaded <a href="http://www.JeremyWhittaker.com/wp-content/uploads/2010/02/Whittaker COT Index (WCOTI-a).ex4">here</a>. Save the file to C:\Program Files (x86)\Interbank FX Trader 4\experts Once the file is downloaded simply add it to your chart.</p>
<p>Due to the fact that this is a stripped down version of my EA that I use to trade live it is programmed as an EA or expert advisor. I realize it should technically be an indicator and I will reprogram it when I get the opportunity. Also, if you are testing this out on the weekend it is not going to work. It only generates numbers &#8220;on tick&#8221;, so if the market is closed it is not going to do anything.</p>
<p><strong>Update:<br />
I have reprogrammed this EA as an indicator so that it does not have to be loaded as an EA. You can download the updated version <a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/10/Whittaker%20COT%20Index%20(WCOTI-a).ex4">here</a>.  Save to C:\Program Files (x86)\Interbank FX Trader 4\experts\indicators\</strong></p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/03/Whittaker_COT_Index1.jpg"><img class="aligncenter size-medium wp-image-654" title="Whittaker_COT_Index" src="http://www.jeremywhittaker.com/wp-content/uploads/2010/03/Whittaker_COT_Index1-300x128.jpg" alt="" width="300" height="128" /></a></p>
<p>Update 2:</p>
<p>I have recently been asked for an example CSV file.   Here it is &#8211; <a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/03/annual.xls.csv">http://www.jeremywhittaker.com/wp-content/uploads/2010/03/annual.xls.csv</a> The original source file I created this from is here &#8211; <a href="http://www.cftc.gov/MarketReports/files/dea/history/dea_fut_xls_2011.zip">http://www.cftc.gov/MarketReports/files/dea/history/dea_fut_xls_2011.zip</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2010%2F03%2F03%2Fwhittaker-cot-index-variant-a%2F&amp;title=Whittaker%20COT%20Index%20Variant-A" id="wpa2a_18"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2010/03/03/whittaker-cot-index-variant-a/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Whittaker Volatility Breakout Indicator</title>
		<link>http://www.jeremywhittaker.com/2010/02/09/whittaker-volatility-breakout-indicator/</link>
		<comments>http://www.jeremywhittaker.com/2010/02/09/whittaker-volatility-breakout-indicator/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 04:21:09 +0000</pubDate>
		<dc:creator>Jeremy Whittaker</dc:creator>
				<category><![CDATA[Metatrader]]></category>
		<category><![CDATA[average true range]]></category>
		<category><![CDATA[entries]]></category>
		<category><![CDATA[exits]]></category>
		<category><![CDATA[histogram]]></category>
		<category><![CDATA[money management]]></category>
		<category><![CDATA[range]]></category>
		<category><![CDATA[take profit]]></category>
		<category><![CDATA[true range]]></category>
		<category><![CDATA[Whittaker Volatility Breakout Indicator]]></category>
		<category><![CDATA[WVBI]]></category>

		<guid isPermaLink="false">http://www.jeremywhittaker.com/?p=552</guid>
		<description><![CDATA[I wanted to share with everyone an indicator that I programmed and I find very useful. It is called the Whittaker Volatility Breakout Indicator or WVBI. The purpose of this indicator is to represent the range of a bar in percentage terms rather than in points. I think the flaw of most traders or programmers [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to share with everyone an indicator that I programmed and I find very useful. It is called the Whittaker Volatility Breakout Indicator or WVBI. The purpose of this indicator is to represent the range of a bar in percentage terms rather than in points. I think the flaw of most traders or programmers is they often write code and optimize it for pips of a given pair. This I truely believe is one of the core fundamental flaws of sustainability of a strategy. When people start programming static values. Whether it be in money management, entries, exits, or take profit levels.</p>
<p><a href="http://www.JeremyWhittaker.com/wp-content/uploads/2010/02/WVBI Whittaker Volatility Breakout Indicator.ex4" target="_self">Download WVBI!</a></p>
<p>What this indicator does is as follows:</p>
<ol>
<li>Takes the range(high-low) the last x bars.</li>
<li>Averages the range of the last x bars.</li>
<li>Displays as a histogram the percentage of change from the average.</li>
<li>Takes an average of the percentage of change from the average.</li>
<li>Allows you to set a horizontal line at your preference so you can see when the average is breaking out.</li>
</ol>
<p>This indicator has 3 inputs:</p>
<ol>
<li>&#8220;ATRPeriod&#8221; which allows you to specify the amount of bars to average out for the Average True Range of that period</li>
<li>&#8220;WVBIAverage&#8221; is a setting that allows you to specify the amount of bars to which will be the average of the percentage of the ATR.</li>
<li>The last setting is pretty straightforward it is &#8220;TooFar&#8221;.  This simply will draw a horizontal line across the indicator so that you can visually see where the percentage is in comparison to other bars.  Its purpose is to simply put things in perspective.</li>
</ol>
<p>All of this might seem confusing at first. However, I assure you this a very useful indicator for detecting volatility in a market.</p>
<p><a href="http://www.jeremywhittaker.com/wp-content/uploads/2010/02/203.jpg"><img class="aligncenter size-medium wp-image-553" title="203" src="http://www.jeremywhittaker.com/wp-content/uploads/2010/02/203-300x132.jpg" alt="" width="300" height="132" /></a></p>
<p>You can see from this example of above the bar in question exceed it&#8217;s 14 day ATR by 203.95%.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.jeremywhittaker.com%2F2010%2F02%2F09%2Fwhittaker-volatility-breakout-indicator%2F&amp;title=Whittaker%20Volatility%20Breakout%20Indicator" id="wpa2a_20"><img src="http://www.jeremywhittaker.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jeremywhittaker.com/2010/02/09/whittaker-volatility-breakout-indicator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

