NexusFi: Find Your Edge


Home Menu

 





Plotting horizontal line


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,731 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread

Plotting horizontal line

  #1 (permalink)
 ReximusMaximus 
SAINT LOUIS
 
Experience: Advanced
Posts: 40 since Aug 2019
Thanks Given: 7
Thanks Received: 23

Hi guys,

New to Tradestation/EasyLanguage, it's only bee a week or so.

I'm trying to develop a strategy that places a limit order when a strong candle is formed at the high/low of the bar prior to the strong candle. I've been searching around for a way to deal with the fact that limit orders are cancelled at the end of the "next" bar.

To remedy this, I'm attempting to create an indicator that plots a horizontal line using the following logic:

If we have a "strong" up candle, draw line (place limit order) at the high of the bar prior to the "strong" candle.
If we have a "strong" down candle, draw line (place limit order) at the low of the bar prior to the "strong" candle.

As a side note, I've noticed that when I try to use "is_big_bar" in the if statement that plots the lines, it reacts differently to when I place the formula.

The problem is that these lines are sloped, rather than horizontal. Can anyone point me in the right direction, whether how to just have the limit order exist without getting cancelled, or with the indicator?

 
Code
inputs: bar_size_limit(2);
vars: limit_price(0), is_big_bar(false), down_bar(false), up_bar(false);

If absvalue(open-close) > bar_size_limit then
	is_big_bar = true;

If close < open then
	down_bar = true;

If close > open then
	up_bar = true;


If absvalue(open-close) > bar_size_limit then begin
	if down_bar then
		plot1(low[1]);
	If up_bar then
		Plot2(high[1]);
end;

Attached Thumbnails
Click image for larger version

Name:	sloped lines.PNG
Views:	460
Size:	159.3 KB
ID:	278174  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Tao te Trade: way of the WLD
23 thanks
Diary of a simple price action trader
22 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


ReximusMaximus,

for drawing lines you might want to look into trend lines or horizontal lines. These are drawing objects and will do what you have in mind.

In general orders are cancelled when your conditions for the order are no longer true. You can use this to keep your orders alive by using conditions that you keep valid as long as you want.
You can for example use a Boolean variable that you set to true when your conditions are fulfilled and then only use this variable to issue your order. When you are filled or when you don't want to issue the order anymore you could set this variable back to false.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
 ReximusMaximus 
SAINT LOUIS
 
Experience: Advanced
Posts: 40 since Aug 2019
Thanks Given: 7
Thanks Received: 23


ABCTG View Post
ReximusMaximus,

for drawing lines you might want to look into trend lines or horizontal lines. These are drawing objects and will do what you have in mind.

In general orders are cancelled when your conditions for the order are no longer true. You can use this to keep your orders alive by using conditions that you keep valid as long as you want.
You can for example use a Boolean variable that you set to true when your conditions are fulfilled and then only use this variable to issue your order. When you are filled or when you don't want to issue the order anymore you could set this variable back to false.

Regards,

ABCTG

Thanks for the suggestion.

I've tried a million things over the last several days and am back to trying to plot horizontal lines, assuming I'll be able to reference them in the code for the strategy (not sure if that's possible).

Can't share the link because I only have 2 posts, but I found some info about drawing lines.

I've tried to plot a simple line to see how that works, but I am definitely doing something wrong.

Can you help point me in the right direction?

 
Code
using elsystem.drawingobjects;
using elsystem; 

vars: horizontalline myline(null);

If 	Time = 825 then
		myline = horizontalline.create(close);

DrawingObjects.Add(myline);

Started this thread Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

ReximusMaximus,

you don't have to add your drawing to DrawingObjects on every code cycle. It is enough to add it when you create the drawing object. With the way you wrote the code you might also run into an error when myLine is still null and the code tries to add that to DrawingObjects.

Regards,

ABCTG


ReximusMaximus View Post
Thanks for the suggestion.

I've tried a million things over the last several days and am back to trying to plot horizontal lines, assuming I'll be able to reference them in the code for the strategy (not sure if that's possible).

Can't share the link because I only have 2 posts, but I found some info about drawing lines.

I've tried to plot a simple line to see how that works, but I am definitely doing something wrong.

Can you help point me in the right direction?

 
Code
using elsystem.drawingobjects;
using elsystem; 

vars: horizontalline myline(null);

If 	Time = 825 then
		myline = horizontalline.create(close);

DrawingObjects.Add(myline);


Follow me on Twitter Reply With Quote




Last Updated on October 30, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts