Cutting off extended Rectangle - Sierra Chart | futures io social day trading
futures io futures trading


Cutting off extended Rectangle
Updated: Views / Replies:439 / 5
Created: by NaturePip Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Cutting off extended Rectangle

  #1 (permalink)
Trading Apprentice
Calgary Alberta Canada
 
Futures Experience: Intermediate
Platform: Sierra Charts
Broker/Data: TP Futures
Favorite Futures: Futures
 
Posts: 5 since Nov 2013
Thanks: 0 given, 1 received

Cutting off extended Rectangle

Hello Everyone:

Let me start by saying that I enjoy scripting but I am not all that good at it yet. I am currently writing a script and could use some advice.

MY script examines the close of the LAST candle on the chart and if it is lower than the low of candle previous candle, then it draws an extending rectangle around the previous candle. I have this part working fine.

The part I am not sure how to do is how to reference the rectangle once price comes up and intersects the low of the rectangle so I can then convert the extending rectangle to a regular rectangle to cut it off at this point. Should I use a persistent variable or an array? Also, how do I delete the reference or do I need to.... Not certain how to fully do this.

Below is the what I have written so far....


if (sc.GetBarHasClosedStatus(sc.Index) != BHCS_BAR_HAS_CLOSED)
return;

const float LastClosedCandle = sc.Close[sc.Index];
const float SecondLastCandleLow = sc.Low[sc.Index - 1];
const float SecondLastCandleHigh = sc.High[sc.Index - 1];


if (LastClosedCandle < SecondLastCandleLow)
{
double BeginTime = sc.BaseDateTimeIn[sc.Index - 1];
double EndTime = sc.BaseDateTimeIn[sc.Index];

const float LastCandleHigh = sc.High[sc.Index];

s_UseTool(Tool);

Tool.Clear();
Tool.AddAsUserDrawnDrawing = 1;
Tool.ChartNumber = sc.ChartNumber;
Tool.DrawingType = DRAWING_RECTANGLE_EXT_HIGHLIGHT;
Tool.BeginDateTime = BeginTime;
Tool.EndDateTime = EndTime;
Tool.BeginValue = SecondLastCandleLow;
Tool.EndValue = LastCandleHigh;
Tool.Color = COLOR_YELLOW;
Tool.LineWidth = 1;
Tool.LineStyle = LINESTYLE_DOT;
Tool.SecondaryColor = COLOR_YELLOW;
Tool.TransparencyLevel = 90;
Tool.AddMethod = UTAM_ADD_OR_ADJUST;

sc.UseTool(Tool);
}

Thank you... Any help with regards to the referencing of the rectangle when it is intersected would be greatly appreciated.

thanks,

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
Scottsdale
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: ES, YM
 
Posts: 26 since Nov 2010
Thanks: 3 given, 14 received

Hi NaturePip.

I'm not sure I understand the requirement. Since you're drawing a rectangle, its upper and lower PRICE values will remain unchanged even though it extends in TIME to whatever point. So you should be able to simply compare the current price to whatever your're setting Tool.BeginValue and Tool.EndValue to; in your case it's SecondLastCandleLow and LastCandleHigh.

