Thanks TJ.
I thought I knew how to get an array work for me, but I don't know a way of getting a particular value out of the array (for example value of 6 days back).
I use this code for the array (in the strategy code of the 1 minute resolution)
I fetch the daily macd values of another daily chart (other workspace) with ADE.
Code: Select all
Arrays:
// macd ade values
IntrabarPersist macd_day_array[](0), // macd values
IntrabarPersist macd_day_avg_array[](0), // macd trigger line (avg)
IntrabarPersist macd_day_diff_array[](0); // difference between macd value / trigger line
If Currentbar = 1 and Usefile then
Value27 = ADE.OpenMap(Class_MACD, "MACD", Interval_daily);
// Retrieve the data for this symbol and bar interval.
// ADE.GetBarInfo will copy the information from the appropriate DataMap into our InfoMap.
value27 = ADE.GetBarInfo(Class_MACD, "MACD", Interval_daily, ADE.BarID, MACD_Daily_map);
If date > date[1] then begin
// fetch the values from the "_" Map into variables
Macd_day_ade = MapSN.Get(MACD_Daily_map, "MACD Daily");
Macd_avg_day_ade = MapSN.Get(MACD_Daily_map, "MACD Daily Avg");
Macd_diff_day_ade = MapSN.Get(MACD_Daily_map, "MACD Daily Diff");
// increment the count at the beginning of a new day
Macd_count = macd_count + 1;
// expand the array by one
Array_setmaxindex(macd_day_array, macd_count);
Array_setmaxindex(macd_day_avg_array, macd_count);
Array_setmaxindex(macd_day_diff_array, macd_count);
// post data to array
Macd_day_array[macd_count] = Macd_day_ade;
Macd_day_avg_array[macd_count] = Macd_avg_day_ade;
Macd_day_diff_array[macd_count] = Macd_diff_day_ade;
end;
How to get the value of 2 days ago? Tried something like this:
macd_2daysback = macd_day_array[2];
but that gives an error about using the wrong index.
So as an workaround I now changed the code in the ADE sender code and send the value[1] and value[2] from the daily chart to the minute chart. But I still like to know how to get the value for example 50 days back out of an array. So I don't have to code value1 to value 50 and wright it all out.
edit: never mind, I found the way to get the value of 50 days back or any other day:
Macd_2daysback = macd_day_array[macd_count] [50];