Help with automated strategy for EURUSD

Forums ProRealTime English forum ProOrder support Help with automated strategy for EURUSD

Viewing 8 posts - 1 through 8 (of 8 total)
  • #54819

    Hi everybody,  First posts so be sweet with me pls. I am looking to code an automated strategy for EURUSD trends. I need to add a feature where if the market moves in one direction with candles > x it trades, while if candles are < than x it stops.  Any suggestions? Thanks, Edoardo

    #54828

    By “candles > x” do you mean:

    1. candles whose Opening/Closing/Highest/Lowest (which one?) is > x?
    2. candles whose range is > x?
    3. number of consecutive bullish/bearish candles greater than x?

    Also, what does “candles are < than x it stops” mean? What should be stopped, the strategy, the current trade…?

    Please post a real example, so we can try to be of some help.

    Roberto

    #54911

    Hello Roberto

    Thanks for offering help. I have an example below so that you can help further, but I also want to explain what I-m trying to do.

     

    I have a strategy that buys into eurusd trends, it makes money when the market raises with more than 3 green 1 min candles or falls with more than 3 red 1 minute candles, but loses money when market does a red and a green candle or viceversa. I define this market absence of trend FLAPPING.

    So I-d like to have a code, which I can-t program yet, that tells the auto trading system not to initiate a new trade if the previous difference between candles is small.

     

    Here is what I have come up with

     

    // Initialization of Amplitude
    Amplitude = 0.001
    // Initialization of detector
    Detector = 0

    // Definition of Flapping

    IF ABS((Low – High [1]) / High [1]) < Amplitude THEN
    // Behavior of the detector
    Detector = 1
    ENDIF

    // Absence of Flapping

    IF ABS((High – Low [1]) / Low [1]) > Amplitude THEN
    // Behavior of the detector
    Detector = -1
    ENDIF

    Thank you for your contributions, Edoardo

    #54936

    Please use the “Insert PRT code” button identified by <> on the grey bar when you are posting, to make code more readable and easier to understand, as follows:

    A few questions:

    1. in your code you did not check whether 3 consecutive matching bars have elapsed or not (3 green bars or 3 red ones)
    2. 0.001 is the difference in price between two bars?
    3. a difference between candles/bars should be computed using which price (low,high,open,close) or maybe their range?
    #55006

    Answers to your questions

     

    1. I-m not at the stage of defining the three candles yet (trend), so far I check only if the current close is higher or lower than the previous.
    2. yes is what I intended to use to define the range of the candle in %
    3. what I think is most relevant is the difference between the closes.

    thanks for your help, 

    Edoardo

    #55225

    Your code works, though it seems not profitable at this stage.

    What kind of help are looking for?

     

    #55256

    Hi Roberto,

    Glad to hear you found no glitches in the SW. Do you think that the way I have designed it to stop trading in absence of trend works well. Is there a better way to do it in your opinion, thanks, Edoardo

    #55260

    You might use this code to detect whether your are in a range or not:

    IF OutOfRange is true you will know you are not within a range (according to your settings, 50, 20 or whatever you choose).

    You may try to find out other and better ways to determine if an instrument is trending or not. With the help of the serach box you may scan this forum for, say, the words TREND or RANGE. You may even search the web and then translate to PRT any way you may find worth while spending some time.

Viewing 8 posts - 1 through 8 (of 8 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login