Open trade when price touch a MA?

Posted By hypnose Sunday, August 22, 2010
Add to Favorites0
Author Message
hypnose
 Posted Sunday, August 22, 2010
Forum Newbie

Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)Forum Newbie - (6 reputation)

Group: Forum Members
Last Active: Sunday, September 26, 2010
Posts: 6, Visits: 42
6
Hi,

I'd like to know if it would be possible to open a position when the price touch a moving average?

This is what I have but it does not work:

if (FloatToStr(History.Last(0)) = FloatToStr(MA2.Graph.Last(0))) then

I get an error message.

Can anyone help me please to detect when the price is equal to a moving average value?

Thanks in advance
Hyp
black
 Posted Monday, August 23, 2010
Supreme Being

Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)Supreme Being - (1,423 reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 462, Visits: 848
hypnose (8/22/2010)
Hi,

I'd like to know if it would be possible to open a position when the price touch a moving average?

This is what I have but it does not work:

if (FloatToStr(History.Last(0)) = FloatToStr(MA2.Graph.Last(0))) then

I get an error message.

Can anyone help me please to detect when the price is equal to a moving average value?

Thanks in advance
Hyp


1. Use 2 Histories, except if you are averaging Ticks. If your average is some other period than Tick, use a Tick History along with the History of your moving average. Call the Tick History "History" and the MA History "History1." I would use Minute for the second History period. But averaging Ticks might produce interesting results.


2. Use > (greater than) and < (less than) rather than = (equals).
if (History.Last(1) > MA.Graph.Last(1)) then

NOTE: My experience when using "(0)" is that it is unreliable. Try it, and if it works for you, great.

if (History.Last(0) > MA.Graph.Last(0)) then


3. Since Ticks jump around so that one Tick may go above the MA, and the next one back below the MA, and the third one back above the MA, if you don't want to have a whole bunch of open positions, you must limit how many positions can be open at one time. One way to keep only one position open at a time is to:
if (History.Last(1) > MA.Graph.Last(1))
and (TradeList.Count = 0) then


4. If you want more than 1 position open, but only one each Tick, and you want to limit it to some number, use a variable called "MaxOpenPos."

MaxOpenPos : Double

AddFloatSetting(@MaxOpenPos, 'Maximum Open Trades', 3);

if (History.Last(1) > MA.Graph.Last(1))
and (TradeList.Count < MaxOpenPos) then

NOTE: I used Float, Double, Extended. If you can make Integer work, it is better. Use it.

MaxOpenPos:Integer

AddIntegerSetting(@MaxOpenPos, 'Maximum Open Trades', 3);

if (History.Last(1) > MA.Graph.Last(1))
and (TradeList.Count < MaxOpenPos) then


5. Using the Tester with Ticks requires a large amount of information to be downloaded. This is because there may be dozens of Ticks in some minutes, and there are 1440 minutes in a day. Be sure that your Broker will accept downloading large numbers of Ticks. Minutes are large enough.

Monday, August 23, 2010 by black

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top