Equivalent / workaround for "Include Systems" feature?

Questions about MultiCharts and user contributed studies.
Sebastian Vermont
Posts: 36
Joined: 06 Jan 2016
Has thanked: 6 times
Been thanked: 5 times

Equivalent / workaround for "Include Systems" feature?

Postby Sebastian Vermont » 10 Feb 2016

I can't seem to figure out how to replicate the "Include Systems" feature of EasyLanguage into PowerLanguage.

Here's what I am trying to do: Instead of constantly rewriting a set of signals to update the same trade management features, I want to separate trade management from signal generation. So let's say I have signal A, B, and C. Each signal would use the exact same trade management features from a "signal" which I'll call Z. If I wanted to update my trade management practices, all I would have to do is update Z instead of updating signals A, B, and C. This would reduce the potential for errors and speed up development.

I even tried putting trade management into a function, but functions apparently cannot use order generation commands, so I can't set stops/TPs with them.

Any advice or direction would be greatly appreciated. Thanks!

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1502 times
Contact:

Re: Equivalent / workaround for "Include Systems" feature?

Postby JoshM » 11 Feb 2016

It's a true workaround, but CommandLine() can add signals based on various command line commands.

This is not a 'code inheriting' feature you also mention where the Z "signal" contains code that's incorporated in other signals, but the Command Line can add the Z signal to the chart. The `I_GetPlotValue()` and `I_SetPlotValue()` keywords (see here) or just global variables can then be used to have the data computed by Z communicated to the other signals. With this workaround you'll at least prevent code replication.

Grigorios
Posts: 49
Joined: 30 Nov 2007
Has thanked: 13 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Grigorios » 15 Feb 2016

Thanks JoshM ,

But how to prevent the CommandLine statement running on every bar and adding the signal
multiple times on chart? i tried with "Once - Begin" with no luck.

It's a true workaround, but CommandLine() can add signals based on various command line commands.

This is not a 'code inheriting' feature you also mention where the Z "signal" contains code that's incorporated in other signals, but the Command Line can add the Z signal to the chart. The `I_GetPlotValue()` and `I_SetPlotValue()` keywords (see here) or just global variables can then be used to have the data computed by Z communicated to the other signals. With this workaround you'll at least prevent code replication.

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1502 times
Contact:

Re: Equivalent / workaround for "Include Systems" feature?

Postby JoshM » 16 Feb 2016

But how to prevent the CommandLine statement running on every bar and adding the signal multiple times on chart?
You can use a Boolean variable that has its value 'switched' as soon as `CommandLine()` has executed once, for instance like this (untested):

Code: Select all

Variables:
IntrabarPersist onlyAddOnce(false);

if (onlyAddOnce = false) then begin

CommandLine("...");

onlyAddOnce = true;

end;

Grigorios
Posts: 49
Joined: 30 Nov 2007
Has thanked: 13 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Grigorios » 16 Feb 2016

Thanks JoshM but your suggestion doesn't seem to work either....

User avatar
TJ
Posts: 7192
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby TJ » 16 Feb 2016

Thanks JoshM but your suggestion doesn't seem to work either....
Please post your codes.

Grigorios
Posts: 49
Joined: 30 Nov 2007
Has thanked: 13 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Grigorios » 17 Feb 2016

Thanks JoshM but your suggestion doesn't seem to work either....
Please post your codes.

Code: Select all

Once Begin
CommandLine(".isig name1=Acme Trade Manager");
End;

Code: Select all

Var:RunOnce(false);
If (RunOnce=false) then begin
CommandLine(".isig name1=Acme Trade Manager");
RunOnce=True;
End;
I tried both from within a signal ...both add Acme Trade Manager signal multiple times...
where i am wrong please?

Sebastian Vermont
Posts: 36
Joined: 06 Jan 2016
Has thanked: 6 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Sebastian Vermont » 17 Feb 2016

Can inputs be passed with this workaround? I can't figure out how to accomplish this, and it would be necessary for my use case.

Thanks again

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1502 times
Contact:

Re: Equivalent / workaround for "Include Systems" feature?

Postby JoshM » 20 Feb 2016

Thanks JoshM but your suggestion doesn't seem to work either....

Code: Select all

Var:RunOnce(false);
If (RunOnce=false) then begin
CommandLine(".isig name1=Acme Trade Manager");
RunOnce=True;
End;
Your code is different from the example I posted; you're missing the IntrabarPersist keyword. Does it work when you use that keyword?
Can inputs be passed with this workaround? I can't figure out how to accomplish this, and it would be necessary for my use case.
I don't follow; you want to pass inputs from where to where?

