Perfect Trend Indicator with automatic trading

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #50722 quote
    Eduardo Siverio
    Participant
    New

    Hi Nicolas, in order of your recommendation I´m writing here what I need to do for using your Perfect Trend indicator as an automatic trader. First of all, I want to operate in DAX Full Future in 1 minute, and I´ve made a list of paramethers that I wish it would have, for example:

    1. Open only longs
    2. Open longs when the blue dot gets on
    3. Limit: 5 points
    4. Stop: 5 points
    5. Close the operation if a red dot gets on
    6. Get a minimum of 20 points daily and a máximum of 24
    7. Maximum of operations daily: 150
    8. Schedule: From 8:00 to 17:00

    Thank you very much.

    Eduardo Siverio

    Lotech123 thanked this post
    #50725 quote
    Nicolas
    Keymaster
    Master

    When you speak English, it is obvious to open a thread in the English forum .. just saying it ..

    This is the code of the strategy you asked for. I omit the MaxDaily profit which I don’t think it is useful in this case, make your own tests and tell us how it goes..

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    defparam flatbefore = 080000
    defparam flatafter = 170000
    
    // --- settings
    SlowLength         = 7 // Slow length
    SlowPipDisplace    = 0 // Slow pip displace
    FastLength         = 3 // Fast length
    FastPipDisplace    = 0 // Fast pip displace
    MinDailyProfit=20 //Max daily loss allowed  (in points)
    // --- end of settings
    
    thigh1 = Highest[SlowLength](high)+ SlowPipDisplace*pointsize
    tlow1  = Lowest[SlowLength](low)- SlowPipDisplace*pointsize
    thigh2 = Highest[FastLength](high)+ FastPipDisplace*pointsize
    tlow2  = Lowest[FastLength](low)- FastPipDisplace*pointsize
    
    if barindex>2 then
    if Close>line1[1] then
    line1 = tlow1
    else
    line1 = thigh1
    endif
    if Close>line2[1] then
    line2 = tlow2
    else
    line2 = thigh2
    endif
    endif
    
    if (Close[0]<line1[0] and Close[0]<line2[0]) then
    trend =  1
    endif
    if (Close[0]>line1[0] and Close[0]>line2[0]) then
    trend = -1
    endif
    if (line1[0]>line2[0] or trend[0] =  1) then
    trena =  1
    endif
    if (line1[0]<line2[0] or trend[0] = -1) then
    trena = -1
    endif
    
    //----
    // first time we launch the code, the trading is allowed
    once TradeAllowed=1
    if intradaybarindex=0 then 
    count=0
    MyProfit=STRATEGYPROFIT
    TradeAllowed=1
    endif
    
    // test if the strategyprofit of the day is currently above the daily profit allowed 
    If StrategyProfit>=MyProfit+(MinDailyProfit*POINTVALUE) then
    TradeAllowed=0
    endif
     
    if TradeAllowed and trena<>trena[1] and trend=-1 and not onmarket and count<150 then
    buy 1 contract at market 
    endif
    if longonmarket and  trend=1 then 
    sell at market
    endif
    if longonmarket and tradeindex<>lastindex then 
    count=count+1
    lastindex=tradeindex
    endif
    
    SET STOP PLOSS 5
    SET TARGET PPROFIT 5
    #50742 quote
    Eduardo Siverio
    Participant
    New

    Muchas gracias Nicolas y mil disculpas por lo del inglés, desconocía que estaba en el foro en español.

    Una pregunta, me aparece un error de sintaxis en la fila 5, qué debo hacer para corregirlo?

     

    Gracias

    Lotech123 thanked this post
    #50750 quote
    Nicolas
    Keymaster
    Master

    The topic is now in the English forum, do not speak Spanish please. There is no syntax error in the code, please copy/paste it once more.

    #50782 quote
    Eduardo Siverio
    Participant
    New

    Sorry for the spanish.

    I´m attaching the error the system gives me, I´ve tryed several times copying and pasteing the program but I can´t validate it. Also I´ve erased the symbol that is giving me the “error” and the thing became worse. When I downloaded your Perfect trend indicator was from an ITF file, I don´t know if it´s posible to have this code like an ITF file too to import it directly and avoid the copy/paste. Please excuse my ignorance in this subject.

     

    Thank you

     

    Eduardo Siverio

    #50784 quote
    Nicolas
    Keymaster
    Master

    Totally odd, what is the “symbol” you erased that give you the error? There is no character at line 5!

    Please try to delete the “añadir” variable that still exist (certainly from a previous code) in the optimisation settings.. Variable name can’t have accent, this is what may cause the problem here.

    #50787 quote
    Eduardo Siverio
    Participant
    New

    Well, I can´t see the symbol, but the space is being occuped by a ” ” (I´ve copied and pasted it, is between question marks), and it appears in lines 5, 13, 18, 31, 44, 53, 58 and 69 too. I erased everything and paste only the code, but it remains the “sintaxis error”. In the attachment you can see what it looks like.

    #50790 quote
    Nicolas
    Keymaster
    Master

    I think the way you copy/paste code from here is wrong. Are you on PC or MAC or LINUX? What is your web browser?

    Please find below the instructions on how to copy/paste code from this website.

    #50793 quote
    Eduardo Siverio
    Participant
    New

    Got it!

    Thank you, on monday i`ll try it in demo.

    #51398 quote
    Eduardo Siverio
    Participant
    New

    Hi Nicolas,

    I adjusted the limit and the stop in the backtest, I put Limit 6 and stop 8. The result in a walk forward was terrible. My idea was to earn 50 points per week, and between monday and wednesday I earned 28.5 points (not bad) but between thursday and friday I lost 51 points. The result is -22.5/week. My idea doesn´t works. So, If you have some recomendation to improve the code (or another code) I´ll be glad to read about it. Thank you for your time.

     

    Eduardo

    #51427 quote
    Nicolas
    Keymaster
    Master

    Why not backtesting it and try to improve the strategy? Testing a strategy only during one week should not guarantee if it is worth nothing (or if it’s worth one million dollars too .. ).

    #51432 quote
    Eduardo Siverio
    Participant
    New

    thank you again, I´ll try to improve it.

    #51554 quote
    Eduardo Siverio
    Participant
    New

    Hi Nicolas,

    It´s posible to add a maximum daily loss to the code and a trailing stop of 1 point that activates when the value gets the target profit?

     

    Thank you

     

    Eduardo

    #51559 quote
    Nicolas
    Keymaster
    Master

    A trailing stop of “only” 1 point should not work, it depends mainly of the allowed stop distance from price from your broker (and it’s different for every single security).

    About a daily loss trigger, you have something already available in this blog post: https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/

    #51569 quote
    Eduardo Siverio
    Participant
    New

    thank you Nicolas

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

Perfect Trend Indicator with automatic trading


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 17 replies,
has 2 voices, and was last updated by Mitchy14
3 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/27/2017
Status: Active
Attachments: 3 files
Logo Logo
Loading...