PDA

View Full Version : Updating values of a Custom Indicator



novice
02-21-2014, 01:12 PM
hello,

I need help in updating the values of a custom indicator
I'am able to add the custom indicator but the values do not get updated on new ticks or when new bar is formed
please help resolve this
thanks

let us take a dummy example as below:


Public Sub main()

dim closearray(), indkey, barcount

copyclose 0,1,bars(0),closearray
indkey = AddCustomIndicator( 0, closearray,1,False)

End Sub

Hassan-HS
02-21-2014, 04:22 PM
Dear Sir,,,


You have to use SetIndicatorData (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2663) method.


check this sample..





Dim indKey

Dim vchartId

Dim vchartName

Dim resultValue

Public Sub Main()

Dim highArry()

vchartId=chartId

vchartName=ChartSymbol(Clng(vchartId))

CopyHigh 0,1, bars(0),highArry

indKey=AddCustomIndicator(0, highArry,0)

End Sub

Public Sub OnTick(SymbolName)

ObjectSeriesGetValue 0,cstr(vchartName & ".close"),CLNG(bars(CLNG(vchartId))),resultValue

ObjectSeriesSetValue 0,CSTR(indKey),CLNG(bars(CLNG(vchartId))),CDBL(res ultValue)

End Sub

Public Sub OnCalculate(symbol ,symPeriod, openVal , highVal , lowVal , closeVal )

SetIndicatorData 0,CSTR(indKey),CDbl(highVal)

End Sub

novice
02-21-2014, 07:49 PM
Dear Hassan,
thanks for your code. it is changing the values. but the values are not getting updated correctly. can you check and confirm at your end if correct values are getting updated. thanks

Hassan-HS
02-21-2014, 07:55 PM
Dear...


Can you explain more

novice
02-22-2014, 11:10 AM
sure, let me try to elaborate.

when I add indicator it draws perfectly with the correct close values of each and every candle/bar.

problem happens on two conditions :

1. when new ticks come : value of indicator line doesn't change (you can check in data window)

2. when new candle is formed : the previous bar's close value and previous bar's indicator value do not match with each other. (you can check in data window)

hope you understand the issue now

right now the markets are close otherwise I could have attached a scrrenshot.

Hassan-HS
02-22-2014, 03:45 PM
Dear,

I cant trace this issue while the market is closed, I will update you soon please stand by.

Can you send me your script that programmed by you?

Hassan-HS
02-23-2014, 03:21 PM
Dear Sir,



Please check this sample which is draw the high values for each bar over the current chart and its updating its value according to the new ticks and i confirm that all method run properly.





Dim indKey

Dim vchartId

Dim vchartName

Dim resultValue

Public Sub main ()

Dim highArry()

vchartId=chartId

vchartName=ChartSymbol(Clng(vchartId))

CopyHigh 0,1, bars(CLNG(vchartId)),highArry

indKey=AddCustomIndicator(0, highArry,1,False)

End Sub

Public Sub OnTick(SymbolName)

ObjectSeriesGetValue 0,cstr(vchartName & ".High"),CLNG(bars(0)),resultValue
MsgBox resultValue
ObjectSeriesSetValue 0,CSTR(indKey),CLNG(bars(0)),CDBL(resultValue)

End Sub

Public Sub OnCalculate(symbol ,symPeriod, openVal , highVal , lowVal , closeVal )

SetIndicatorData 0,CSTR(indKey),CDbl(highVal)

End Sub

novice
02-24-2014, 11:32 AM
dear Hassan,

your recent code is working correctly, thanks