Im new to Pro Real Code so im asking if anyone can help me build a simple strategi (i think its simple:-)
Long position when a candle open above ma in 2min EUR/USD and sell when a candle crosses MA with X margin and the other way around for shorts.
Maybe its wise to separate this 2 strategis so you can use only one when it is a strong trend.
Great if anyone can put me in the right direction building this strategi
Magnus
Hi Magnus
Welcome to the forum.
What is the period for the moving average.
Do you want to exit when it crosses back below that MA by a certain margin.
Thanks
MazParticipant
Veteran
Here you go buddy
// px-dx-test
// --------------
// -- System parameters --
DEFPARAM preLoadBars = 1000
// -- Variables --
once positionSize = 1
// maType = 0
// maPeriod = 20
// deathCrossMargin = 20
// price = close // could be high | low | typicalprice etc etc
// -- Indicators -----
MA = average[maPeriod, maType](price)
// -- long entry conditions -----
bc1 = not longOnMarket and close crosses over MA
// -- long exit conditions -----
le1 = longOnMarket and price <= (MA - deathCrossMargin)
// -- execution -----
if bc1 then
buy positionSize shares at market
elsif le1 then
sell at market
endif
Have fun with the variable optimizer and different instruments.
Small Change
You have to multiply Margin bu pipsize else its subtracting margin which is 20 from MA value.
// px-dx-test
// --------------
// -- System parameters --
DEFPARAM preLoadBars = 1000
// -- Variables --
once positionSize = 1
// maType = 0
// maPeriod = 20
// deathCrossMargin = 20
// price = close // could be high | low | typicalprice etc etc
// -- Indicators -----
MA = average[maPeriod, maType](price)
// -- long entry conditions -----
bc1 = not longOnMarket and close crosses over MA
// -- long exit conditions -----
le1 = longOnMarket and price <= (MA - deathCrossMargin*pipsize)
// -- execution -----
if bc1 then
buy positionSize shares at market
elsif le1 then
sell at market
endif
Hi Magnus welcome to the site,
>> Could you please update your country flag in your profile? Thank you 🙂 <<
(go to top right corner on your profile picture, a menu appears, click on “settings”, and in your profile select “location” and update your contry, thanks)
Thank you for helping me out StantonR.
I will post something when its up and running.
Magnus