Future Reference to Past Bar - futures io
futures io futures trading



Future Reference to Past Bar


Discussion in EasyLanguage Programming

Updated
    1. trending_up 7,231 views
    2. thumb_up 16 thanks given
    3. group 3 followers
    1. forum 23 posts
    2. attach_file 11 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Future Reference to Past Bar

(login for full post details)
  #1 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

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
Click image for larger version

Name:	Future Reference to a Past Bar.bmp
Views:	93
Size:	1.84 MB
ID:	212212  
Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(152 thanks from 29 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(110 thanks from 31 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 15 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 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

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #4 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

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
 
(login for full post details)
  #5 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 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

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #6 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

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
 
(login for full post details)
  #7 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 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

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #8 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

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:
 
(login for full post details)
  #9 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 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,


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #10 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received


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
Click image for larger version

Name:	Issues 1 and 2.bmp
Views:	94
Size:	2.47 MB
ID:	212360   Click image for larger version

Name:	Issue 3.bmp
Views:	60
Size:	2.47 MB
ID:	212361   Click image for larger version

Name:	Issues 1 and 4.bmp
Views:	46
Size:	2.47 MB
ID:	212362   Click image for larger version

Name:	Issue 5.bmp
Views:	42
Size:	2.47 MB
ID:	212363  
Reply With Quote
 
(login for full post details)
  #11 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Vientomarsol,

I am afraid your code wouldn't compile (as it contains pseudo code) and to properly debug it one would most likely need a working version (where you could exchange the proprietary parts to something open source, as long as same the problems stay apparent).

You might want to print the values your code generates and check what values were used exactly at the bars that "appear" problematic".

You wrote "In at least one case, an exit was made on a subsequent trigger Bar Low.". If I understand you correctly this is exactly what I meant here. Did you try the suggestion I gave you to avoid that?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #12 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

Hello ABCTG,

I was afraid my pseudo code might 'queer the deal'. My Values 1 and 2 are purchased indicators that contain a password in the values themselves, so I can't post them on a public forum.

I have an idea. Let me rewrite my code using Larry Williams' famous "Naked Bottom' as my trigger bar. Larry has been gracious enough to release this indicator to the public, so I can upload his code without fear. (and give him a plug).

I'll run the Naked Bottom Trigger System (and use your code to store the values) and see what I get. I'll post the results this afternoon.

I'm hoping you will be kind enough take a look at those results, and provide specific comments and suggestions..

Again, thanks sooo much for hanging with me, and trying to 'show me the way'. I'll have the updated results up by EOD today.

Respectfully,

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

Greetings ABCTG,

I’m happy to report that I've updated my code to use Larry Williams’ “NAKED BOTTOM” indicator as my Trigger Bar, and with one [hopefully] minor exception, it works!!!

Here is the code:
Var:
MP(0),//MP = marketposition
bool isTriggerBar ( false ),
double triggerBarHigh ( 0 ),
double triggerBarLow ( 0 );

//reset flag
isTriggerBar = false ;

isTriggerBar = isTriggerBar or Condition1;

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

//Naked Btm Condition
Condition1 = C[1]<L[2] and C>H[1];

//Filter Conditions
Condition2 = High > High[1];
Condition3 = Low > Low[1];
Condition4 = Low = Low[1];

//Plots
//Naked Btm TriggerBar
If Condition1 then Plot1(Low - .25, "Nkd_Btm", red);

//Long Entry
If Condition1[1] {previous bar = Naked Btm} and Condition2 {this bar = Higher High than Naked Btm}
and (Condition3 or condition4) {this bar = Low =/> Naked Btm} then begin Plot2 (Low - .25, "LE", White);
MP = 1;
End;

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

WHAT IS WORKING:

When using “NAKED BOTTOM” as Condition1, the following sequence is expected:

A. Long entry (MP=1) is initiated via:
o Condition1[1] and Condition2 and (Condition3 or condition4)

And then:

B. An exit is initiated via:
o MP=1 and L < Condition1

The above code works flawlessly in all cases but one. The exception is as follows:

WHAT IS NOT WORKING:


C. Long entry (MP=1) is initiated via:
o Condition1[1] and Condition2 and (Condition3 or condition4)

And then:

D. A second Condition1 (Trigger Bar) plots without conditions 2, 3, or 4 and no entry is initiated

And then:

E. An exit is initiated on < Low of item D (above) rather than item B (above).

Examples of Item D exits are circled on attached screen-prints.

QUESTIONS:

1. Do why know why I'm exiting on < Low of item D (above) rather than item B (above)?

2. Do you know how to revise my code so this will not happen?


As always, I'm mucho appreciative of your help.

You're a very smart guy, and have shown me EL functions which I did not know were possible.

Again, Thanks!!

Attached Thumbnails
Click image for larger version

Name:	BitMap#1.bmp
Views:	44
Size:	2.47 MB
ID:	212393   Click image for larger version

Name:	BitMap#2.bmp
Views:	42
Size:	2.47 MB
ID:	212394   Click image for larger version

Name:	BitMap#3.bmp
Views:	35
Size:	2.47 MB
ID:	212395   Click image for larger version

Name:	BitMap#4.bmp
Views:	31
Size:	2.47 MB
ID:	212396  
Reply With Quote
 
(login for full post details)
  #14 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Vientomarsol,

EasyLanguage code is evaluated from top to bottom (unless you use methods, which you don't). If you use a variable or condition before you evaluate it in your code, you will use the previous bar's (or code execution's) value for it.

I would strongly suggest to use the Print command or the plot reserved words in your debugging, to actually see what values a variable in your code holds at the very moment, when it gets updated etc..

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #15 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

ABCTG,

I don't know how to use the Print command, or the plot reserved words in your debugging, but I'll figure it out and post my results.

Thanks again for your prompt reply.

Reply With Quote
 
(login for full post details)
  #16 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Vientomarsol,

you are already using "Plot" in your code. Plots are a great way to visualize what is going on in your code when trying to track problems down.

Look the "print" reserved word up in the editor's help - for example by writing print in your code, highlighting it and pressing F1. This will bring up the online help and give you ideas on how to use it. With that you can print values at certain times or continuously to the output log - this is a great way to keep track on what is going on in your code.

Regards,

ABCTG




Vientomarsol View Post
ABCTG,

I don't know how to use the Print command, or the plot reserved words in your debugging, but I'll figure it out and post my results.

Thanks again for your prompt reply.


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #17 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

ABCTG,

Yes, I have figured out how to use the plot function to verify my code prior to exporting to a strategy, but I'm not familiar with the print (Parameter) function.

I just read the Tradestation EL description of 'Print (Parameter)' function, and (to me anyway) it may as well be written in Chinese.

Could you give me an example of how this function would be coded to print the sequence of my code (or part of the code)?

Thanks

Reply With Quote
 
(login for full post details)
  #18 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Vientomarsol,

the examples Tradestation provides in their help (at least for the print) are quite good actually and cover everything you need to know. In your case I'd start with checking what values are stored for the trigger bar and more important when they are stored.

 
Code
//trigger bar detected, store values
if isTriggerBar then
begin
triggerBarHigh = High[1] ;
triggerBarLow = Low[1] ;
Print( ElDateToString( Date ), "; Time: ", Time:0:0, "; triggerBarHigh: ", triggerBarHigh, "; triggerBarLow: ", triggerBarLow ) ;
end ;
The print statement will go to Tradestation's Print Log tab in the main window. If you don't see it, you will have to enable it under -> View -> EasyLanguage Print Log.

This, together with using Plots to display values on the chart, should give you a good start to find out yourself what is going on in your code.

Regards,

ABCTG


Vientomarsol View Post
ABCTG,

Yes, I have figured out how to use the plot function to verify my code prior to exporting to a strategy, but I'm not familiar with the print (Parameter) function.

I just read the Tradestation EL description of 'Print (Parameter)' function, and (to me anyway) it may as well be written in Chinese.

Could you give me an example of how this function would be coded to print the sequence of my code (or part of the code)?

Thanks


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #19 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

ABCTG,

You code was exactly what I needed. I plugged it in, and it is outputting to my PrintLog as I write this.
I'll keep an eye on the print output today, and see if I can define my glitch.



I'm humbled by your generosity.
Again, thanks so much. I'll report back on my findings.

Reply With Quote
The following 2 users say Thank You to Vientomarsol for this post:
 
(login for full post details)
  #20 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Vientomarsol,

you are welcome and thank you for your kind words.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #21 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

Hello ABGT,

Sorry to bug you again but I have a glitch in my TradeStation ‘Naked Bottom” system which didn’t show-up right away. I have been working on a solution for over a week, and I finally run-out of ideas.

As discussed in our earlier correspondence; my ‘Naked Bottom” exit strategy (for a Long trade) is intended to trigger a Sell when price is < Entry Low [1]. In other words: Sell on a break of the low of the ‘Bar-Before-Entry’.

The code you helped me develop performs as intended except for one flaw.

As indicated on attached Barchart of my ‘Naked Bottom” system, the intended system sequence is as follows:
1. Market Position is MP=0 (Blue Dots on chart) until Entry Signal #1 is received.

2. Entry Signal #1 is received (Red Dot on chart) which initiates MP = 1 (Yellow Dots on chart) and signals a Long Trade.

3. Entry Signal #2 (Red Dot) is received and will continue with the original trade (Still MP = 1), but is expected to re-set the ‘Exit Trigger’ to < Entry Low [1] of Entry #2.

Note: In the case of Entry #2, the < Entry Low [1] of Entry #2 was not breached, and no exit was made (as was expected).

4. Entry Signal #3 (Red Dot) is received and continues the original trade (Still MP = 1), and (as discussed in Item 3 above) the ‘Exit Trigger’ is expected to be re-set to < Entry Low [1] of Entry #3.

Note: In the case of Entry #3, the < Entry Low [1] was breached, but no exit was made. Instead; many bars later, the actual exit (Green Dot) was made on the basis of < Entry Low [1] of Entry #1 (not Entry #3), whereupon Market Position was returned to MP=0 (Blue Dots on chart)

Question / Comment:
• How may I code my ‘Exit Trigger’ to re-calculate to the < Entry Low [1] for each succeeding Entry Signal, rather than the < Entry Low [1] of my initial entry?

Note: I do understand that a re-set depends on the Market Position reverting back to MP=0, when each new Entry Signal populates, but I cannot figure out how to make that happen.
My Indicator Code for attached BarChart is as follows:
Var:
MP(0),//MP = marketposition
BuyCondition (False),
bool NakedBtm ( false ),
double NakedBtmLow ( 0 );

//reset flag
NakedBtm = false ;
NakedBtm = NakedBtm or Condition1 and MP=0;

//trigger bar detected, store values
if NakedBtm then
begin
NakedBtmLow = Low[1];
end;

//Naked Btm Condition
Condition1 = C[1]<L[2] and C>H[1];

//Filter Conditions
Condition2 = High > High[1];
Condition3 = Low > Low[1];
Condition4 = Low = Low[1];

//Buy Condition
BuyCondition = Condition1[1] and Condition2 and Condition3 or Condition4;

//Plots

//Long Entry
If BuyCondition then begin Plot2 (Low - .25, "LE", Red);
MP = 1;
End;

//Long Exit on Break of Trigger Bar bottom
If MP=1 and L < NakedBtmLow then begin Plot3(Low - .25, "LX", Green);
MP = 0;
END;

If MP=0 then Plot10 (HIGH + .75,"MP=0", blue);

If MP=1 then Plot11 (HIGH + .75,"MP=1", yellow);

As always, thank you sooo much for your expert guidance.

Attached Thumbnails
Click image for larger version

Name:	Back To GURU.bmp
Views:	49
Size:	2.46 MB
ID:	213156  
Reply With Quote
 
(login for full post details)
  #22 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

Hello ABGT,

Sorry to bug you again but I have a glitch in my TradeStation ‘Naked Bottom” system which didn’t show-up right away. I have been working on a solution for over a week, and I finally run-out of ideas.

As discussed in our earlier correspondence; my ‘Naked Bottom” exit strategy (for a Long trade) is intended to trigger a Sell when price is < Entry Low [1]. In other words: Sell on a break of the low of the ‘Bar-Before-Entry’.

The code you helped me develop performs as intended except for one flaw.

As indicated on attached Barchart of my ‘Naked Bottom” system, the intended system sequence is as follows:
1. Market Position is MP=0 (Blue Dots on chart) until Entry Signal #1 is received.

2. Entry Signal #1 is received (Red Dot on chart) which initiates MP = 1 (Yellow Dots on chart) and signals a Long Trade.

3. Entry Signal #2 (Red Dot) is received and will continue with the original trade (Still MP = 1), but is expected to re-set the ‘Exit Trigger’ to < Entry Low [1] of Entry #2.

Note: In the case of Entry #2, the < Entry Low [1] of Entry #2 was not breached, and no exit was made (as was expected).

4. Entry Signal #3 (Red Dot) is received and continues the original trade (Still MP = 1), and (as discussed in Item 3 above) the ‘Exit Trigger’ is expected to be re-set to < Entry Low [1] of Entry #3.

Note: In the case of Entry #3, the < Entry Low [1] was breached, but no exit was made. Instead; many bars later, the actual exit (Green Dot) was made on the basis of < Entry Low [1] of Entry #1 (not Entry #3), whereupon Market Position was returned to MP=0 (Blue Dots on chart)

Question / Comment:
• How may I code my ‘Exit Trigger’ to re-calculate to the < Entry Low [1] for each succeeding Entry Signal, rather than the < Entry Low [1] of my initial entry?

Note: I do understand that a re-set depends on the Market Position reverting back to MP=0, when each new Entry Signal populates, but I cannot figure out how to make that happen.
My Indicator Code for attached BarChart is as follows:
Var:
MP(0),//MP = marketposition
BuyCondition (False),
bool NakedBtm ( false ),
double NakedBtmLow ( 0 );

//reset flag
NakedBtm = false ;
NakedBtm = NakedBtm or Condition1 and MP=0;

//trigger bar detected, store values
if NakedBtm then
begin
NakedBtmLow = Low[1];
end;

//Naked Btm Condition
Condition1 = C[1]<L[2] and C>H[1];

//Filter Conditions
Condition2 = High > High[1];
Condition3 = Low > Low[1];
Condition4 = Low = Low[1];

//Buy Condition
BuyCondition = Condition1[1] and Condition2 and Condition3 or Condition4;

//Plots

//Long Entry
If BuyCondition then begin Plot2 (Low - .25, "LE", Red);
MP = 1;
End;

//Long Exit on Break of Trigger Bar bottom
If MP=1 and L < NakedBtmLow then begin Plot3(Low - .25, "LX", Green);
MP = 0;
END;

If MP=0 then Plot10 (HIGH + .75,"MP=0", blue);

If MP=1 then Plot11 (HIGH + .75,"MP=1", yellow);

As always, thank you sooo much for your expert guidance.

Attached Thumbnails
Click image for larger version

Name:	Back To GURU.bmp
Views:	39
Size:	2.46 MB
ID:	213163  
Reply With Quote
 
(login for full post details)
  #23 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Vientomarsol,

if I understand you correctly the problem you are facing spans from two things:

1. You need multiple different entries with each using its own stop value.
2. You only allow the stop value to be updated when you are flat.

You will most likely have to look into loops and arrays or use a list to accomplish what you want, be more convenient (although this would be a lot more complex due to the OOEL nature, though).

You basically need to update the NakedBtmLow every time the condition is met, but regardless of the market position. Then upon an entry signal store the current NakedBtmLow value in the list or array.
When you are currently in a position you have to loop through your list or array to check if the current price stopped any of your entries out, then you can remove this particular NakedBtmLow value from the list or array. This last part is where a list is more handy than the array for your problem, as removing entries is slightly simpler with lists (as you can simply shrink the list with removing entries, where the array would keep it's size and you'd manage the indices that have values within the array yourself).

This is definitely doable, but a bit more complex.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #24 (permalink)
Port St. Lucie, FL.
 
 
Posts: 25 since May 2016
Thanks: 17 given, 8 received

ABCTG,

Thanks (as always) for your prompt response.

I knew there must be a tool I was missing, and OOEL is apparently it.
Looks like I’ve got my work cut-out for me, but I can imagine that OOEL will be a useful tool for future projects.

Again, thanks.


Respectfully,

Vientomarsol

Reply With Quote
The following user says Thank You to Vientomarsol for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Future Reference to Past Bar


Last Updated on August 2, 2016


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Identifying Setups & Targets Using Profile Charts w/Trevor & Tradovate

Feb 25
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
     



Copyright © 2021 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