New to PRT and PBC, so be firm and fair…

Viewing 15 posts - 31 through 45 (of 45 total)
  • Author
    Posts
  • #246782 quote
    NeoTrader
    Participant
    New
    // === POSITION MANAGEMENT ===
    reverseToLong  = 1
    reverseToShort = 1
    If ShortonMarket and LongSignal and reversetolong = 1 Then
    ExitShort at Market
    Endif
    
    If LongonMarket and ShortSignal and reversetoShort = 1 Then
    Sell at Market
    Endif
    
    // 1. Check stop loss AND reverse
    IF high >= (tradeprice(1) + StopLossDistance) THEN
    // LONG  reversal
    BUY PositionSize SHARES AT MARKET
    ENDIF
    ELSE <<< Syntax error formed after adding code...
    //

    Ctrl + F5 < got it…

    Thank you

    #246783 quote
    NeoTrader
    Participant
    New

    Hi,
    Got to be honest, I am a little confused on this one…

    The code has syntax errors, line 58 ELSE
    So, I am not sure what to do with the code ?

    Can you help please…

    NT

    #246834 quote
    robertogozzi
    Moderator
    Master

    Line 58 reads:

    ELSIF ShortSignal THEN

    and I can’t spot any error.

    NeoTrader thanked this post
    #246835 quote
    NeoTrader
    Participant
    New

     

    // Draw stop loss line for long positions
    IF LongStopLevel > 0 THEN
    DRAWHLINE(LongStopLevel) COLOURED(0,255,0) STYLE(DOTTEDLINE, 2)
    ENDIF
    ENDIF
    

    Not sure why, but the indents are not showing on the code insert (Ctrl + F5)
    File attached also.

    I have syntax errors that I cannot currently solve.
    DRAWHLINE using IF statements !

    Attached is the full code, for your perusal.

    I have reviewed the glossary, examples online also, but to no avail, so any guidance is very much appreciated.

    Any guidance is much appreciated !
    NT

    BT-DMI-testV3.0.0.txt
    #246837 quote
    GraHal
    Participant
    Master

    This is a Strategy / Algo under discussion in this Topic.

    Drawing objects (Drawline etc as you post above) is not allowed in ProOrder / Strategies / Algos (hence why you are seeing errors).

    Instructions to Draw Objects are allowed in Indicators (but not Algos).

    Try this one (I am also attaching the ITF file):

    Re Roberto code provided on the link above … I can confirm that there are no syntax errors when the code is run on PRT Platform.

    NeoTrader thanked this post
    #246838 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    Don’t worry about the indents in inserted PRT codes, they are not added automatically. If maybe you came accross some indents previously in someone’s inserted codes, that would be because the author took the time to add some spaces manually to make the code more pleasant to read in the forum.

    NeoTrader thanked this post
    #246839 quote
    NeoTrader
    Participant
    New

    Oh, GraHal,
    So, I have to create an indicator (custom) with the DRAW code, to show the stop loss levels in use (and apply that to the chart used in the backtest).
    and
    I am not to code any drawing code in the backtest Algo code…
    Is that correct?

    #246840 quote
    NeoTrader
    Participant
    New

    JC_Bywan, thank you, for the pointer, much appreciated.

    NT

    #246841 quote
    druby
    Participant
    New

    In a back-test file the only draw options are GRAPH, GRAPHONPRICE also the addition of PRINT to display a table.

    Regarding the GRAPH commands, I think the only additional modifier that can be used is COLOURED(r,g,b,a)  and AS”label”.

    Also PRINT is limited to the last 200 entries, if I recall right.

    NeoTrader thanked this post
    #246843 quote
    PeterSt
    Participant
    Master

    So, I have to create an indicator (custom) with the DRAW code, to show the stop loss levels in use (and apply that to the chart used in the backtest).

    Nah … you can use GraphOnPrice for that. It is only that this works with (forward) Backtesting. So a Live strategy won’t show GraphOnPrice (or Graph or Print for that matter). Those commands or not allowed to be active in the code when put to Live (or Demo).
    Confused ? I hope not. But you really don’t need Indicators to see what you’re doing.

    With GarphOnPrice you would “draw” on vertical positions around Close. That can thus also be Close + LimitPrice. Etc. …

    NeoTrader thanked this post
    #246844 quote
    PeterSt
    Participant
    Master

    For your inspiration.
    The graphing in the middle pane is from GraphOnPrice.
    What you see in the bottom pane is from Graph.

    A few examples in code :

    graph 6000 Coloured("Blue") as "Limit adjusted3"
    graphOnPrice VirtualLimit Coloured("Turquoise", BacktestColorAlpha) as "New Exit Limit S"
    graphOnPrice VirtualStop Coloured("White") as "Virtual Stop"   // 03-03-2025,PS.
                      
    // 20-02-2025,PS, Just notice : The below line would show the *changed* trailing, also visible on the price chart via "New Limit".
    // Keep in mind that this Trailing follows the price, thus Up as well as Down.
                        
    graph VirtualLimitBarCount * 100 Coloured("Green") As "VirtualLimitBarCount S * 100"
    

    Have fun !

    NeoTrader thanked this post
    image_2025-05-06_124457386.jpg image_2025-05-06_124457386.jpg
    #246846 quote
    NeoTrader
    Participant
    New

    In a back-test file the only draw options are GRAPH, GRAPHONPRICE also the addition of PRINT to display a table.

    Regarding the GRAPH commands, I think the only additional modifier that can be used is COLOURED(r,g,b,a) and AS”label”.

    Also PRINT is limited to the last 200 entries, if I recall right.

    Dam, the code online glossary A-Z is missing….
    GRAPHONPRICE
    GRAPH

    There are examples of these in use, in the online Code Documentation, which I am now using….

    Thank you for the heads up

    #246848 quote
    NeoTrader
    Participant
    New

    For your inspiration.

    The graphing in the middle pane is from GraphOnPrice.

    What you see in the bottom pane is from Graph.

    A few examples in code :

    Have fun !

    Oh my…
    That is a really useful heads up, thank you….

    I’ll refactor the code, and see what happens output wise 👍

    #246852 quote
    GraHal
    Participant
    Master

    Try this one (I am also attaching the ITF file):

    Neo, in case you never noticed … Roberto provided GRAPH commands (click on text ‘Roberto wrote’ to link to the code).

    graph myDIplus  CROSSES OVER myDIminus        AS "LongSignal"   coloured("Green")
    graph myDIminus CROSSES OVER myDIplus         AS  "ShortSignal" coloured("Red")
    graphonprice TradePrice(1) - StopLossDistance AS "LONG sl"      coloured("Red")
    graphonprice TradePrice(1) + StopLossDistance AS "SHORT sl"     coloured("Blue")
    NeoTrader thanked this post
    #246853 quote
    NeoTrader
    Participant
    New

    graph myDIplus CROSSES OVER myDIminus AS “LongSignal” coloured(“Green”) graph myDIminus CROSSES OVER myDIplus AS “ShortSignal” coloured(“Red”) graphonprice TradePrice(1) – StopLossDistance AS “LONG sl” coloured(“Red”) graphonprice TradePrice(1) + StopLossDistance AS “SHORT sl” coloured(“Blue”)

    What the… how did I miss that…. that is great…
    I have not seen an example like that, well, I have now

    and thank you GraHal, for point that out👍👍

    robertogozzi, Thank you 👍👍

    GraHal and robertogozzi thanked this post
Viewing 15 posts - 31 through 45 (of 45 total)
  • You must be logged in to reply to this topic.

New to PRT and PBC, so be firm and fair…


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
NeoTrader @neotrader Participant
Summary

This topic contains 44 replies,
has 6 voices, and was last updated by NeoTrader
9 months, 2 weeks ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/01/2025
Status: Active
Attachments: 9 files
Logo Logo
Loading...