IF decisions using the order gain

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #95468 quote
    Alun
    Participant
    Average

    How do I use the gain on an order in an IF decision?

    #95469 quote
    Nicolas
    Keymaster
    Master

    POSITIONPERF 

    The instruction POSITIONPERF(n) returns: The performance (ratio gain/cost of the position)

    So in order to use it in a condition you can do:

    if positionperf(0) > 0 then 
     //we are in gain!!
    endif
    #95561 quote
    Alun
    Participant
    Average

    Hi thank you for your reply.

    When I have tried this it does not seem to work. I would like to exit greater than a gain value. Is this possible?

    #95562 quote
    Vonasi
    Moderator
    Master

    Alun– please do not double post. It just leads to wasted time and effort for those trying to help you if you post the same question in two places. I have deleted your other topic with an identical question.

    #95580 quote
    Vonasi
    Moderator
    Master

    You can do something like this:

    takeprofit = 1000
    
    if longonmarket and (close - positionprice) * countofposition > takeprofit then
    sell at market
    endif
    
    if shortonmarket and (positionprice - close) * (0 - countofposition) > takeprofit then
    exitshort at market
    endif

    which will check at the bar close if you are in the desired profit or alternatively just use:

    set target $profit 1000

    which places an order on the market to sell when up $1000 or whatever currency the instrument is in.

    #95584 quote
    GraHal
    Participant
    Master

    When I have tried this it does not seem to work. I would like to exit greater than a gain value. Is this possible?

    Yes just set your gain value as a percentage, for example …

    if positionperf(0) > 0.1 then  //gain > 0.1%
    Sell at Market
    endif
    
    #95588 quote
    Alun
    Participant
    Average

    Will do! Apologies, very new to this.

    #95589 quote
    Alun
    Participant
    Average

    Vonasi, this seems to be exactly what I was looking for. Thanks

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

IF decisions using the order gain


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Alun @alun Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by Alun
6 years, 11 months ago.

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