NexusFi: Find Your Edge


Home Menu

 





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 3,576 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 14 posts
    2. attach_file 0 attachments




 
Search this Thread

Retrace before reentry?

  #1 (permalink)
jrh059
Denver CO
 
Posts: 6 since Jul 2014
Thanks Given: 3
Thanks Received: 0

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

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
70 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Bigger Wins or Fewer Losses?
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
The Program
20 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628


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
  #4 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207

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

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

@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
Thanked by:
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

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
  #7 (permalink)
jrh059
Denver CO
 
Posts: 6 since Jul 2014
Thanks Given: 3
Thanks Received: 0

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
  #8 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207

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
Thanked by:
  #9 (permalink)
jrh059
Denver CO
 
Posts: 6 since Jul 2014
Thanks Given: 3
Thanks Received: 0

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
  #10 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207


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




Last Updated on April 6, 2018


© 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