Ledge ATR Strategy

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #44636 quote
    RoLaDay
    Participant
    Average

    Hello,

    I would love to create a strategy for the ATR Ledge Indicator. Maybe someone is able to help? It is currently not working and I don’t know why..

    if time = 010500 then
           
    ATRperiod = 14
    // ---
     
    dTR = 0
    for i = 0 to ATRperiod
    dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
     
    avg = dTR/ATRperiod
     
    htr = Dlow(0)+avg[1]
    ltr = Dhigh(0)-avg[1]
    
    ab=(htr-ltr)/2*1+ltr
    
    b=(htr-ab)/4*2+ab
    c=(htr-ab)/4*1+ab+0.0003
    
    d=(ab-ltr)/4*3+ltr-0.0003
    e=(ab-ltr)/4*2+ltr
    
    if not longonmarket and close<c then
    buy 1 share at c stop
    
    endif
     
    if not shortonmarket and close>d then
    sellshort 1 share at d stop
    
    endif
    
    if longonmarket then
    sell at b stop
    sell at d limit
    elsif shortonmarket then
    exitshort at e stop
    exitshort at c limit
    endif
    endif
    

    Thanks a lot!

    #44756 quote
    Nicolas
    Keymaster
    Master

    I did not test your code, but the first thing I can tell you is that your pending orders (STOP and LIMIT ones) are only set at 010500 time and only for 1 bar.

    Pending orders only last 1 bar and should be placed at market each new bar.

    #44796 quote
    RoLaDay
    Participant
    Average

    Hello Nicolas,

    is it recommended to place the pending order at market each new bar or is it then generating new entries for every new bar? How would that work?

    #44800 quote
    Despair
    Blocked
    Master

    A market order will executed with the open of the next bar, so this should NOT be repeated every bar. Limit- and stop-orders on the other hand are only valid one bar and have to repeated if this is what you desire.

    The only pending orders that do not have to repeated are the once you put with the set command (set stop loss for example).

    #44808 quote
    RoLaDay
    Participant
    Average

    ok I understand. But I really don’t have a clue how to solve the problem. If I change the code to “buy / sellshort 1 share at market” instead of “stop” it only buys at the particular time and it does ignore the other condition.

    I want to buy if it’s over c and set a stop at d. Target would be b. And I want to sell if it’s under d and set stop at c. Target would be e.

    I don’t have a clue how to change the stop order to something else.

    #44810 quote
    Despair
    Blocked
    Master
    if close>c then
      buy 1 contract at market
    elsif close<d then 
      sellshort 1 contract at market
    endif
    if longonmarket then
      sell at b limit
      sell at d stop
    elsif shortonmarket then
      exitshort at e limit
      exitshort at c stop
    endif

    Here you go.

    #44814 quote
    RoLaDay
    Participant
    Average

    Thanks a lot for your help but it’s not working

    #44820 quote
    Despair
    Blocked
    Master

    Can you be more specific what is the problem? I assume that you maybe have a mistake in the calculation of the variables. It is easy to get confused with points/pips and price.

    #44825 quote
    Nicolas
    Keymaster
    Master

    If you are not on market, you should placed your pending orders until you get market orders. This is how you should develop the code of your strategy.

    #44826 quote
    RoLaDay
    Participant
    Average

    The problem is that the code above is not working. I want to use it for Forex. Nicolas said that my pending orders are only set at 010500. I want to change this that ithe system starts when the specific entry points are reached and not a specific time. Your code is looking good for me too but it doesn’t work

    #44828 quote
    Nicolas
    Keymaster
    Master

    I don’t know for which instruments your strategy is, your code seems correct, but you should try to code it into 2 different parts instead: one that calculate the price levels for your pending orders at 010500 and one that continuously put your pending orders until one of them triggered.

    #44836 quote
    RoLaDay
    Participant
    Average

    Sounds complicated. Any recommendations or is there a guide how I can code it into 2 different parts?

     

    There is a picture of the indicator attached. I want to buy at the first green line in the middle and sell at the second, vice versa sell at the first red line from the middle and target profit at the second red line.

    Bildschirmfoto-2017-08-29-um-13.09.50.png Bildschirmfoto-2017-08-29-um-13.09.50.png
    #44865 quote
    Jessar
    Participant
    Senior

    I think you also want the only one position is open until it reaches the goal or the stop again? Would the market move to the first green line in a sideways movement, which could be fatal if strategy X opened positions?

     

    I am quite good at developing strategies myself, but I have no idea of programming myself, I only manage to mend strategies from others.

    #44873 quote
    Despair
    Blocked
    Master

    @Jessar: Just come with your ideas. Maybe there is something I can code for you.

    #44892 quote
    RoLaDay
    Participant
    Average

    @jessar: exactly it should only open one short or long until it is closed.

    Any ideas?

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

Ledge ATR Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
RoLaDay @roladay Participant
Summary

This topic contains 22 replies,
has 5 voices, and was last updated by RoLaDay
8 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/25/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...