New to PRT and PBC, so be firm and fair…
Forums › ProRealTime English forum › ProOrder support › New to PRT and PBC, so be firm and fair…
- This topic has 44 replies, 6 voices, and was last updated 1 month ago by
NeoTrader.
-
-
05/04/2025 at 7:50 PM #246782123456789101112131415161718// === POSITION MANAGEMENT ===reverseToLong = 1reverseToShort = 1If ShortonMarket and LongSignal and reversetolong = 1 ThenExitShort at MarketEndifIf LongonMarket and ShortSignal and reversetoShort = 1 ThenSell at MarketEndif// 1. Check stop loss AND reverseIF high >= (tradeprice(1) + StopLossDistance) THEN// LONG reversalBUY PositionSize SHARES AT MARKETENDIFELSE <<< Syntax error formed after adding code...//
Ctrl + F5 < got it…
Thank you
05/04/2025 at 7:53 PM #24678305/06/2025 at 9:36 AM #246834Line 58 reads:
1ELSIF ShortSignal THENand I can’t spot any error.
1 user thanked author for this post.
05/06/2025 at 9:52 AM #246835DRAWHLINE12345// Draw stop loss line for long positionsIF LongStopLevel > 0 THENDRAWHLINE(LongStopLevel) COLOURED(0,255,0) STYLE(DOTTEDLINE, 2)ENDIFENDIFNot 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 !
NT05/06/2025 at 10:05 AM #246837This 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.
1 user thanked author for this post.
05/06/2025 at 10:07 AM #246838Hi,
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.
1 user thanked author for this post.
05/06/2025 at 10:52 AM #246839Oh, 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?05/06/2025 at 10:53 AM #24684005/06/2025 at 11:08 AM #246841In 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.
1 user thanked author for this post.
05/06/2025 at 11:36 AM #246843So, 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. …
1 user thanked author for this post.
05/06/2025 at 11:50 AM #246844For 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 :
12345678graph 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 !
1 user thanked author for this post.
05/06/2025 at 11:58 AM #246846In 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
GRAPHThere are examples of these in use, in the online Code Documentation, which I am now using….
Thank you for the heads up
05/06/2025 at 12:02 PM #246848For 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 :
12345678graph 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 !
Oh my…
That is a really useful heads up, thank you….I’ll refactor the code, and see what happens output wise 👍
05/06/2025 at 1:54 PM #246852Try 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).
1234graph 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")1 user thanked author for this post.
05/06/2025 at 3:03 PM #246853graph 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 nowand thank you GraHal, for point that out👍👍
robertogozzi, Thank you 👍👍
2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on