PDA

View Full Version : How can I draw a text object 3 candles to the right of the current (active) candle



NCD
07-10-2015, 10:58 AM
How can I draw a text object 3 candles to the right of the current (active) candle ?
VTL allows me to draw text object on any historical (or current) candle. It does not
allow me to draw text object when time is in the future (e.g. 3 hours in future)






' Please test this example on Hourly (H1) chart.


' Detect the current candle open time.
Dim arrTime(), currCandleTime, drawCandleTime
CopyTime 0, Bars(0), Bars(0), arrTime ' Copy latest candle time into arrTime array
currCandleTime = arrTime(1) ' Store the opening time of the current candle in currCandleTime
' Calculate candle to draw 2 candles to right of current candle. We add 2 hours (7200 seconds)
drawCandleTime = DateAdd("s", 7200, currCandleTime)


' Display the current and the future time.
MsgBox "Current Candle = " & CStr(currCandleTime) & vbcrlf & "Text Object To Draw At = " & CStr(drawCandleTime)


' Find (and delete) text object "Demo" if it exits.
If( ObjectFind(0, "Demo") >= 0 ) Then ObjectDelete 0, "Demo"
' Find high of the current candle. We draw a text at high.
Dim arrHigh()
CopyHigh 0, Bars(0), Bars(0), arrHigh


' Draw a Text object 2 candles from current candle at the high.
' BUG : It does not allow me to draw on future time (to the right of the current candle).
' It allows me to draw only in past or current time.
If( AddObject( 0, "Demo", OBJ_TEXT, 0, CStr(drawCandleTime), CDbl(arrHigh(1))) ) Then
ObjectSet 0, "Demo", OBJPROP_TEXT , "Hello"
ObjectSetText 0, "Demo", 10, "Arial", RGBColor(255, 0, 0)
Else
MsgBox "AddObject Failed."
End If

Rawan-HS
07-10-2015, 11:50 AM
Dear NCD ,

we will check it, please standby...

Hassan-HS
07-12-2015, 11:03 AM
Hello,

Unfortunately you cant do this in the current moment, but we already asked our development department to study the possibility of adding this feature to our client terminal

Thanks.