Future Reference to Past Bar - EasyLanguage Programming | futures io social day trading
futures io futures trading


Future Reference to Past Bar
Updated: Views / Replies:1,336 / 23
Created: by Vientomarsol Attachments:11

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 90,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
 11  
 
Thread Tools Search this Thread
 

Future Reference to Past Bar

  #1 (permalink)
Trading Apprentice
Port St. Lucie, FL.
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: ES
 
Posts: 22 since May 2016
Thanks: 14 given, 7 received

Future Reference to Past Bar

Iím building an ES Tick-bar strategy in TradeStation Easy Language.

I have coded a specific bar that will trigger an entry several bars later. The number of bars later will vary.

Question: How can I reference the trigger bar (actually; the High or Low of the Trigger bar) as a value for my exit stop, after my entry has been filled?

Attached example depicts a long trade. Any suggestions?

Attached Thumbnails
Future Reference to Past Bar-future-reference-past-bar.bmp  
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,466 since Apr 2013
Thanks: 224 given, 836 received


Vientomarsol,

you wrote "I have coded a specific bar that will trigger an entry several bars later. ". Just save the values you need from that trigger bar into variables at the moment you detect the trigger bar.

In other words you will have conditions for what makes your trigger bar and every time these are met, you can also store the values you need to use later.

By the way you can show your appreciation for a post on futures.io by clicking the "Thanks" button next to it.

Regards,

ABCTG

Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
  #4 (permalink)
Trading Apprentice
Port St. Lucie, FL.
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: ES
 
Posts: 22 since May 2016
Thanks: 14 given, 7 received

Thanks for your prompt reply (amazing turnaround!)

I donít know how to Store the values for later. Please elaborate.

My Trigger Code is:

//Long Entry Trigger
If Condition2[1] and Condition3 and (Condition7 or condition8) and not Condition10 then begin Buy ( "LE" ) next bar at market;
MP = 1;
End;


I need to add something to my code that will mark the Low of my trigger bar (not my entry bar) as my stop; if and when, my order is triggeredĒ.

How do I code this?

Thanks in advance for your input :-)

Reply With Quote
 
  #5 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,466 since Apr 2013
Thanks: 224 given, 836 received

Vientomarsol,

you are welcome. It appears your code snippet is for the bar that actually triggers the entry. Storing the values of that bar would be too late as you want the trigger bar values (at least this is my impression from what you wrote).

Not knowing what your conditions for the trigger bar are and what values you actually want to store, I am afraid but I can't be of much help besides providing you with an pseudo code example that you'd have to adapt to fit your needs.

 
Code
Variables:
bool isTriggerBar ( false ),
double triggerBarHigh ( 0 ),
double triggerBarLow ( 0 );

//reset flag
isTriggerBar = false ;

isTriggerBar = isTriggerBar or ( All your checks for the trigger bar would have to go in here ) ;

//trigger bar detected, store values
if isTriggerBar then
begin 
    triggerBarHigh = High ;
    triggerBarLow = Low ;
end ;
This would store the high and low of each trigger bar, but it would also overwrite the values with each new trigger bar. This might be something you need to deal with - for example by not allowing the code to overwrite (you'd need to code that) the values while you are waiting to go long and then storing these values in a second variables at the moment you send the order. Please keep in mind that these are just ideas and depending on what exactly you need the code to do will not accomplish that, but it's a good start that you can adapt to your needs.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #6 (permalink)
Trading Apprentice
Port St. Lucie, FL.
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: ES
 
Posts: 22 since May 2016
Thanks: 14 given, 7 received

Reply to ABCTG Re: Future reference to Past Bar

As before, Thanks so much for your prompt reply.

Sorry for the confusion. Yes, my code below is for 'next bar' entry, but my question could apply to a second bar or third bar (I probably would not go past three bars) beyond the trigger bar where I would want to use a pre-established value (based on my Trigger Bar) as an exit.

So; to clarify:

For a Long Position, I want to store the Low of my Trigger Bar. I plan to use the "TriggerLow" value to:

a) Automatically set an exit order for a Long Position, based on the low of a previous bar

b) Automatically exit the Long position on the first tick (of the first instance) that the “TriggerLow” value is broken to the down side.

and

c) Allow the process to start fresh when I again receive my next ‘TriggerBar’.


In my feeble attempt to to code this function, I have created a variable called “triggerLow(0);” and inserted it in my Long Entry code as follows:

If Condition XX then begin Buy ( "LE" ) next bar at market;
MP = 1;
TriggerLow=Low;
End;

And, I have set-up the Long Exit code as follows:

If MarketPosition > 0 and L< (TriggerLow=Low) then begin Sell next bar at Market.
MP=0;
End;

Comments or suggestions?? I can use all the help I can get

