iCustom function has no shift?
I just noticed that iCustom function is differrent from coding in m t, it does not have shift argument, then how do I get the value of a bar other than current one of another indicator?
H iYingzhong Xu.
iCustom() function have right signature with shift argument:
double iCustom(string symbol, int timeframe, string name, ... /* custom indicator input parameters */, int lineIndex, int shift);
However, C# Indicators.iCustom() method have anorther signature and using other way.
Let as know if you have further questions.
Regards,
Serge.
Hi Serge,
Can you please provide an an example as to how the iCustom function can be used with C#.
What am I looking to do?...
I am looking to use the values from an indicator line or histogram in one chart on another indicator in another chart.
Hence I believe that the line 'index' number should be used from the source indicator.
I have attached an indicator that outputs one line and three histogram values. Hence a total of 4 index numbers (0,1,2 and 3).
Can you please provide an an example with this indicator where the output/value of index 1 (a histogram) can be used in an indicator on another chart.
I have attached the reference indicator cs file,asl and dll file.
.cs file - https://www.dropbox.com/s/7g4df1faee8af9s/msc.cs?d...
.asl file - https://www.dropbox.com/s/4x2jji0rtowttrq/msc.asl?...
.dll file - https://www.dropbox.com/s/ozq14e1fnvm0v7q/msc.dll?...
Cheers
PS - is there a way to chare files/code on the forum other than to provide external links in this case I used dropbox.
I reckon that the Algostudio coding capability is the same on both PTMC and PT3.
The attached indicator is for use in PT3.
Hi Serge,
Can you please provide an an example as to how the iCustom function can be used with C#.
What am I looking to do?...
I am looking to use the values from an indicator line or histogram in one chart on another indicator in another chart.
Hence I believe that the line 'index' number should be used from the source indicator.
I have attached an indicator that outputs one line and three histogram values. Hence a total of 4 index numbers (0,1,2 and 3).
Can you please provide an an example with this indicator where the output/value of index 1 (a histogram) can be used in an indicator on another chart.
I have attached the reference indicator cs ,asl and dll file.
.cs file - https://www.dropbox.com/s/7g4df1faee8af9s/msc.cs?d...
.asl file - https://www.dropbox.com/s/4x2jji0rtowttrq/msc.asl?...
.dll file - https://www.dropbox.com/s/ozq14e1fnvm0v7q/msc.dll?...
Cheers
PS - is there a way to chare files/code on the forum other than to provide external links in this case I used dropbox.
I reckon that the Algostudio coding capability is the same on both PTMC and PT3.
The attached indicator is for use in PT3.
Hi ssk1284u.
Please look at following code example:
(Some code are skipped).
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using PTLRuntime.NETScript;
using PTLRuntime.NETScript.Indicators;
namespace GetMsc
{
public class GetMsc : NETIndicator
{
private Indicator msc;
public override void Init()
{
msc = Indicators.iCustom("msc", CurrentData);
}
public override void OnQuote()
{
// double msc = msc.GetValue(int lineIndex, shift));
double msc0 = msc.GetValue(0, 0)); // get data from first line, last value
double msc1 = msc.GetValue(1, 0)); // get data from second line, last value
...........
}
Lendich Serge
Hi Serge,
Thanks for getting back to me. I did implement what you had asked , however I still do have some more questions -
1) when one uses iCustom for c# does it actually copy the data/line index value from another running instance of the indicator?
or
does it run an instance of the indicator in the background anyway?
I have asked this because even if I insert the indicator that uses icustom without the reference indicator - it still shows values!
Which i believe is not supposed to be the case since the reference indicator is not running.
Please do clarify.
2) even when i do have a reference indicator....The values i get on the indicator that uses the icustom method is never exact.
The values are such that the icustom function derived lines are cumulative when compared to the reference indicator lines.
example - consider the following 5 independent histogram values per 1min candle on the reference indicator.
1,-2, 4, 5, 7
instead of showing the above values the icustom derived values shows the following-
1,-1,3,8,15 (i.e. the values are cumulative)
I have included an example screen shot.
Any possible reason as to why this is happening? I have tried referencing different indicator index values however the results are always the same.
Am i misunderstanding something with regards to how iCustom functions or is there some kind of a bug?
Thanks in advance.
Below are the indicator files that have been used -
Indicator that uses the icustom method, named datapulltest -
cs file - https://www.dropbox.com/s/jian4ism39ogl6g/datapull...
aslfile - https://www.dropbox.com/s/jian4ism39ogl6g/datapull...
dll file - https://www.dropbox.com/s/hgxmieorke5d5lw/datapull...
reference indicator,named VWAPpANDn -
Note - I am trying to reference the index line '4' value .
cs file - https://www.dropbox.com/s/x4c23x1a86xjmf5/VWAPpAND...
asl file - https://www.dropbox.com/s/unaxfsg28zz27si/VWAPpAND...
dll file - https://www.dropbox.com/s/x4c23x1a86xjmf5/VWAPpAND...
Lendich Serge
Hi Serge,
Sorry for not uploading the .cs file.
here is the link for the .cs file for VWAPpANDn -
https://www.dropbox.com/s/cbdggkaf9nf4yzm/VWAPpAND...
Cheers
Hi Serge,
I had one more related query too. Will I be able to access the index(line) values of the same indicator (which is an indicator that i coded not a stock indicator) running on different charts?
I understand the syntax required to obtain values from an indicator on the same chart is as follows -> double msc = msc.GetValue(int lineIndex, shift);
Which does require the user to specify an index line and candle offset.
I would like to know the syntax for getting index(line) values from a specific chart or charts (multiple instances of the running indicator)
Explained Example -
Lets us call the indicator of interest to be 'reference indicator'. And my objective is to obtain data/value of index(line) 1 from each instance of the 'reference indicator'.
One instance of 'reference indicator' is loaded onto EURUSD.
Second instance of the 'reference indicator' is loaded onto GBPUSD.
I have now loaded another indicator that uses the 'iCustom' function onto a third chart . Let us call this indicator 'iCustom indicator'. The 'iCustom indicator' will obtain the value of index(line) 1 from each instance of the 'reference indicator'.
So i load the 'iCustom indicator' onto a third chart and it should be able to pull the values of index(line) 1 from both the instances of the 'reference indicator' running on EURUSD and GBPUSD.
What is the syntax needed to accomplish this ? Is this possible?
Cheers
Hi ssk1284u.
For getting indicators data from any chart you may use following code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using PTLRuntime.NETScript;
using PTLRuntime.NETScript.Indicators;
namespace HistoryLoad
{
public class HistoryLoad : NETStrategy
{
private Indicator ind;
public override void Init()
{
Instrument inst = Instruments.GetInstrument("GBP/USD");
HistoricalData Hist = GetHistoricalData(new HistoricalDataRequest(inst, Period.Min));
DateTime fromDate = DateTime.UtcNow.AddDays(-20);
Hist.BeginLoad(fromDate);
ind = Indicators.iCustom("MyIndicator", Hist);
}
public override void OnQuote()
{
double val = ind.GetValue(int lineIndex, int shift);
}
}
}