Help converting some EasyLanguage

Questions about MultiCharts and user contributed studies.
sgjohnson1981
Posts: 29
Joined: 05 May 2021

Help converting some EasyLanguage

Postby sgjohnson1981 » 16 Apr 2022

Would like to use this in MC. Got it from the TS community forum. It drew rectangles around the same period (and from high to low) every day and placed a text label on the box that indicated high/low/etc. for that period. I just modified it to show me the day of week of the period. I can't even seem to find help for the "method" keyword. Nothing but a link to the EasyLanguage SDK. Not sure what that has to do with that keyword. All I've done so far is remove the "using" statements. Thanks.

Code: Select all

inputs: PeriodStartTime( 0930 ), PeriodEndTime( 1600 ), Transparency_0_100( 20) ; vars: double SessionHigh( 0 ), double SessionLow( 0 ), intrabarpersist double PriorSessionHigh( 0 ), intrabarpersist double PriorSessionLow( 0 ), intrabarpersist bool FirstTick( false ), OkToDraw( true ), DateTime SessionStartBar( NULL ), DTPoint TextDTPoint( NULL ), Rectangle MyRectangle( NULL ), TextLabel MyTextLabel( NULL ), int FillTrans( Transparency_0_100 * 2.55 ), DayofWeekString("") ; method void DrawRectangle( ) variables: DTPoint MyStartDT, DTPoint MyEndDT ; begin MyStartDT = DTPoint.Create( SessionStartBar, SessionLow ) ; MyEndDT = DTPoint.Create( BarDateTime, SessionHigh ) ; MyRectangle = Rectangle.Create( MyStartDT, MyEndDT ) ; { create the rectangle } MyRectangle.Persist = true ; MyRectangle.FillColor = Color.FromArgb( FillTrans, 128,128,128 ) ; //MyRectangle.Color = Color.Yellow ; MyRectangle.Color = Color.FromArgb( FillTrans, 255,255,255 ) ; DrawingObjects.Add( MyRectangle ) ; end ; method void UpdateRectangle () variables: DTPoint MyStartDT, DTPoint MyEndDT ; begin MyStartDT = DTPoint.Create( SessionStartBar, SessionLow ) ; MyEndDT = DTPoint.Create( BarDateTime, SessionHigh ) ; MyRectangle.SetEndPoint( MyEndDT ) ; MyRectangle.SetStartPoint( MyStartDT ) ; end ; method void CreateText() begin if Dayofweek(Date) = 1 then DayofWeekString = "Mon" else if Dayofweek(Date) = 2 then DayofWeekString = "Tue" else if Dayofweek(Date) = 3 then DayofWeekString = "Wed" else if Dayofweek(Date) = 4 then DayofWeekString = "Thu" else if Dayofweek(Date) = 5 then DayofWeekString = "Fri" else DayofWeekString = "error"; TextDTPoint = MyRectangle.EndPoint astype DTPoint ; MyTextLabel = TextLabel.Create( TextDTPoint, DayofWeekString ) ; MyTextLabel.Color = Color.Aquamarine; MyTextLabel.Persist = false ; MyTextLabel.HStyle = HorizontalStyle.right ; MyTextLabel.VStyle = VerticalStyle.Bottom; DrawingObjects.Add( MyTextLabel ) ; end ; method void UpdateText() begin if Dayofweek(Date) = 1 then DayofWeekString = "Mon" else if Dayofweek(Date) = 2 then DayofWeekString = "Tue" else if Dayofweek(Date) = 3 then DayofWeekString = "Wed" else if Dayofweek(Date) = 4 then DayofWeekString = "Thu" else if Dayofweek(Date) = 5 then DayofWeekString = "Fri" else DayofWeekString = "error"; TextDTPoint = MyRectangle.EndPoint astype DTPoint ; MyTextLabel.TextString = DayofWeekString ; MyTextLabel.PointValue = TextDTPoint ; end ; if Time[1] < PeriodStartTime and Time >= PeriodStartTime then begin SessionHigh = High ; SessionLow = Low ; SessionStartBar = BarDateTime ; if OkToDraw then begin DrawRectangle( ) ; CreateText() ; end ; OkToDraw = false ; end else if (( PeriodStartTime < PeriodEndTime ) and ( Time > PeriodStartTime and Time <= PeriodEndTime ) ) or (( PeriodStartTime > PeriodEndTime ) and ( Time > PeriodStartTime or Time <= PeriodEndTime )) then begin SessionHigh = MaxList( High, SessionHigh ) ; SessionLow = MinList( Low, SessionLow ) ; OkToDraw = true ; end ; if MyRectangle <> NULL and ((( PeriodStartTime < PeriodEndTime ) and ( Time > PeriodStartTime and Time <= PeriodEndTime ) ) or (( PeriodStartTime > PeriodEndTime ) and ( Time > PeriodStartTime or Time <= PeriodEndTime ))) then begin if PriorSessionHigh <> SessionHigh or PriorSessionLow = SessionLow or FirstTick then begin UpdateRectangle() ; UpdateText() ; end ; end ; PriorSessionHigh = SessionHigh ; PriorSessionLow = SessionLow ; FirstTick = BarStatus( 1 ) = 2 ;
boxes.PNG
(45.04 KiB) Not downloaded yet

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Help converting some EasyLanguage

Postby TJ » 16 Apr 2022

This is not EasyLanguage.
This is TS' new OOP Language with some Easylanguage syntax.
It is not possible to do a translation. At least not an easy direct translation.

sgjohnson1981
Posts: 29
Joined: 05 May 2021

Re: Help converting some EasyLanguage

Postby sgjohnson1981 » 16 Apr 2022

Maybe someone will come along willing to do a difficult direct translation. Until then I suppose I can manually draw. Rectangles seem to stay when you change the chart interval. Any idea why text labels don't? (Sometimes they do, sometimes not.)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Help converting some EasyLanguage

Postby TJ » 17 Apr 2022

Rectangles seem to stay when you change the chart interval. Any idea why text labels don't? (Sometimes they do, sometimes not.)
Computers are dumb. They do what they are told.


Return to “MultiCharts”