Pointer and Records Expand / Collapse
Author
Message
Posted 7/30/2010 10:50:15 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 10/16/2010 1:10:00 PM
Posts: 7, Visits: 29
Hi,

i want to use a record to combine some values in a nice data structure.
As i've seen the editor is aware of the keyword "record" but I wasn't able to create a record.
I have tried the common ways which are known in Delphi an Pascal.


How can I write a Function which takes a Pointer as argument?
I have seen, that the AddCandleHistorySetting function takes pointer as arguments but how is the
right code to build an own function like that?

Best regards

Jeremia
Post #1824
Posted 8/9/2010 5:13:55 AM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 1/27/2012 12:53:25 PM
Posts: 201, Visits: 295
Hi, Jeremia!
What do you mean in “pointer as arguments”?
AddCandleHistorySetting used that settings what have been written in

procedure OnCreate;
begin
AddFloatSetting(@FS, 'Float Setting', 1.45);
AddIntegerSetting(@IntS, 'Integer Setting', 45);
AddStringSetting(@SS, 'String Setting', 'a123');
end;

What function exactly do you want to write?


Best regards!
Post #1842
Posted 8/16/2010 12:53:53 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 10/16/2010 1:10:00 PM
Posts: 7, Visits: 29
Hi eMoe,

as far as I know from the Pascal programming language the '@' means that the parameter is given to the function as pointer instead of making a copy of it.
This is much more eficient than copying the variable as value over the stack. In addition it gives the possibility to change the value of the parameter inside the function.

With this you can for example write functions which return more than one value.


procedure GetMinMax(var graph: TChartGraph; range:Integer; minouble; maxouble);

In this procedure the minimum and maximum values from a given graph in a given range are determined. The result is written in the variables min and max. For this you need the possibility to use pointer as parameters.

Best regards

Jeremia
Post #1852
Posted 9/30/2010 8:57:19 AM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 1/27/2012 12:53:25 PM
Posts: 201, Visits: 295
Hi, Jeremia!


// This function will get maximum rate for defined number of candles(count) from Index (first candle).
function maxCandle(count,Index : integer): double;
var
m : double;
i : integer;
begin
m:=History.Last(Index).High;
for i := 1 to count-1 do
m := max(m,History.Last(Index+i).High);
result := m;
end;

----------------------------------------------------------------------------------------------------------------------

// This function will get minimal rate for defined number of candles(count) from Index (first candle).

function minCandle(count,Index : integer): double;
var
m : double;
i : integer;
begin
m:=History.Last(Index).Low;
for i := 1 to count-1 do
m := min(m,History.Last(Index+i).Low);
result := m;
end;


Best regards!

Edited: 9/30/2010 8:58:21 AM by eMoe
Post #2055
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin

All times are GMT -5:00, Time now is 8:35pm


© 2009 Actforex.com Terms of Use