how to report the entry type

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #261934 quote
    oliTR
    Participant
    Average

    Hello,

    my code gets AT MARKET and AT LIMIT entry orders: how to report (could be using print) the amount of each in a backtest?

    is there a special command which directly states the entry type? (and similarly for the exits)

    thank you

    #261954 quote
    robertogozzi
    Moderator
    Master

    I moved your topic from the French forum to the English forum, as you used the English language. Please stick to the correct language or to the correcty forum. Thanks 🙂

    The PRT language only reports if either a LONG or a SHORT trade has been triggered, so you have to code it yourself.

    Luckily this is not too difficult.

    1. You have to set a variable in one of the initial lines (after any DEFPARAM… you may be using);
    2. let’s name it TradeType, assigning it 1 when it’s a trade opened AT MARKET or, say, 2 if it was a PENDING order;
    3. use IF..ENDIF to detect which type it was and process it before that variable is cleared for future trades;
    4. clear the variable, setting it to 0 (zero);
    5. set the variable to 1 or 2 whenever you open a trade AT MARKET or place a PENDING order.

    This is a sample code:

    ONCE TradeType    = 0   // used to tell a type from another
    ONCE PendingCount = 0   // used to tally pending trades (stop or limit)
    ONCE MarketCount  = 0   // used to tally market orders
    // --- detect the type of trade entered
    IF TradeType = 1 THEN
    MarketCount = MarketCount + 1
    ELSIF TradeType = 2 THEN
    IF LongTriggered OR ShortTriggered THEN
    PendingCount = PendingCount + 1
    ENDIF
    ENDIF
    TradeType = 0  // clear it before a new market trade is entered or a pending order is placed
    //
    myLongMarketConditions   = close CROSSES OVER  average[21,0](close)
    myShortMarketConditions  = close CROSSES UNDER average[21,0](close)
    myLongPendingConditions  = Rsi[14] CROSSES OVER  50
    myShortPendingConditions = Rsi[14] CROSSES UNDER 50
    //
    IF myLongMarketConditions AND Not OnMarket THEN
    BUY 1 CONTRACT AT MARKET
    TradeType = 1              // it's a market order
    SET STOP   pLOSS   50
    SET TARGET pPROFIT 200
    ELSIF myShortMarketConditions AND Not OnMarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
    TradeType = 2
    SET STOP   pLOSS   50
    SET TARGET pPROFIT 200
    TradeType = 1              // it's a market order
    ELSIF myLongPendingConditions AND Not OnMarket THEN
    myLongPrice = high * 1.01  // enter at high + 1%
    BUY 1 CONTRACT AT myLongPrice STOP
    TradeType = 2              // it's a pending order
    SET STOP   pLOSS   50
    SET TARGET pPROFIT 200
    ELSIF myShortPendingConditions AND Not OnMarket THEN
    myShortPrice = low * 0.99   // enter at low - 1%
    SELLSHORT 1 CONTRACT AT myShortPrice STOP
    TradeType = 2              // it's a pending order
    SET STOP   pLOSS   50
    SET TARGET pPROFIT 200
    ENDIF
    //
    graph PendingCount AS "Pending Orders" coloured("Cyan")
    graph MarketCount  AS "MarketOrders"   coloured("Fuchsia")
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

how to report the entry type


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
oliTR @olitr Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
4 days, 16 hours ago.

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