|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 9/26/2010 9:41:24 AM
Posts: 6,
Visits: 42
|
|
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
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2/7/2012 10:15:57 AM
Posts: 445,
Visits: 818
|
|
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.
Edited: 8/23/2010 8:17:15 PM by black
|
|
|
|