method void

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
pivot
Posts: 29
Joined: 07 Dec 2009
Been thanked: 2 times

method void

Postby pivot » 22 Mar 2012

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;

FutureTrader
Posts: 79
Joined: 28 Mar 2013
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: method void

Postby FutureTrader » 31 Mar 2013

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?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: method void

Postby JoshM » 03 Apr 2013

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;


Return to “User Contributed Studies and Indicator Library”