How to add text
Forums › ProRealTime English forum › ProBuilder support › How to add text
- This topic has 8 replies, 4 voices, and was last updated 1 year ago by PeterSt.
-
-
06/05/2023 at 10:32 PM #215679
Hi, I’d like to insert some text above a below the current candle (according to certain conditions). The DRAWTEXT method (https://www.prorealcode.com/<wbr />documentation/drawtext/) doesn’t seem to work. Can someone explain where’s the error in the below code ?
123456789ONCE bStart = 0Voffset = 5 * pipsizehd = 154500hf = 193000IF (Time >= hd AND Time <= hf AND bStart = 0)DRAWTEXT("START ALGO", barindex, Low[1] - Voffset, SansSerif, Standard, 16) COLOURED(153,153,0)bStart = 1ENDIFAnd btw, it’d be nice to get more insight about syntax error, a hint when mousing over the warning symbol for instance…
Thanks
Fred
PS : sorry I didn’t keep the source code, just a screen shot (attached) and tried to reproduce something meaningful above
06/05/2023 at 11:50 PM #215683Line 1 cannot be used in indicators, it’s reserved for strategies (indicators don’t deal with orderes).
Line 2 will make ALL graphic objects and text being cancelled and being drawn again each new candle, so once bStart is set, the IF conditions will no more be met, thus DrawText will never be executed again, unless you clear bStart somewhere, and you wll no more seee the text that was previously printed.
Any line starting with IF must end with THEN (this concerns the code you posted, not the one in the attached pic).
06/06/2023 at 12:01 AM #21568406/06/2023 at 12:07 AM #215686This is the correct code for ProRealTime:
123456789ONCE bStart = 0Voffset = 5 * pipsizehd = 154500hf = 193000IF (Time >= hd AND Time <= hf AND bStart = 0) THENDRAWTEXT("START ALGO", barindex, Low[1] - Voffset, SansSerif, Standard, 16) COLOURED(153,153,0)//bStart = 1ENDIFRETURNall indicators must end with the keyword RETURN.
06/06/2023 at 12:20 AM #215687I guess the DRAWTEXT function doesn’t work in TradingSystem coding environment (see the little warning icon indicating a syntax / compile error on the screenshot ?).
Of course, if I put it in an indicator code, everything works fine (no warning icon).
1234567891011121314151617181920212223242526// Variables contenant le prix d'achat ou de vente (en cas de signal)buyLevel = -1sellLevel = -1// Signal LONG lors d'une rupture de tendance descendante par les valeurs max// On dessine la flèche de signal, le prix d'achat, le take profit (tp) et le stop loss (sl)IF Low[1] < Low[2] AND High[1] < High[2] AND High > High[1] THENbuyLevel = High[1] + (dist + spread) * PointSizeDRAWARROWUP(BarIndex, Low - 2) COLOURED(0,255,0)DRAWSEGMENT(BarIndex, buyLevel, BarIndex + 1, buyLevel) COLOURED("Blue") STYLE(LINE,2)DRAWSEGMENT(BarIndex, buyLevel + tp, BarIndex + 1, buyLevel + tp) COLOURED("MediumBlue") STYLE(DOTTEDLINE,2)DRAWSEGMENT(BarIndex, buyLevel - sl, BarIndex + 1, buyLevel - sl) COLOURED("Crimson") STYLE(DOTTEDLINE,2)ENDIF// Signal SHORT lors d'une rupture de tendance ascendante par les valeurs minIF Low[1] > Low[2] AND High[1] > High[2] AND Low < Low[1] THENsellLevel = Low[1] - (dist + spread) * PointSizeDRAWARROWDOWN(BarIndex, High + 2) COLOURED(255,0,0)DRAWSEGMENT(BarIndex, sellLevel, BarIndex + 1, sellLevel) COLOURED("Blue") STYLE(LINE,2)DRAWSEGMENT(BarIndex, sellLevel - tp, BarIndex + 1, sellLevel - tp) COLOURED("MediumBlue") STYLE(DOTTEDLINE,2)DRAWSEGMENT(BarIndex, sellLevel + sl, BarIndex + 1, sellLevel + sl) COLOURED("Crimson") STYLE(DOTTEDLINE,2)ENDIFDRAWTEXT("START ALGO", barindex, Low[1] - Voffset, SansSerif, Standard, 16) COLOURED(153,153,0)RETURN buyLevel, sellLevelBut this is neither what I want nor what I was trying to explain.
Thanks for your help anyway
06/06/2023 at 12:35 AM #215689Trading systems cannot plot text, or objects. They can only enter and exit trades.
06/06/2023 at 12:51 AM #215690Of course, if I put it in an indicator code, everything works fine (no warning icon).
Hi Fred,
The answer to your “line 13” question is : All of these commands only apply to Indicator code (which end with the Return command).
The screenshot is from a tradingsystem code.
In brief, that only allows for Graph and GraphOnPrice. Nothing of the graphical “nice stuff” works in that part of the platform.
It is a bit confusing, but you will get used to it.Peter
06/06/2023 at 10:30 AM #21570106/06/2023 at 11:40 AM #215706… with the notice that this now also works with Indicators (assuming that “trading systems” was meant to say just that). I did not really use/test it for Indicators yet but for trading systems it is great.
But maybe mentioned too early (after all 😉 ) because it is only for V12. At least for me it’s not there in V11.1.
-
AuthorPosts