HELP: Buy contract after some time

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #71516 quote
    raphaelopilski
    Participant
    Senior

    Hi guys,

    I would like to buy a contract after the first contract is x bars old and negative. So that I would have 2 contract in total. And after that, if the cumulated contracts are positive (lets say 10 pips), the system should sell them both.

    Thanks for helping!

    #71519 quote
    immo_vienna
    Participant
    Average

    Hallo Raphael!

    I think you mean this:

    https://www.prorealcode.com/blog/trading/averaging-techniques-automated-trading/

    hope this can help you a bit

    #71546 quote
    Vonasi
    Moderator
    Master
    BarWait = 20
    
    IF not LongOnMarket and (your conditions) then
    BUY 1 contract at market
    ENDIF
    
    IF LongOnMarket and (your conditions) and BarIndex - TradeIndex >= BarWait and close < PositionPrice then
    BUY 1 contract at market
    ENDIF
    
    IF LongOnMarket and close > PositionPrice + 10 then
    Sell at Market
    ENDIF  
    

    This should do what you want. Difficult to tell from the description whether you want to stop trading at two positions or not. This code will just keep on buying.

    immo_vienna and Nicolas thanked this post
    #71547 quote
    raphaelopilski
    Participant
    Senior

    thank you guys

    #71566 quote
    Vonasi
    Moderator
    Master

    No problem. there was a minor typo in the first BUY line so I have corrected that.

    You could also consider only re-entering if the market has fallen by a certain percentage with something like this:

    PercDrop = 1.5
    
    IF LongOnMarket and (your conditions) and BarIndex - TradeIndex >= BarWait and close < PositionPrice * (1 - (PercDrop/100)) then
    BUY 1 contract at market
    ENDIF

    There are benefits and disadvantages to this. Less trades = less exposure but you may miss trades right at the bottom of the market meaning that price has to climb further before you are in profit.

    immo_vienna thanked this post
    #71568 quote
    Vonasi
    Moderator
    Master

    Another possibility is to increase your position size by an amount relative to the amount that the market has dropped.

    PositionSize = 1
    
    IF LongOnMarket and (your conditions) and BarIndex - TradeIndex >= BarWait then
    BUY PositionSize + (PositionSize * (((close / PositionPrice) * 100) - 100)) contracts at market
    ENDIF
    

    Just some ideas – nothing proven!

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

HELP: Buy contract after some time


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/28/2018
Status: Active
Attachments: No files
Logo Logo
Loading...