eur/usd 2m MA Candle strategi

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #33574 quote
    MagnusalMagnusal
    Participant
    New
    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
    #33579 quote
    StantonRStantonR
    Participant
    Senior
    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
    #33613 quote
    MazMaz
    Participant
    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.
    ALE and Nicolas thanked this post
    #33623 quote
    StantonRStantonR
    Participant
    Senior
    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
    Nicolas, Magnusal and Maz thanked this post
    #33628 quote
    JC_BywanJC_Bywan
    Moderator
    Master
    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)

    #33833 quote
    MagnusalMagnusal
    Participant
    New
    Thank you for helping me out StantonR. I will post something when its up and running.   Magnus
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

eur/usd 2m MA Candle strategi


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Magnusal @magnusal Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by MagnusalMagnusal
9 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/26/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...