1 hr Breakout strategy for fx

Questions about MultiCharts and user contributed studies.
User avatar
t-rader
Posts: 139
Joined: 02 Feb 2011
Location: Australia
Has thanked: 11 times
Been thanked: 27 times

1 hr Breakout strategy for fx

Postby t-rader » 16 Feb 2011

Hi,
(this has been edited to be more clear).

I use Multicharts and am trying to write a simple breakout strategy that will set a high and low range for the first hour of trading. (The chart is set to 1hr bars with 5 days of history). THE REST OF THE SYSTEM: Once the first hour is finished, a BUY will be placed as soon as the price equals the high range (plus one point). Then once the BUY order is filled, a profit of 25 points and a stoploss of 50 points is set.

This is what I have so far, but it looks like "close" is not being calculated tick-by-tick for all bars in my 5 day chart. It does however, seem to be tick-by-tick when trading live.

NB: In my timezone, the start time for the GBP/USD market is 1800.

[IntraBarOrderGeneration=true] ;
Input: RangePeriodFinishTime(2000) ;
Var: InTradingWindow(False), RangeHigh(0), RangeLow(0) ;

// Ready to enter if close=rangehigh
InTradingWindow = Time >= RangePeriodFinishTime ;

// Set the RangeHigh and RangeLow variables
If marketposition=0 and time = RangePeriodFinishTime then
begin
RangeHigh = high[1] + 1 point ;
Rangelow = low[1] - 1 point ;
End ;

// Checking if we can go long
If marketposition = 0 and InTradingWindow and close=RangeHigh then
begin
BUY ("GoLong") next bar at market ;
End ;

If MarketPosition = 1 then
Begin
Sell ("Long Profit") next bar (entryprice + 50 points) stop ;
Sell ("Long Loss") next bar (entryprice - 25 points) stop ;
End ;

I seem to be having problems with the intra-bar price detection with this section below
If marketposition = 0 and InTradingWindow and close=rangehigh then
begin
BUY ("GoLong") next bar at market ;
End ;

Why doesn't it "BUY" until the current bar's close, open, low or high equals "rangehigh"?????? Why doesn't it just "BUY" at the point that it should (RangeHigh)???

Regards
T

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: 1 hr Breakout strategy for fx

Postby Dave Masalov » 16 Feb 2011

Dear t-rader,

You are talking about historical calculation (backtesting), am I correct? Could you please tell us if you use Bar Magnifier (Strategy Properties -- >Backtesting)? IntraBarOrderGeneration works only in real-time, not in backtesting on historical data.

User avatar
t-rader
Posts: 139
Joined: 02 Feb 2011
Location: Australia
Has thanked: 11 times
Been thanked: 27 times

Re: 1 hr Breakout strategy for fx

Postby t-rader » 16 Feb 2011

Hi Dave,

Yeah I guess I'm talking about 2 things regarding backtesting.
1. How do I perform backtesting, using the backtesting program, and have it report accurately as if it was done in real-time (how to get tick-by-tick info on a 1hr chart).
2. When I perform basic testing while writing a strategy, I load about 5 days worth of data on my chart so I can check the accuracy of my system. On the chart, I want to be able to see intrabar results. i.e buy orders executing as if I was running the strategy in real-time.

PS. I haven't tried Bar Magnifier (Strategy Properties -- >Backtesting).

Cheers
T

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2223 times

Re: 1 hr Breakout strategy for fx

Postby TJ » 16 Feb 2011

Hi Dave,

Yeah I guess I'm talking about 2 things regarding backtesting.

1. How do I perform backtesting...

Cheers
T
press [F1]
look under MultiCharts > Strategy Trading > Backtesting

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: 1 hr Breakout strategy for fx

Postby Dave Masalov » 17 Feb 2011

I haven't tried Bar Magnifier (Strategy Properties -- >Backtesting).
t-rader,

You should try it. Basically, it allows you to look inside bars when you backtest your strategy. You can find more information in MultiCharts Help. Also, you may want to try Extended backtesting mode (Strategy Properties -- >Backtesting) for more precision.


Return to “MultiCharts”