Last position type

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #41088 quote
    Glen Marquis
    Participant
    Average

    Hi, how do I test the last loss-position type something like…?

    If PositionPerf(1) < 0 and OnMarket[1]=1  Then

    #41092 quote
    Nicolas
    Keymaster
    Master

    Do you want to know if the last loser was a SELLSHORT or a BUY?

    #41093 quote
    Glen Marquis
    Participant
    Average

    🙂 Yes please.

    #41094 quote
    Nicolas
    Keymaster
    Master

    But only the last position? Or could it be a position far away in the orders history?

    #41095 quote
    Glen Marquis
    Participant
    Average

    Only last.

    #41585 quote
    Nicolas
    Keymaster
    Master

    In this case, why do not save in a variable the type of the order you are launching at market:

    if BuyCondition then 
     BUY 1 CONTRACT AT MARKET 
     ordertype = 1 //it's a buy order ! 
    endif 
    
    if SellCondition then 
     SELLSHORT 1 CONTRACT AT MARKET 
     ordertype = -1 //it's a sell order !! 
    endif
    #42355 quote
    Glen Marquis
    Participant
    Average

    Indeed, I thought of that, I wondered if there was another way.

    Thanks.

    #104468 quote
    Schneider
    Participant
    Average

    Hi, I want to know the same thing but I’m using a stop order.

    I this case I don’t know when the order will be triggered in and I’m placing a short and a long order at the same time.

    I’m interested to find out what order was closed. if one of the orders is closed (winner), the other order that was not triggered needs to be removed (not renewed).

     

    Thanks

    #104470 quote
    Vonasi
    Moderator
    Master

    You know what price you placed the orders at so just check to see if a high or low was above or below those prices. You may have to include a fudge factor for spread which adds some inaccuracy to the whole thing though.

    #104841 quote
    Nicolas
    Keymaster
    Master

    Little code snippet to check the profit of the last order and its direction:

    //------------------
    //check profit 
    if strategyprofit<>strategyprofit[1] then 
     if positionperf(1)>0 then 
      if close<tradeprice(2) then  
       gain=-1 //was sell
      elsif close>tradeprice(2) then 
       gain=1 //was buy
      endif
     else
      gain=0
     endif
    endif
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Last position type


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Glen Marquis @gmarquis Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by Nicolas
6 years, 6 months ago.

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