Retrace before reentry? - futures io
futures io futures trading



Retrace before reentry?


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one jrh059 with 6 posts (0 thanks)
    2. looks_two SMCJB with 4 posts (2 thanks)
    3. looks_3 ABCTG with 4 posts (3 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,689 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 14 posts
    2. attach_file 0 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
 

Retrace before reentry?

(login for full post details)
  #1 (permalink)
Denver CO
 
 
Posts: 6 since Jul 2014
Thanks: 3 given, 0 received

I've been stuck on this problem for awhile and wondering if there is a simple solution.

I am using SetStopLoss to exit a position (say 20 ticks) but only want to re-enter a position if price has gone against the original entry price by at least 40 ticks at some point between my SetStopLoss exit and the next entry.

any suggestions?

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


jrh059,

we could try to point you in the right direction when you post the code you are stuck with.
One idea would be using a flag that you use to only allow another entry in case the market moved X points higher than your exit price.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #4 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 3,964 since Dec 2013
Thanks: 3,254 given, 7,760 received

Maybe a noob question @ABCTG but how do you know what your exit price was?

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

@SMCJB,

you can access the exit price via the reserved word ExitPrice. This will work fine, unless you scale in and out of positions. In this case you can access the respective prices using the StrategyHost class.

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)
  #6 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

The same way the entry price is accessible via the reserved word EntryPrice. @jrh059 you can use this to only allow a new entry when you are flat and if the current price is X ticks above the last entry price.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #7 (permalink)
Denver CO
 
 
Posts: 6 since Jul 2014
Thanks: 3 given, 0 received

Thank you for your response.

To clear up any confusion, once I am stopped out of a long position, I want price to go LOWER than where I was stopped out before taking another entry.

The code I am currently trying is as follows:

Var:
bool LongFalseStop(False);

If ExitPrice(1)<=EntryPrice(1)-.20 and Lowest(Low,BarsSinceExit(1))<=EntryPrice(1)-.40 then
LongFalseStop=True;

If LongFalseStop=True then Buy

Using the print function, I can tell that this should work but the problem is that I can't figure out how to initiate the first entry without setting the LongFalseStop Variable to TRUE in the beginning, at which point the code doesnt work.

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 3,964 since Dec 2013
Thanks: 3,254 given, 7,760 received

entryprice is zero until you have your first trade

 
Code
Var:
   bool LongFalseStop(False);

if entryprice = 0 then
   first trade condition
else begin
   If ExitPrice(1)<=EntryPrice(1)-.20 and Lowest(Low,BarsSinceExit(1))<=EntryPrice(1)-.40 then LongFalseStop=True;
   If LongFalseStop=True then Buy
end;

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
(login for full post details)
  #9 (permalink)
Denver CO
 
 
Posts: 6 since Jul 2014
Thanks: 3 given, 0 received

Thank you! That did work. However, now it seems that the LongFalseStop stays True for every bar following the first bar that it is True, making it ineffective because there is never a False condition. Is there a way to make it reset or reevaluate each bar?

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 3,964 since Dec 2013
Thanks: 3,254 given, 7,760 received


Just set it to false on every bar or my preference is to

 
Code
If ( (ExitPrice(1) <= EntryPrice(1) - 0.20) and (Lowest(Low, BarsSinceExit(1)) <= EntryPrice(1) - 0.40) ) then
   LongFalseStop = True else LongFalseStop = False;

Reply With Quote
 
(login for full post details)
  #11 (permalink)
Denver CO
 
 
Posts: 6 since Jul 2014
Thanks: 3 given, 0 received

Yeah, I tried that and it gives me a max bars back error which doesn't make sense to me.

Reply With Quote
 
(login for full post details)
  #12 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 3,964 since Dec 2013
Thanks: 3,254 given, 7,760 received

That's because of
 
Code
Lowest(Low, BarsSinceExit(1))

If barssinceexit > max bars back you'll get that error. I get around this problem (normally with barssinceentry) by using
 
Code
Lowest( Low, minlist(99, BarsSinceExit(1)) )

But obviously change 99 to whatever you need, it has to be less than your max bars back setting though.

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
(login for full post details)
  #13 (permalink)
Denver CO
 
 
Posts: 6 since Jul 2014
Thanks: 3 given, 0 received

Yes, that part of the code is what's causing the error, but looking at the chart bar by bar, it should never be reaching my max bars back setting. There's something else in there jacking it up. When I reset the LongFalseStop to False, it will work for a few bars and then get stuck on false for the rest of the bars, causing no more entries to happen....hence the max bars back error.

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

jrh059,

you could track the lowest low yourself with a variable.

 
Code
if Low < trackLow then
    trackLow = Low ;
Assuming "trackLow" is the variable you created. After every exit you would simply reset it to the Low of the bar following your exit and from then on it will track any lower low.

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)
Denver CO
 
 
Posts: 6 since Jul 2014
Thanks: 3 given, 0 received

SO MANY THANKS TO YOU GUYS! Your help is very much appreciated! I have implemented elements of both of your advice and it is now working perfectly!

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Retrace before reentry?


Last Updated on April 6, 2018


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