Need help with automatic a strategy for DAX and SA40

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #105257 quote
    Lombard974
    Participant
    Junior

    Good day

    I am looking for someone that can help me to code a automatic strategy.. it is a very simple strategy which i use on a daily basis but i want to automate it.. I have no

    coding experience so thats why i need someone that can help me please.

    Thanks

    #105258 quote
    jebus89
    Participant
    Master

    ill help u. Whats the rules? (i got 200K bars as well)

    #105259 quote
    Lombard974
    Participant
    Junior

    Thank you for the reply..

    The rules are- for south african 40 and dax on 15 min chart

    Markets open at 9 am my time: There is a candle that forms 8:45 to 9:00.

    At exactly 9 am I want to place a buy stop above the high and a sell stop below the low of the 8:45 candle.
    When one order is triggered the other must be canceled.

    Stop loss must be adjustable and that i will test once i can do back testing.
    Tp must also be adjustable.

    A second option must also be available to add another trade at example 50 points from first entry. Like hedging but i will also test it first.

    So basically breakout of 8:45 candle with adjustable sl and tp. Contracts must also be adjustable 1 or 2 or 5 contracts ect..

    Hope it is clear

    Thank you

    #105264 quote
    Lombard974
    Participant
    Junior

    Hi

    IS there a way to contact you via a message system or how can we talk if there are any questions?

    Thanks

    #105269 quote
    Vonasi
    Moderator
    Master

    Lombard974 – Do not double post as it just wastes the time of those trying to help you and leads to confusion – especially if you double post in the wrong forums! Both Roberto and I have had to waste time moving and deleting your posts this morning. Double posting does not get you a faster or better answer – in fact it does the opposite!

    #105270 quote
    Vonasi
    Moderator
    Master

    If you want to place two pending orders and cancel one when the other is filled then you will need to use MTF on a very fast time frame which will massively limit your back test data available to test on.

    Hedging is not possible in PRT as you cannot have a strategy both long and short at the same time. You would need two strategies and simulate the other strategy in each. There would however be some inaccuracy in prices as the fill price is not always the same as the close or open price that you would be simulating with.

    #105272 quote
    Lombard974
    Participant
    Junior

    Hi Vonasi

    Sorry its my first time using the forum and i dont know exactly how to reply.. sorry for that. What i mean with hedging and maybe its not the right term.. If for example my sell order is triggered  at that specific time buy stop is canceled and another sell stop order is placed 50 points below my entry.. if prices goes doen further it triggers the second sell..  so i have 2 short trades running with same tp.

    I hope it is clear?

    Thanks

    #105408 quote
    Vonasi
    Moderator
    Master

    Something like this will mean that your buy order is cancelled after 1 second if your sell order is hit. It then sends a pending order every second to the market 50 pips from your entry price until that is filled.

    timeframe(daily)
    
    longlevel = high[1] //long entry price - yesterdays high in this example.
    shortlevel = low[1] //short entry price - yesterdays low in this example. 
    
    
    timeframe(1 second)
    
    if not onmarket then
    buy 1 contract at longlevel stop
    sellshort 1 contract at shortlevel stop
    endif
    
    if countofposition = 1 then
    buy 1 contract at tradeprice + 50 stop
    endif
    
    if countofposition = -1 then
    sellshort 1 contract at tradeprice - 50 stop
    endif
    #105528 quote
    Lombard974
    Participant
    Junior

    Hi

    Thank you for the reply.. is this the complete code for my strategy i want to implement? How do i change code for 15 min time frame?

    I am trying to read up in the documentation but dont know how to put it all together.

    Can you please help me with the complete code?

    Than you

    #105530 quote
    Vonasi
    Moderator
    Master

    No this is not a complete strategy. It is just showing how you can send long and short pending orders to the market and cancel one if the other is filled – and then to allow a second position to be entered once the first is opened.

    #105531 quote
    Lombard974
    Participant
    Junior

    Is it possible you can help with the complete code? I am trying but just getting errors.. I have no idea what i am doing.

    thank you

    #105539 quote
    Vonasi
    Moderator
    Master

    Is it possible you can help with the complete code?

    I’m busy with other stuff tomorrow and then flying back to Greece the next day so time is a bit short at the moment. Perhaps someone else can help as it is only adding stoploss and take profit and adding some trading times in? You may need to give more detail such as do you want the TP and SL levels to be at the same levels for the added positions as for the first positions etc.

    Be aware as I said before that to have one order cancel another order means that you have to use the 1 second time frame and so worthwhile back testing is going to be pretty hopeless due to the limited data sample in the 1 second time frame.

    #105562 quote
    juanj
    Participant
    Master

    Hi Lombard974, I am sure I can assist you with the coding if you are looking for more comprehensive assistance: http://www.FXautomate.com

    #105593 quote
    Lombard974
    Participant
    Junior
    DEFPARAM CumulateOrders = false
    DEFPARAM FLATBefore     = 084500                         //09:00
    DEFPARAM FLATAfter      = 210000                         //21:00
    DEFPARAM PreLoadBars    = 2000
     
    ONCE nLots              = 5
    ONCE MaxPrice           = 999999
    ONCE MinPrice           = 0
    ONCE FirstHour          = 090000
     
    IF time = FirstHour THEN
    MaxPrice = highest[3](high)                          //Il massimo/minimo delle ultime 12 barre
    MinPrice = lowest[3](low)                            //   (ogni ora = 12 barre da 5 minuti)
    ENDIF
    //************************************************************************
    //     trailing stop function
    trailingstart = 20   //5    trailing will start @trailinstart points profit
    trailingstep  = 50    //5    trailing step to move the "stoploss"
    //
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************
    //                           LONG
    a1 = price1 CROSSES OVER MaxPrice
    IF a1 THEN
    Buy nLots CONTRACT AT MARKET
    MaxPrice = 999999
    MinPrice = 0
    ENDIF
     
    //                           SHORT
    b1 = price2 crosses under MinPrice
    IF b1 THEN
    Sellshort nLots CONTRACT AT MARKET
    MaxPrice = 999999
    MinPrice = 0
    ENDIF
    
    price1 = TotalPrice >  maxprice
    price2= TotalPrice  < minprice
    
    ENDIF
    

    Hello

    I treid to modify this code i fund in the forum.. To enter the trade when it breaks the high or the low of the previous bar and not to wait for the close first. I am trying to define the price to break the highest or lowest of the MAXPRICE an MINPrice but dont know how to do it. Can you please assist me to fix it,

    Thanks

    #105595 quote
    Lombard974
    Participant
    Junior

    I dont know how to set it up so that it uses a sl… Because the trailing stop works but sometimes the trade goes into negative from the start and then it doesnt close for  a long time or until account is empty.

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

Need help with automatic a strategy for DAX and SA40


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Lombard974 @lombard974 Participant
Summary

This topic contains 16 replies,
has 5 voices, and was last updated by Paul
6 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/22/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...