What in the world could be wrong with this picture?!

Questions about MultiCharts and user contributed studies.
Freakendorf
Posts: 14
Joined: 29 Jun 2014
Been thanked: 3 times

What in the world could be wrong with this picture?!

Postby Freakendorf » 04 Jul 2014

Image
MultiCharts (2Data).jpg
Where are the signals?!
(111.35 KiB) Downloaded 1298 times
Even though the condition is met, No trading signals!

Notice the absence of any trade signals in Data1, despite the repeated crossover of the Close of Data2 of the Price (marked by the dotted yellow horizontal line).

So, where are the signals?!

Data1 is OZBQ14 C136 (2 Tick)
Data2 is USU14 (100 Tick) - But these resolutions could be changed if needed.

Code: Select all

[b]Inputs: Price(136);
If Close of Data2 crosses over Price
then BUY next bar at market;[/b]

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

Re: What in the world could be wrong with this picture?!

Postby JoshM » 06 Jul 2014

Is this a double post from what you posted here? If so, my suggestion would be the same as in that topic. If not, could you specify what makes this question different? I'm not understanding the difference.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: What in the world could be wrong with this picture?!

Postby evdl » 06 Jul 2014

You only get a signal if the close of data2 crossing over coincidence with the closing of a bar in data1. The script is only calculated on the close of a bar on data1.

The close of data2 crossing the price is only valid when this happens. The next bar or tick if you use IOG in data1, it can not be valid anymore. If you want this to be valid until a bar is formed in data1, you should use a variabel which can be set to true of false when the crossing takes place in data2 and use this variabel to create the signal when the data1 bar is formed.

You also should reset this variabel, for example after taking a position. Otherwise you will get a lot of signals.

With print statements in the editor, you can check the status of the variabel and see if the timing is alright. Working with multiple datastreams can be a bit difficult and sometimes can take some debugging to get it to work.

Freakendorf
Posts: 14
Joined: 29 Jun 2014
Been thanked: 3 times

Re: What in the world could be wrong with this picture?!

Postby Freakendorf » 06 Jul 2014

You only get a signal if the close of data2 crossing over coincidence with the closing of a bar in data1.
Thanks for the explanation. It's what I suspected to be the reason why no signals appear on the historical chart. But, what about real-time trading? For instance, currently, without any modifications to this code, shouldn't one expect signals to be generated and orders be placed (to BUY Data1) - instantly - each time the condition is met (following each crossover of Data2 to the Price)..?

In other words, is there a reason for this code not to work as intended in real time?

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

Re: What in the world could be wrong with this picture?!

Postby TJ » 06 Jul 2014

You only get a signal if the close of data2 crossing over coincidence with the closing of a bar in data1.
Thanks for the explanation. It's what I suspected to be the reason why no signals appear on the historical chart. But, what about real-time trading? For instance, currently, without any modifications to this code, shouldn't one expect signals to be generated and orders be placed (to BUY Data1) - instantly - each time the condition is met (following each crossover of Data2 to the Price)..?

In other words, is there a reason for this code not to work as intended in real time?
data1 must be of a faster fractal than the rest of the data series...

ie. to make your multi-data strategy work, data1 must have more ticks per minute than data2 .


ps. it is all a matter of timing... there are gymnastics you can do to make a slower data1 work, but it will take some time and effort to code the logic.

Freakendorf
Posts: 14
Joined: 29 Jun 2014
Been thanked: 3 times

Re: What in the world could be wrong with this picture?!

Postby Freakendorf » 07 Jul 2014

Thanks evdl and TJ. You both seem to be saying the same thing. My question is: Would these "gymnastics" ultimately produce a reliable code and consistent signals?..
And,..since this appears to be above my coding skills, should I expect help in that regard on this forum, or is it more involved so that I need to seek programming help somewhere else?
Last edited by Freakendorf on 07 Jul 2014, edited 1 time in total.

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

Re: What in the world could be wrong with this picture?!

Postby JoshM » 07 Jul 2014

data1 must be of a faster fractal than the rest of the data series...

ie. to make your multi-data strategy work, data1 must have more ticks per minute than data2 .
That's true, but in this case exchanging data 1 for data 2 would probably not work since he needs to trade data 1 (the option) and orders cannot be submitted for the second data series.
The close of data2 crossing the price is only valid when this happens. The next bar or tick if you use IOG in data1, it can not be valid anymore. If you want this to be valid until a bar is formed in data1, you should use a variabel which can be set to true of false when the crossing takes place in data2 and use this variabel to create the signal when the data1 bar is formed.

You also should reset this variabel, for example after taking a position. Otherwise you will get a lot of signals.
Do you might have an example of that? I cannot make it work (perhaps wrong setting?):

Code: Select all

[IntrabarOrderGeneration = true]

Variables:
averagePrice(0),
buySignal(false);

// Calculate average on the close of data 2
if (BarStatus(2) = 2) then begin
averagePrice = XAverage(Close Data2, 9);

buySignal = (Close Data2 > averagePrice) and (Close[1] data2 <= averagePrice);
end;

// Generate signals
if (buySignal = true) then
buy ("EL") next bar at market;

// Exit the position at the bar close of data 1
if (MarketPosition(0) > 0) and (BarStatus(1) = 2) then begin

sell ("XL") next bar at market;

end;
The setup highlighted in orange is not taken because it did not coincide with a bar close of data 1:

Image
So, where are the signals?!
Is there a reason why you need a non-time based resolution as data 1? Can you not plot the option with seconds bars? That would give data1 more bars (even though they might be empty) than data 2.

In addition, is there a reason why data 1 is plotted to Trade, and not bid/ask? They are probably a lot more bid/ask updates in the option than trades, so changing the quote field might lead to a data 1 with more price bars.
Attachments
scr.07-07-2014 08.56.18.png
(30.36 KiB) Downloaded 1210 times

Freakendorf
Posts: 14
Joined: 29 Jun 2014
Been thanked: 3 times

Re: What in the world could be wrong with this picture?!

Postby Freakendorf » 07 Jul 2014

These are good observations, JoshM.
Setting Data1 to "seconds" works fine, but still not enough bars.
Setting Data1 to Ask or Bid, instead of Trade, does not appear to work at all. It shows "No Data".!!

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: What in the world could be wrong with this picture?!

Postby Henry MultiСharts » 07 Jul 2014

Setting Data1 to Ask or Bid, instead of Trade, does not appear to work at all. It shows "No Data".!!
TS provides Trade quote field only.

Have you tried to debug your code using the Print statement like Evdl and the article Why an Order Was or Was Not Executed suggests?

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

Re: What in the world could be wrong with this picture?!

Postby TJ » 07 Jul 2014

data1 must be of a faster fractal than the rest of the data series...

ie. to make your multi-data strategy work, data1 must have more ticks per minute than data2 .
That's true, but in this case exchanging data 1 for data 2 would probably not work since he needs to trade data 1 (the option) and orders cannot be submitted for the second data series.
::
What is your rationale for recommending an exchange of data1 for data2?

Please see the rest of my post you quoted.

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

Re: What in the world could be wrong with this picture?!

Postby JoshM » 13 Jul 2014

That's true, but in this case exchanging data 1 for data 2 would probably not work since he needs to trade data 1 (the option) and orders cannot be submitted for the second data series.
::
What is your rationale for recommending an exchange of data1 for data2?

Please see the rest of my post you quoted.
I'm not recommending exchanging data1 for data2. I think words like 'not work' and 'cannot' made that already clear.

Not sure why you 'jumped on' this, but if I annoyed you unknowingly, my apologies. :)

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

Re: What in the world could be wrong with this picture?!

Postby JoshM » 07 Aug 2014

The close of data2 crossing the price is only valid when this happens. The next bar or tick if you use IOG in data1, it can not be valid anymore. If you want this to be valid until a bar is formed in data1, you should use a variabel which can be set to true of false when the crossing takes place in data2 and use this variabel to create the signal when the data1 bar is formed.

You also should reset this variabel, for example after taking a position. Otherwise you will get a lot of signals.
Do you might have an example of that? I cannot make it work (perhaps wrong setting?):

Code: Select all

[IntrabarOrderGeneration = true]

Variables:
averagePrice(0),
buySignal(false);

// Calculate average on the close of data 2
if (BarStatus(2) = 2) then begin
averagePrice = XAverage(Close Data2, 9);

buySignal = (Close Data2 > averagePrice) and (Close[1] data2 <= averagePrice);
end;

// Generate signals
if (buySignal = true) then
buy ("EL") next bar at market;

// Exit the position at the bar close of data 1
if (MarketPosition(0) > 0) and (BarStatus(1) = 2) then begin

sell ("XL") next bar at market;

end;
The setup highlighted in orange is not taken because it did not coincide with a bar close of data 1:

Image
Might anyone have an idea how to implement Evdl's suggestion? I'm curious to know how to create a strategy that has a 'slow' Data1 and 'fast' Data 2, but I cannot make it work.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: What in the world could be wrong with this picture?!

Postby Henry MultiСharts » 12 Aug 2014

Might anyone have an idea how to implement Evdl's suggestion? I'm curious to know how to create a strategy that has a 'slow' Data1 and 'fast' Data 2, but I cannot make it work.
JoshM, please specify what does not work exactly.

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

Re: What in the world could be wrong with this picture?!

Postby JoshM » 30 Aug 2014

JoshM, please specify what does not work exactly.
Trades that are generated on Data2 are only executed when their price bars overlap with those from Data1.

In the MA crossover highlighted by an orange box, which should have triggered a trade in Data1, no trade was taken because those Data2 bars happened in-between two Data1 bars.

Normally I'd switch both data series, so that the lower (faster) resolution is Data1 and the higher (slower) resolution Data2, but since it was said here that 'slow' Data1 can trade based on 'fast' Data2, I was wondering how to do that.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: What in the world could be wrong with this picture?!

Postby Henry MultiСharts » 09 Sep 2014

JoshM, please specify what does not work exactly.
Trades that are generated on Data2 are only executed when their price bars overlap with those from Data1.

In the MA crossover highlighted by an orange box, which should have triggered a trade in Data1, no trade was taken because those Data2 bars happened in-between two Data1 bars.

Normally I'd switch both data series, so that the lower (faster) resolution is Data1 and the higher (slower) resolution Data2, but since it was said here that 'slow' Data1 can trade based on 'fast' Data2, I was wondering how to do that.
Since MultiCharts 9.0 Beta 1 autotrading orders can be generated and sent if the barstatus value is -1. In order to allow that you need to add the following attribute at the top of your code:

Code: Select all

[AllowSendOrdersAlways = true]
If you want to have averagePrice calculated on data2 you need to use the following code:

Code: Select all

if (BarStatus(2) = 2) then begin
averagePrice = XAverage(Close Data2, 9)of data2;


Return to “MultiCharts”