Only trade when above/below x% on previous day close?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #58579 quote
    jbyrne
    Participant
    Average

    Hi, I’m currently trying to backtest some ideas and I need ProOrder to only deal if stock is above/below ‘x’% on previous days close. For example, I may want to only deal when the stock is over +2% on previous days close. Since theres no timeframe in ProOrder I don’t know how to do this.

     

    Can anybody show me how to code this?

    Thanks in advance

    #58582 quote
    Vonasi
    Moderator
    Master
    Percentage = 10
    
    IF close > (DClose(1) * (1 + (Percentage/100))) THEN
    BUY 1 Contract AT Market
    ENDIF
    
    IF close < (DClose(1) * (1 - (Percentage/100))) THEN
    SELLSHORT 1 Contract AT Market
    ENDIF
    

    Is one option which opens a position at the close of the candle if it is your chosen percentage above/below the last candleclose.

    Or you can:

    Percentage = 10
    
    UpBuyPrice = (DClose(1) * (1 + (Percentage/100)))
    DownBuyPrice = (DClose(1) * (1 - (Percentage/100)))
    
    BUY 1 Contract AT UpBuyPrice LIMIT
    SELLSHORT 1 Contract AT DownBuyPrice LIMIT

    which sets  market orders to buy/sell if the chosen increase or decrease is reached.

    jbyrne thanked this post
    #58612 quote
    jbyrne
    Participant
    Average

    Thanks a lot, seems to work how I need it 🙂

    #58613 quote
    Vonasi
    Moderator
    Master

    Sorry – I just noticed a typo.

    The LIMIT’s in the second example should be STOP’s as you are setting an inferior price to the current one to buy/sell at.

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

Only trade when above/below x% on previous day close?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jbyrne @jbyrne Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Vonasi
8 years, 1 month ago.

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