(Things would have been tricky if you were drawing a sloping line (e.g. an extended Ray) where you don't know price touched by that ray at a certain point in time.)

That being said, why don't you use Subgraphs to store the values of SecondLastCandleLow and LastCandleHigh for every candle? If you don't want the subgraphs painted on chart, simply set their type to DRAWSTYLE_HIDDEN or DRAWSTYLE_IGNORE.

Let's say you assigned LastCandleHigh to sc.Subgraph[1]. For any candle on the chart, you can for example use the sc.CrossOver function to detect when price is crossing your (hidden) subgraph.

In addition, in Sierra there are multiple arrays attached to each subgraph array, which you can use to store values. So you can, for example, use those arrays to store the rectangle's Top and the rectangle's bottom for every candle on the chart. Again, detetcting intersections here would simply entail using the CrossOver() function.

I hope this helps.

Reply With Quote
 
  #3 (permalink)
Trading Apprentice
Calgary Alberta Canada
 
Futures Experience: Intermediate
Platform: Sierra Charts
Broker/Data: TP Futures
Favorite Futures: Futures
 
Posts: 5 since Nov 2013
Thanks: 0 given, 1 received


Hello Zambia:

Just wanted to thank you very much for your input. I am not certain I have fully wrapped my head around what you are suggesting yet but let me play with your idea some more. I did try using subgraphs early on in the development of this study but did not have much success. However, I didn't try it the way you are suggesting. I think I also ran into some stumbling block with the drawing type....

In any event, I will try it again with your suggestion and let you know how I make out by posting my results here.

thank you

NaturePip

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Calgary Alberta Canada
 
Futures Experience: Intermediate
Platform: Sierra Charts
Broker/Data: TP Futures
Favorite Futures: Futures
 
Posts: 5 since Nov 2013
Thanks: 0 given, 1 received

Hi Zambia:

I remember why I am not using Subgraph now. It is because there is NO horizontal rectangle or extended rectangle Draw Style under Subgraphs. There is a Fill Rectangle to Top and Bottom but that is not what I need. Therefore, if the drawing style does not exist, how do I use it?

That's why I am using the sc.UseTool function. Because under this function, there is a Rectangle and Extended Rectangle Draw Type.

Notice the distinction. Subgraphs use Draw STYLE and sc.UseTool use Draw TYPE.

Anyway, I am back to my original question of how to reference rectangle so I may modify the Tool.EndDateTime parameter to end the rectangle from drawing any further, once price hits the low of the rectangle (which would be the low of the candle I reference).

Like I said, I am not the best programmer and I am still very much learning my way around AsciL.

thanks again,

Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Scottsdale
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: ES, YM
 
Posts: 26 since Nov 2010
Thanks: 3 given, 14 received

Hi Nature

One way of doing this is to "name" each rectangle. One member you're not using in your code is .LineNumber, which allows you to assign an arbitrary number to each drawing.

Use a persistent variable to hold a counter, and increment that counter as each new rectangle is introduced to the chart. From then on, you can call each rectangle by its number, and change its settings (start, end, colour, etc).

So, when the conditions are true for creating a NEW rectangle, and before you draw that new rectangle, you reference the CURRENT most recent rectangle using its .LineNumber, and change its drawtype to a non-extending rectangle, and set its .EndDateTime.

P.S. Unless there's a specific need for using DateTime's to set beginning and end, I've always found it more manageable to set beginnings and endings using a bar index number.

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Calgary Alberta Canada
 
Futures Experience: Intermediate
Platform: Sierra Charts
Broker/Data: TP Futures
Favorite Futures: Futures
 
Posts: 5 since Nov 2013
Thanks: 0 given, 1 received

Hi Zambia:

Thank you again for your response. I greatly appreciate it. I hope you and everyone else who I reading this post had, or is having, a wonderful holiday.

I have actually started working with .LineNumber persistent variable and have setup a counter for it that increments with each new rectangle created.

Couple things I should clarify.... first, regarding the bar index.... Once I create a new rectangle on my higher time frame, I want to copy it to the lower time frame. That's fine, I simply use the .ChartNumber to draw an additional rectangle to the chart I desire. (I tried copying the rectangle via Chart Settings - Copy, but that did not work, even though I used the .AddAsUserDrawnDrawing when I created the rectangle in my study). Anyway, during development of this COPY, I was in fact using the Bar Index instead of .DateTime. It worked great as long as I stuck to the one chart. However, the rectangles were not copying correctly to the lower time frame chart. The "Value" levels were correct, but not the "DateTime", on the lower time frame chart. That is why I had to use the .BeginDateTime and .EndDateTime. Once I made that switch, the rectangles appeared on both charts without any errors.

Second, regarding .LineNumber.... You said that before I create a NEW rectangle, I should reference the current most recent rectangle and set its .EndDateTime. However, I only want to set the .EndDateTime once price comes back up and HITS to low of the rectangle...which will always be value at my SecondLastCandleLOW variable.

Therefore, I require another persistent variable (ValueDown) that I will increment and hold the "LOW value" information for each newly created rectangle. Since the first persistent variable is just a "name" reference, I cannot use it to test the low of the rectangle. That is why I am thinking I need this second persistent variable.

I am concerned about setting up the second persistent variable since it will need to be a foating number and not an int, since the Value information has decimal places. I hope I can set it up as float. Otherwise, I don't know how I will test the low of the rectangle.

Then, prior to any other testing, I will setup a new if...then condition that will TEST whether price has hit the LOW of a rectangle and if true, then go to most recent current rectangle (via .LineNumber persistent variable) and set its .EndDateTime. Then I will De-increment both persistent variables.

Anyway, that is my current plan. Do not have it on paper yet, just the flow chart. I've never even setup a persistent variable before so hopefully that works. Please let me know what you think of my logic. I am more than happy to hear any suggestions or improvements to this script.

I will let you know how I do by posting my results here.

Thank you,


Last edited by NaturePip; December 28th, 2017 at 11:24 AM.
Reply With Quote

Reply



futures io > > > > Cutting off extended Rectangle

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

September Journal Challenge (sponsored by TopstepTrader)

September

Battlestations! Win $947 in prizes for showing us your trading desk!

October
 

Finding Your Edge & Maximizing Returns w/Richard L Weissman

Oct 16
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webinar: Dr Brett Steenbarger - Extended Ask Me Anything (AMA) Big Mike The Elite Circle 10 August 13th, 2017 04:40 AM
losing extended screen after window 10 update. mykee Traders Hideout 7 November 28th, 2016 09:18 PM
Vertical Rectangle on Right of Chart mmaker NinjaTrader Programming 3 December 7th, 2014 03:46 AM
Extended ray for sma, vwap, trix etc. indicator (NT7) Peke5 The Elite Circle 4 October 23rd, 2014 06:21 AM
[SC] Example of study for extended rectangles Nicolas11 The Elite Circle 12 July 14th, 2014 11:20 AM


All times are GMT -4. The time now is 04:41 AM. (this page content is cached, log in for real-time version)

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2018-10-16 in 0.14 seconds with 14 queries on phoenix