If you mean the Command Line, then yes a string input can be passed to the Command Line with `CommandLine()`. But in that case you can also use the Command Line toolbar itself, that may be easier and more efficient than typing in the same command in the script's input settings.

Grigorios
Posts: 49
Joined: 30 Nov 2007
Has thanked: 13 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Grigorios » 20 Feb 2016

Hi JoshM,
use of IntraBarPersist makes no difference....it keeps running on every bar and adds signal
multiple times on chart....very strange...any suggestions ?

TIA
Your code is different from the example I posted; you're missing the IntrabarPersist keyword. Does it work when you use that keyword?

Sebastian Vermont
Posts: 36
Joined: 06 Jan 2016
Has thanked: 6 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Sebastian Vermont » 22 Feb 2016

Can inputs be passed with this workaround? I can't figure out how to accomplish this, and it would be necessary for my use case.
I don't follow; you want to pass inputs from where to where?

If you mean the Command Line, then yes a string input can be passed to the Command Line with `CommandLine()`. But in that case you can also use the Command Line toolbar itself, that may be easier and more efficient than typing in the same command in the script's input settings.
Sorry, I did not realize the ambiguity of "inputs". I am referring specifically to signal inputs. For the signals I load, I want to be able to pass inputs to them, just like I would inside the "Format Signals" dialog or with something like:

Code: Select all

inputs: inputTrendBarMaximum (12);

Sebastian Vermont
Posts: 36
Joined: 06 Jan 2016
Has thanked: 6 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Sebastian Vermont » 22 Feb 2016

Something fairly obvious just occurred to me. I could simply have a separate trade management signal loaded on the chart at all times, alongside the actual entry signal. This would be very easy using MarketPosition(0), EntryName(0), etc and it should work just fine with backtesting and optimizing (although somewhat slower, I'm sure).

As long as I'm careful when planning this out (so that each signal knows what the other is doing) I don't see any downside here. Is there something I'm missing?

Sebastian Vermont
Posts: 36
Joined: 06 Jan 2016
Has thanked: 6 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Sebastian Vermont » 23 Feb 2016

After playing around with this, I've come to two conclusions:

1) The use of multiple signals will certainly reduce the amount of code I need to maintain (whether using the CommandLine() function or just separating entry and management signals from the start), and

2) I will still have a lot of redundant code to maintain unless I figure out some way to mimic "Include Systems".

For now I am just going to separate entry and trade management signals. At some later date I might try out some different ideas. I was thinking perhaps I could use a 3rd party tool to mimic the effect of preprocessor directives. For example, I'd have a "master" code file, and use it to generate separate source code for each signal. The master file might look something like this:

Code: Select all

inputs:
inputBrokerBidData (1),
inputBrokerAskData (2),
inputBrokerPriceData (3),
inputBrokerVolumeData (4),
inputMaxSpreadAcceptable (5.0),
inputStartTime (1000),
inputEndTime (1500),
inputFridayEntryCutoff (1259),
inputFridayExitCutoff (1444),

#ifdef SETUP_A
inputTrendBarMaximum (50),
inputTrendBarMinimum (10);
#endif
#ifdef SETUP_B
inputPercentageRangeLast5 (80),
inputPercentageRangeLast45 (80);
#endif

.....

// General conditions go here for testing start time, end time, cut off times, etc

#ifdef SETUP_A
// conditions specific to Setup A go here
#endif
#ifdef SETUP_B
// conditions specific to Setup B go here
#endif

...

// Trade management goes here
So, whenever I needed to add a feature, I'd generate the source code of each different "setup" (signal) from 1 master file and then compile the source code for each signal inside MultiCharts. As an example of how this would be useful, let's say I want to go back and add an option to stop trading after generating two losses in a row for each signal that I currently run. Instead of editing each file, I would only have to update the master file. The source code is generated from that file, and then I'd compile each file (which I would have to do anyway).

If anyone has done something similar, or has any ideas/suggestions, please feel free to share.

Thanks

Grigorios
Posts: 49
Joined: 30 Nov 2007
Has thanked: 13 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Grigorios » 25 Feb 2016

Hi Sebastian Vermont,

have you succeed in adding a signal only once to a chart using CommandLine() ?

thanks

Sebastian Vermont
Posts: 36
Joined: 06 Jan 2016
Has thanked: 6 times
Been thanked: 5 times

Re: Equivalent / workaround for "Include Systems" feature?

Postby Sebastian Vermont » 25 Feb 2016

Hey,

I do not use intra-bar order generation in my entry or exit strategies, so unfortunately my experience is not going to be helpful to you. Also, for the sake of simplicity I have settled on using a "static" trade management signal as opposed to using CommandLine. I am still looking for a practical way to mimic the "Include Systems" feature to reduce code replication.


Return to “MultiCharts”