NexusFi: Find Your Edge


Home Menu

 





Future Reference to Past Bar


Discussion in EasyLanguage Programming

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




 
Search this Thread

Future Reference to Past Bar

  #21 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9

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:	193
Size:	2.46 MB
ID:	213156  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #22 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9

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:	180
Size:	2.46 MB
ID:	213163  
Reply With Quote
  #23 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


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
Thanked by:
  #24 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9

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
Thanked by:




Last Updated on August 2, 2016


© 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