Indicators Load Order
Indicators Load Order
03 Jun 2020, 22:26
Hello
Is there a way to make a chart load indicators in a specific order? The reason I ask is because I have one indicator who load more history and I want it to go first so only after it finishes loading the data the other indicators will be load as well.
Thanks
Replies
eynt
04 Jun 2020, 09:16
RE:
Thank you
Please understand the following problem:
My chart has many indicators, and one of them calls the function LoadMoreHistory many times (on a loop until a specific data is reached). As a result, on each call of the LoadMoreHistory ALL of my indicators are refreshing and reloading themselfs again. This cause the load of the chart to last very long time, even minutes.
What do you suggest to solve this issue?
@eynt
PanagiotisCharalampous
09 Jun 2020, 09:30
Hi Yuval,
In this case you will need to find a way to communicate to the rest of the indicators that bar loading is in progress e.g. through a variable stored in a file. and do not execute the calculate method when this is the case. This will save you processing time.
Best Regards,
Panagiotis
@PanagiotisCharalampous
eynt
18 Apr 2021, 12:06
RE:
Hi
There's a problem with this approach:
Once the LoadMoreHistory (which was called by the first indicator) is finished, the secondary immediately calls the Calculate method, BEFORE the first indicator had the time to change the value in the file. Therefor, the Calculate method will not be called although it should have.
Thanks
@eynt
PanagiotisCharalampous
19 Apr 2021, 08:39
Hi Yuval,
You can monitor if a file has changed and then act accordingly. Check FileSystemWatcher.
Best Regards,
Panagiotis
@PanagiotisCharalampous
eynt
20 Apr 2021, 15:21
RE:
I've tried the following but when I change the text in one of the files in the directory but nothing happens (no prints):
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.IO;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class NewIndicator : Indicator
{
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
private FileSystemWatcher _watcher;
protected override void Initialize()
{
_watcher = new FileSystemWatcher(@"d:\temp\");
_watcher.NotifyFilter = NotifyFilters.Attributes
| NotifyFilters.CreationTime
| NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.Security
| NotifyFilters.Size;
_watcher.Changed += OnBlockFileChanged;
}
private void OnBlockFileChanged(object sender, FileSystemEventArgs e)
{
try
{
Print("OnBlockFileChanged " + e.ChangeType + " " + e.Name);
}
catch (Exception ex)
{
Print("error OnBlockFileChanged " + ex);
}
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] = ...
}
}
}
@eynt
PanagiotisCharalampous
20 Apr 2021, 15:38
Hi Yuval,
Try setting the properties below to true
_watcher.IncludeSubdirectories = true;
_watcher.EnableRaisingEvents = true;
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Apr 2021, 15:38
Hi Yuval,
Try setting the properties below to true
_watcher.IncludeSubdirectories = true;
_watcher.EnableRaisingEvents = true;
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
04 Jun 2020, 08:48
Hi Yuval,
When more history is loaded on the chart then all indicators are refreshed. So I don't think the order of loading will affect anything.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous