Pro builder language buy and sell orders

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5287 quote
    Privatepilot_Mitch
    Participant
    New

    Hello all,

    I’m completely new to work with automatic trading robots such as prorealtime, it looks great and I see a lot off opportunities. Now I need some help, to translate a part of my trading strategy to pro builder language. Hopefully will someone help me with this, now lets start with an example,

    I buy 2 contracts at the market (DAX) when this meet some indicator criteria, lets say 9600 for a long position. This is very clear for me to program, but when the market goes down I will buy 1 contract at 9595 (minus 5 points from the first position), buy 1 contract at 9585 (minus 10 points from the second position), buy 1 contract at 9565 (minus 20 points from the third position). If one of these orders is execute, I will sell the position with 5 points profit, for example 9595 executed and sell it at 9600. If it goes more down, I buy 1 contract at 9525 (minus 40 points from the last position), 9475, 9435 and so on. If one of these orders is execute, I will sell the position with 10 points profit, for example 9525 executed and sell it at 9535, and so on. This orders need to execute till my profit target for this strategy is reached from all open positions together.

     

    Many thanks in advance!

    #5292 quote
    Nicolas
    Keymaster
    Master

    Hello,

    What you want to be coded here is a typical averaging down orders grid, isn’t it?

    If so I remember have coded something similar as an example in the prorealtime documentation here.

    Here is the code though :

    myMACD = MACD[12,26,9](close)
    long = myMACD crosses over 0
    
    //first order
    IF NOT LongOnMarket AND long THEN
      BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    //averaging down
    IF TRADEINDEX(1)>5 AND TRADEPRICE(1)-Close>20 AND LongOnMarket THEN
      BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    //closing all positions when current close is superior of the average positions price
    IF COUNTOFPOSITION >= 2 AND Close > POSITIONPRICE THEN
      SELL AT MARKET
    ENDIF
    
    SET TARGET PROFIT 20

     

    Of course you’ll have to adapt the code a bit for your dynamic grid space between orders. But that’s a good start to learn more of the possibilites of ProOrder trading module.

    #5295 quote
    Privatepilot_Mitch
    Participant
    New

    Hello Nicolas,

    First of all, thanks for the very quick response!

    It’s a kind of averaging down orders, yes. But I want to sell my executed orders (positions), if they reached my targets (5 points or 10 points), for example when the market goes straight down to 9565 and then up to 9590 and then down to 9580. In this example, I need to buy at 9595, 9585 and 9565 then sell at 9570 and 9590 and then buy again at 9585. So, wen the market goes sideways between 9565 and 9590, I can make small profits so that I reach my strategy profit target sooner.

    #5298 quote
    Nicolas
    Keymaster
    Master

    Ok, so you want to partially close the orders basket. Be aware that trades made with ProRealTime are position centric and the whole orders become a global one, so there are limitations while playing with a bunch of orders conditions at the same time 🙂

    It’s not so difficult to achieve but very time consuming. I can help you code the strategy but you’ll have to put some work on too.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Pro builder language buy and sell orders


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Nicolas
9 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/12/2016
Status: Active
Attachments: No files
Logo Logo
Loading...