Adding an unused input changing trade signal  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
ZaphodB
Posts: 64
Joined: 12 Feb 2019
Has thanked: 20 times
Been thanked: 2 times

Adding an unused input changing trade signal

Postby ZaphodB » 24 Jun 2019

Have been trying for the past few hours to figure this out with no luck. Appreciate any help.

I noticed that simply having an input that uses Data2 will affect the trade signals even if none of the trading logic references the Data2 input.

I loaded AAPL charts for 01/01/2017 to present date with 10 minute chart as Data 1 and 1 hour chart as Data 2.

I then put this simple signal on the chart:

Code: Select all

Inputs: Price (Close) ; Variables: MovAvg (0) , SDev (0) , NumbrStdDevs (0) ; MovAvg = AverageFC (Price, 20) ; SDev = StandardDev (Price, 20, 1) ; NumbrStdDevs = (Price - MovAvg) / SDev ; // Order Logic If NumbrStdDevs < -2.0 // Well oversold then buy next bar at market ; If NumbrStdDevs > 2.0 // Well overbought then sell next bar at market ;
The above code made 269 total trades.

I noticed that if I added an input based on Data2 it would change the Strategy Performance Report. By simply adding an additional input:

Code: Select all

Inputs: Price (Close) , Price2 (Close Data2) ;
It made 267 trades instead of 269. Why would an unused input change the trading results?

Here is the full code with the additional input so you can see that nothing else changed except the addition of an input:

Code: Select all

Inputs: Price (Close) , Price2 (Close Data2) ; Variables: MovAvg (0) , SDev (0) , NumbrStdDevs (0) ; MovAvg = AverageFC (Price, 20) ; SDev = StandardDev (Price, 20, 1) ; NumbrStdDevs = (Price - MovAvg) / SDev ; // Order Logic If NumbrStdDevs < -2.0 // Well oversold then buy next bar at market ; If NumbrStdDevs > 2.0 // Well overbought then sell next bar at market ;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Adding an unused input changing trade signal

Postby TJ » 24 Jun 2019

Your MaxBarsBack might be different.


Have you checked to see which trades are missing?

User avatar
ZaphodB
Posts: 64
Joined: 12 Feb 2019
Has thanked: 20 times
Been thanked: 2 times

Re: Adding an unused input changing trade signal

Postby ZaphodB » 24 Jun 2019

Thanks, by MaxBarsBack, do you mean the setting under "Strategy Properties"? It stays at 50 bars back whether the code has the Data2 input or not. I haven't checked to see what trades are missing because this didn't seem like a code issue and like it was something beyond that...

I also tried something different and instead of adding an additional input that refers to Data2, I added a random input:

Code: Select all

Inputs: Price (Close) , BlahBlah (0) ;
Adding the input "BlahBlah" also induced the same change and there are 2 less trades. In this experiment Data 2 isn't referenced at all in the code, but the same change to the Strategy Report happens simply by adding an unused input... I remove the input BlahBlah it does 269 trades, put BlahBlah back in and it does 267 trades.

User avatar
ZaphodB
Posts: 64
Joined: 12 Feb 2019
Has thanked: 20 times
Been thanked: 2 times

Re: Adding an unused input changing trade signal

Postby ZaphodB » 24 Jun 2019

Actually, I just did an update on MC and now I can't duplicate changed results from adding BlahBlah input but I CAN duplicate changed results from adding input from Data2. I was getting delayed error codes on the chart view when I was using the BlahBlah input, so I did the update on MC. However, like I said, I'm still having the issue with the Data2 input. I'm wondering if there's some other place that I should be adjusting MaxBarsBack, but why would it matter if I'm not actually using Data2 for anything in the trading logic? Thanks

User avatar
ZaphodB
Posts: 64
Joined: 12 Feb 2019
Has thanked: 20 times
Been thanked: 2 times

Re: Adding an unused input changing trade signal

Postby ZaphodB » 24 Jun 2019

I just tried making Data2 go back a few more days further than Data1 and it corrected the issue. I don't understand why that would make a difference though, because Data2 isn't referenced anywhere else in the code except initially as an input..... Trying to figure out the workings of MC because I think this same thing is causing problems for me in my more complicated code that I'm working on

User avatar
ZaphodB
Posts: 64
Joined: 12 Feb 2019
Has thanked: 20 times
Been thanked: 2 times

Re: Adding an unused input changing trade signal  [SOLVED]

Postby ZaphodB » 24 Jun 2019

Ah, I see! The signal won't start at all unless it can view the entire MaxBarsBack, even if the referenced input isn't used in the signal logic... When I had the chart date start earlier on Data2, it had enough bars to start the trading earlier in 2017, hence the lack of 2 trades if I started both Data feeds on 1/1/17... I think calling it MaxBarsBack is sort of confusing because clearly it sometimes serves as Minimum Bars Back.


Return to “MultiCharts”