NexusFi: Find Your Edge


Home Menu

 





Trade Restriction for Certain Time Period After Stopping Out


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,627 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Trade Restriction for Certain Time Period After Stopping Out

  #1 (permalink)
 el oso 
Jersey City, NJ, USA
 
Experience: Intermediate
Platform: MultiCharts, IB
Trading: ES
Posts: 4 since May 2015
Thanks Given: 1
Thanks Received: 3

Hi all,

First post here! I am trying to write a piece of EasyLanguage code intended for risk mitigation in my automated strategy, and I'm stumped. What I'm trying to do is: If a stop order is executed, I would like to have a "blackout period" during which no trade entries in that same direction will be made.

For example, say I am using a 15-min chart and my strategy is long 3 ES contracts. Then, the price drops and triggers my stop loss order for the 3 contracts, so I am now flat. I would like the strategy to not be permitted to enter into any new long positions for the next hour.

I think the best way to do this would be to have a condition that evaluates to "true" if the strategy has been stopped out of a long trade in the past hour, and have the "new orders" command be conditional on that condition being "false".

However, I have not been able to figure out a way to check if a stop order has been triggered in the past hour (and if there is a way to determine this, how to differentiate between a "sell" stop order and a "buy to cover" stop order).

Please let me know if you have encountered a similar problem before or know of a solution.

Thank you!
el oso

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
VFC turning around or continuing to fall?
Stocks and ETFs
Exit Strategy
NinjaTrader
Any futures traders in Texas looking to give back to tho …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
My NQ Trading Journal
24 thanks
Diary of a simple price action trader
20 thanks
Just another trading journal: PA, Wyckoff & Trends
12 thanks
Coding money management strategies.
11 thanks
Daytrading ES & NQ
9 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,626


el oso,

welcome to the forum. Can you post the code you have written so far? This might make it easier to steer you in the right direction.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,626

el oso,

sorry for the confusion, I wasn't interested in your whole strategy, only the part you did so far for the feature you are asking for.
I would try something along the lines of this:

- use a boolean variable that you check before you enter long (something like "newLongsAllowed" for example)
- when the market position changes from long to short/flat, check if the trade was a loser and was exited at your stop price
- if this is the case set the variable newLongsAllowed to false and store the time of the bar in a second variable
- the last thing to do is check if the time of the current bar is later than the stored time + 1 hour
- at that moment you set the newLongsAllowed back to true so the system can take a new long entry

This should get you going.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
 el oso 
Jersey City, NJ, USA
 
Experience: Intermediate
Platform: MultiCharts, IB
Trading: ES
Posts: 4 since May 2015
Thanks Given: 1
Thanks Received: 3


ABCTG View Post
el oso,

sorry for the confusion, I wasn't interested in your whole strategy, only the part you did so far for the feature you are asking for.
I would try something along the lines of this:

- use a boolean variable that you check before you enter long (something like "newLongsAllowed" for example)
- when the market position changes from long to short/flat, check if the trade was a loser and was exited at your stop price
- if this is the case set the variable newLongsAllowed to false and store the time of the bar in a second variable
- the last thing to do is check if the time of the current bar is later than the stored time + 1 hour
- at that moment you set the newLongsAllowed back to true so the system can take a new long entry

This should get you going.

Regards,
ABCTG

Thank you, ABCTG! This is very helpful, and I will try it out. Yeah, I had not written any code yet for this feature, as I was not sure where to start / what is possible, so this is what I was looking for.

Started this thread Reply With Quote




Last Updated on July 23, 2015


© 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