Thanks so much. (

Reply With Quote
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,466 since Apr 2013
Thanks: 224 given, 836 received


Vientomarsol View Post
Comments or suggestions??

Vientomarsol,

you are welcome.
Does the code give you the desired result? Then my comment would be good job, well done.

To suggest anything I would need to know where the code derives from what you want it to do and what it should do instead.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #8 (permalink)
Trading Apprentice
Port St. Lucie, FL.
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: ES
 
Posts: 22 since May 2016
Thanks: 14 given, 7 received

Reply to ABCTG

ABCTG,

My apologies for not getting back to you in a timely manner.

I have been working on this exit code for over a week, and I decided to take a break and study-up on Variables before importing your code.

In you last post you stated: "This {your code} would store the high and low of each trigger bar, but it would also overwrite the values with each new trigger bar. " That is exactly what I'm looking for.

I'll set-it-up tomorrow and report back on the results.

Thanks again for your prompt response, and my apologies for not getting right on it.

I'll let you know how it shakes-out.

Respectfully,

Reply With Quote
The following user says Thank You to Vientomarsol for this post:
 
  #9 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,466 since Apr 2013
Thanks: 224 given, 836 received

Vientomarsol,

my post above was meant in regards to your post #6 in this thread as you asked for comments and suggestions in that.
One suggestion I have is that you probably would get more help from other users if you'd post actually working code. By that I don't mean reveal your exact logic, but you could for example create demonstration code that shows the same behavior that you are having trouble with or want corrected. This will not only make things a lot clearer as someone trying to help you can see exactly what you see it will also make it easier for others to help you.

Regards,

ABCTG




Vientomarsol View Post
ABCTG,

My apologies for not getting back to you in a timely manner.

I have been working on this exit code for over a week, and I decided to take a break and study-up on Variables before importing your code.

In you last post you stated: "This {your code} would store the high and low of each trigger bar, but it would also overwrite the values with each new trigger bar. " That is exactly what I'm looking for.

I'll set-it-up tomorrow and report back on the results.

Thanks again for your prompt response, and my apologies for not getting right on it.

I'll let you know how it shakes-out.

Respectfully,


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #10 (permalink)
Trading Apprentice
Port St. Lucie, FL.
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: ES
 
Posts: 22 since May 2016
Thanks: 14 given, 7 received

I'm Getting Closer!!!


Hello ABCTG,

Good News !!!!! I merged your code with mine, and it worked much better than anything I have tried thus far, but there are issues (details below) that I hope you can help me with.

My code (merged with yours) is as follows:

Variables:
MP(0),//MP = marketposition
bool isTriggerBar ( false ),
double triggerBarHigh ( 0 ),
double triggerBarLow ( 0 );

//reset flag
isTriggerBar = false ;

isTriggerBar = isTriggerBar or (Condition2 and not Condition10 ) ;

//trigger bar detected, store values
if isTriggerBar then
begin
triggerBarHigh = High ;
triggerBarLow = Low ;
end ;

//Values
Value1 = Proprietary;
Value2 = Proprietary;

//Entry Conditions

Condition2 = Value1 < -.1;
Condition3 = High > High[1];
Condition7 = Low > Low[1];
Condition8 = Low = Low[1];
Condition10=Value2>+100;

//Plots

//Long Entry
If Condition2[1] and Condition3 and (Condition7 or condition8) and not Condition10 then begin Plot1(Low, "LE",red);
MP = 1;
End;

//Long Exit on Break of Trigger Bar bottom
If MP=1 and L < triggerBarLow then begin Plot2 (Low, "LX", Cyan);
MP = 0;
End;


Description of Issues:

For the most part, the function is operating properly. The function is:
1) capturing a specific value
2) Implementing the value (as an Exit) only if MP=+1
3) Re-setting the value after each trigger bar, if MP=0

My Issues Are:
1) My exits are being made on <Entry Bar Low, not < Trigger bar Low.
2) There are instances where the exit criteria are met, but no exit was made.
3) In at least one case, an exit was made on a subsequent trigger Bar Low.
4) Late Exit.
5) Exits in places they should not be.

I have attached screen-prints of each issue (numbered per above Issue-Numbers).
ē Trigger Bars on attached screen-prints are Magenta.
ē Long Entries taken (on the basis of trigger bars) are marked by Red Dots.
ē Long Exits taken (on the basis of trigger bars) are marked by Cyan Dots.

I'm assuming I did not input your code properly. Please review and provide comments, or suggestions.
As always, I want to thank you in advance for you time and expertise.
Respectfully,

Attached Thumbnails
Future Reference to Past Bar-issues-1-2.bmp   Future Reference to Past Bar-issue-3.bmp   Future Reference to Past Bar-issues-1-4.bmp   Future Reference to Past Bar-issue-5.bmp  
Reply With Quote

Reply



futures io > > > > > Future Reference to Past Bar

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

RandBots: AutoTrading Bots to diversify your trading

Oct 24
 

TopstepTrader: Profiting Without Risking Your Own Money

Oct 26

Building Open Source Indicators for NT8 w/Fat Tails @ Lizard Indicators

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding real price of current and past ADXVMA bar SolubleFish NinjaTrader Programming 10 May 20th, 2016 03:31 PM
reference last bar (of week) yeshe NinjaTrader Programming 2 October 21st, 2014 11:23 AM
Analyzing trades: Past vs Future Big Mike Psychology and Money Management 7 October 14th, 2012 04:54 PM
reference future data in EasyLanguage? shzhning EasyLanguage Programming 9 October 4th, 2012 10:28 AM
plot axis reference for bar style SARdynamite NinjaTrader Programming 1 July 17th, 2010 06:02 AM


All times are GMT -4. The time now is 11:50 AM.

Copyright © 2017 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 2017-10-22 in 0.13 seconds with 20 queries on phoenix via your IP 54.81.131.189