Scanning outside bar pattern
Author: pichu_1972
Creation Date: 4/8/2016 10:18 AM
profile picture

pichu_1972

#1
Hello everybody, this is my first post, my name is Juan, from Spain and I must say THANKS for this wonderful software.

I am programming with monthly bars and I can detect outside bars:
-High > Previous High
-Low < Previous Low
But I need to know what happens first.

"Ascending" outside bar(inMonthly): First L < Previous L and then H > Previous H
"Descending" outside bar(inMonthly): First H > Previous H and then L < Previous L


As I am working with monthly bars, I can not set scale weekly, dayly..... and have a look inside the outside bar.

Any help to know what happens first??
For example If I find an "ascending" outsidebar I would relocate my stop loss to the LOW of the outsidebar but if the outsidebar is "descending" my stops loss remains where it was located (this is only an example)
Thanks
profile picture

Eugene

#2
¡Hola y bienvenido al forum Juan! We appreciate that you like the product.

What do you mean that you can not set Weekly/EOD scale?

1. Is the data available in Monthly scale exclusively? In this case, you could only make biased assumptions like, for example, LimitPriorityLong from Community Components is making. Check out PositionEx.cs in the source code. On the other hand if it were a fundamental/sentiment series it would have Close only, but since it's an OHLC there must be a lower bar scale.

2. If the EOD data is available there is an easy way to peek inside it from Monthly by analogy: Accessing Intraday data from Daily
profile picture

pichu_1972

#3
Hola Eugene, EOD data is avalaible so I will try to peek inside it from Monthly as you write in 2.

This idea is part of a strategy which runs with Monthly bars so Multi-Time Frame Analysis does not allow me to access data and indicators based on lower timeframes,(SetScaleWeekly(), SetScaledaily().....)
profile picture

Cone

#4
If you need to see what happens in the daily or weekly time frame, you should run the strategy using daily bars and create your monthly bars/indicators with SetScaleMonthly() and return to the base scale (daily) with RestoreScale() to execute the trading system.

QUOTE:
"Ascending" outside bar(inMonthly): First L < Previous L and then H > Previous H
"Descending" outside bar(inMonthly): First H > Previous H and then L < Previous L
The strategy isn't clear to me, but if you can explain more clearly what this means, I'd be glad to help.
profile picture

pichu_1972

#5
Hi Cone, I am making a complete strategy based in Monthly bars, but there is a case I need lower timeframes.
This single case is when I find a Monthly outsidebar and I need to know what hapen fist, I try to explain it with some pics, one "ascending" outside bar, one decending, and the last it can be ascending or descending you need lower timeframe to see it.
Thanks again.
profile picture

Eugene

#6
Here's how you can determine what happened first, a High or a Low. To be run on Daily data, not Monthly:

CODE:
Please log in to see this code.
profile picture

Cone

#7
Here's another solution that will be easier to follow, and you can use the boolean variables isOutsidebar and highWasFirst.

Use Daily bars.

CODE:
Please log in to see this code.


profile picture

pichu_1972

#8
Thank you Eugene and Cone!!!!
Trying to understand how your codes work.
I suppose I should run the whole strategy using daily bars so I will need help again
profile picture

Eugene

#9
Right, daily bars.
profile picture

pichu_1972

#10
Hello, I undestood what your codes do, thank you very much, this is what I needed.

One trouble again about how I can paint my strategy, I have programmed in daily scale, but it is really a monthly strategy.
Is it posible to draw any chart with monthly bars (not the chart with 20 constant bars every day of the same month) programming in daily scale?
For example I need draw a monthly trendline but with monthly bars, not with 20 constants bars).

Thanks again,really valuable your help.
profile picture

Eugene

#11
There's almost always a way. In order of complexity:

1. As a visual aid, overlay monthly candlesticks on the daily chart. For what I mean, see the WealthScript Programming Guide: Multi-Time Frame Analysis > Intraday/Daily > How to: Overlay Daily Candlesticks on an Intraday Chart.

2. Recode your original strategy to peek inside daily bars as exemplified in a link from my post #2

3. Using the "daily" strategy, build a list of month/highWasFirst pairs. Pass it for use in the monthly strategy somehow e.g. read/import a text file, Wealth-Lab's global memory (GOP), clipboard etc.
profile picture

pichu_1972

#12
Hola Eugene and thank you very much.

1. Done!!!

But I would try 3.

I am not sure if I have understood it perfectly (I began with C# 2 months ago)

I can make one code (something like Eugene or Cone Code), daily scale that seeks outside bars, and this code can also create a txt writing these 3 infos (Bars.Symbol, date of outside bar and highWasFirst or lowWasFirst) for each symbol and outsidebar.

Then I create a new program with a new code, monthly scale with my whole strategy and when this code finds a monthly outside bar goes to the txt and finds out with the Bars.Symbol and the date I pass if it is a highWasFirst or lowWasFirst outsidebar.
Is it OK?

Thanks again.
profile picture

Eugene

#13
Correct. Here's a quick (read: not too elegant) example for you using global memory. The donor strategy's selected date range reflects how many items will be processed by the recipient strategy.

1. Donor strategy using Cone's code - to be run on daily:

CODE:
Please log in to see this code.


2. Recipient strategy code - to be run on Monthly scale:

CODE:
Please log in to see this code.
profile picture

pichu_1972

#14
Absolutely great SetGlobal//GetGlobal.
Trying to understand again, they are a really fast (and usefull) C# lessons.
Thanks,thanks,thanks.
profile picture

pichu_1972

#15
Well, done and understood.
But a little problem.
When you run Donor strategy for a single symbol it works OK.
But when you run Donor strategy for a whole dataset it only works for the last symbol of the dataset. Is it supposed that SetGlobal is rewritten each symbol so the last one only remains??

I found a solution but I dont know if it is the best one as I dont know how exactly SetGloblal//GetGlobal works


SetGlobal("lstTuple"+Bars.Symbol , (objet) lst);

GetGlobal("lstTuple"+Bars.Symbol);
profile picture

Eugene

#16
Your understanding is correct. Glad you found the solution:

Donor:
CODE:
Please log in to see this code.


Recipient:
CODE:
Please log in to see this code.
profile picture

pichu_1972

#17
Hello I have everything working perfectly.
Fist I execute Donor strategy
2nd I execute Recipient Strategy
My question is:
Is there any possibility in C# that I only execute Recipient Strategy calling the Donor strategy from the Recipient Strategy??

Of course I have no problem doing 1st and 2st.

Thanks again
profile picture

Eugene

#18
Generally it's possible but not in this special case I think. The problem is that they have to work in different timeframes.
profile picture

pichu_1972

#19
OK thank you very much, no problem doing 1st and 2st.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).