Cumulative orders based on prev order and ATR?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #46336 quote
    LOLO
    Participant
    Junior
    Hi, I’m stuck and could use a little help. I would like to add orders based on price of last order + ATR, I think I got that right. But I would also like the Stop Loss to follow along, that’s to big challange for me. Anyone want to help? Example. Price 100 ATR 10 Order 1: 1 contract @ 100, stop @ 90 Order 2: 1 contract @ 110. stop @ 100 and stop for order 1 should also move to 100 Order 3: 1 contract @ 120, Stop @ 110 and stop for both order 1 and 2 should move to 110 Order 4: 1 contract @ 130, stop @ 120 and stop for order 1-3 should move to 120. Maximum orders at any give time is 4 and the last stop should not move from 120. Exit is @ Low [n] not a stop loss. If let’s say price move to 115 and down to 75, order 1-2 should execute and then stop out @ 100 with 10 loss. Let’s say price move to 200 and then down to 110, and Exit (Low [10]) is 180, all the orders should exit @ 180 with entry @ 100-110-120-130 and profit 260. It’s alot like the moneymanagementsystem as turtle traders used back in the day….at least according to one of the books.
    #46337 quote
    DespairDespair
    Blocked
    Master
    This shouldn’t be problem. To you mind sharing your code you have so far so I can add the stops and so on.
    #46340 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    >> Hi, Please update your country flag by selecting a location in your profile settings. Thank you 🙂 <<

    #46344 quote
    LOLO
    Participant
    Junior
    Thanks, here’s the code so far: I’m looking for a modified version of turtle trading strategy, most for fun and see if it works nowadays. Read the book couple of weeks ago, great story by the way.  🙂 Adding 1/4 ATR to each position and move the stop accordingly, the first example was for ilustration only.
    DEFPARAM CUMULATEORDERS = true
    
    a = highest[55](high)
    b = lowest[20](low)
    c = Average[50](close)
    d = Average[200](close)
    Avg = 0.25*AverageTrueRange[14](close)
    
    // Long Entry
    Long = HIGH>a[1] AND c > d
    // Long Exit
    LongExit = LOW<b[1]
    
    if countofposition<=4 then
    IF NOT LongOnMarket AND Long THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    IF High>TradePrice(1)+avg THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    ENDIF
    SET STOP LOSS 2*AverageTrueRange[14](close)
    
    If LongOnMarket AND Longexit THEN
    SELL AT MARKET
    ENDIF
    #46347 quote
    DespairDespair
    Blocked
    Master
    Ok and where do you want to have the SL? Always 2*ATR away from the combined positionprice? This would look like this:
    if longonmarket then
      sell at positionprice-2*averagetruerange[14](close) stop
    endif
    #46349 quote
    LOLO
    Participant
    Junior
    Ok, what do you mean with combined price? I assume you mean 2*atr from last position taken, is that the same perhaps?
    #46350 quote
    LOLO
    Participant
    Junior
    Or to be more precise, it’s 2*atr from last position entry price.
    #46351 quote
    DespairDespair
    Blocked
    Master
    So you do not want the SL to be in the distance from the combined price (your average position price changes when you cumulate) but from the last lot you bought? In that case just replace positionprice with tradeprice.
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Cumulative orders based on prev order and ATR?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
LO @lars-olof_moberg Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by DespairDespair
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/16/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...