How to exit in the next period if at profit target

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6850 quote
    Dave Charles
    Participant
    New

    Hi,

    I am wanting to create a code so that the profit target must be reach in the next period.

    I am having problems with the backtesting showing that a trade was successful because the trigger bar was long enough that the profit target was within the trigger bar, even though the market didn’t trade there after the order was triggered.

     

    Thanks! I really appreciate it!

    Here is the code I have currently..

    
    
    if not shortonmarket then
    sellshort 15 share at shortLevel limit
    endif
    if not longonmarket then
    buy 15 share at longLevel limit
    endif
    set stop ploss stoploss
    set target pPROFIT profi
    endif
    #6852 quote
    Dave Charles
    Participant
    New

    sorry I think there was a problem with the code… Just to be sure

    if not shortonmarket then
    sellshort 15 share at shortLevel limit
    endif
    if not longonmarket then
    buy 15 share at longLevel limit
    endif
    set target pPROFIT profi
    set stop ploss stoploss
    endif
    #6885 quote
    Nicolas
    Keymaster
    Master

    It’s a common “problem” with the tester. Because each conditions are only tested once per bar, the tester don’t have any idea of when the price has reach your short or long levels limit. And if your stoploss and takeprofit prices were include in the same bar, tester consider the takeprofit firstly.

    Also, when you use pPROFIT ou pLOSS you are defining point values, like 15 points for 0.0015 pips for forex pairs for example.

    #7145 quote
    Dave Charles
    Participant
    New

    Awesome thanks Nicholas for your help.

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

How to exit in the next period if at profit target


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Dave Charles
9 years, 9 months ago.

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