Page 1 of 1

method void

Posted: 22 Mar 2012
by pivot
Does MC have an equivalent to the reserved word in TS of "method Void"

here is what TS write on it:
The method reserved word allows you to create a named subroutine within an EasyLanguage document that consists of a sequence of statements to perform an action, a set of input parameters to customize those actions, and possibly a return value.
here is the example they give
Example
The following method reads and displays account information from the AccountsProvider1 object that was created using the Accounts Provider component. When ShowInformation(0) is called, the first plot displays the Account ID of the first Account in the provider collection (acctIndex is 0) and the second plot displays the Real Time Net Worth value for the same account. Since this method does not return a value it's return type is void.

Code: Select all

Method void ShowInformation(int acctIndex)
begin
if (AccountsProvider1.Count > 0) then
begin
plot1(AccountsProvider1.Account[acctIndex].AccountID, "Account ID");
plot2(AccountsProvider1.Account[acctIndex].RTAccountNetWorth, "RT Net Worth");
end;
end;

Re: method void

Posted: 31 Mar 2013
by FutureTrader
I have the same question. I'm transfering my TS code to multicharts. What is equivalent to:
method void doScaleInLong()
begin
//Buy("LE_Add02") scaleInContracts02 contracts next bar at addPositionPrice02 limit;
//Buy("LE_Add03") scaleInContracts03 contracts next bar at addPositionPrice03 limit;
end;

method void doScaleInShort()
begin
//...
end;
How to write subroutines in PowerLanguage?

Re: method void

Posted: 03 Apr 2013
by JoshM
How to write subroutines in PowerLanguage?
Not possible. But you could use a Boolean variable to get something like this to simulate a method:

Code: Select all

Variables:
IntraBarPersist EnterLong(False);

if (myLongCondition = true) then begin

// Some code
EnterLong = True;

end else
EnterLong = False;

// "method" doScaleInLong()
if (EnterLong = True) then begin

Buy("LE_Add02") scaleInContracts02 contracts next bar at addPositionPrice02 limit;
Buy("LE_Add03") scaleInContracts03 contracts next bar at addPositionPrice03 limit;

end;