Need help with simple stop/reverse strategy - EasyLanguage Programming | futures io social day trading
futures io futures trading


Need help with simple stop/reverse strategy
Updated: Views / Replies:478 / 3
Created: by flaaghara Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Need help with simple stop/reverse strategy

  #1 (permalink)
NY, NY
 
 
Posts: 1 since May 2018
Thanks: 0 given, 0 received

Need help with simple stop/reverse strategy

Hello friends. This is my first time on the forum but I have searched extensively on the internet and the forum for a sample implementation of a stop/reverse strategy in EasyLanguage but have had no luck in finding some currently usable sample code. Here is what I want to do in words:

1. I want to enter a trade either long or short at a fixed time every day, at let's say BeginTime = 0830. The direction of the entry is based on some method EnterLong() which will decide (based on a combination of indicators and daily qualitative analysis) which direction I'm entering.

2. The moment that the trade is entered, I want a fixed stop-loss in the opposite direction of let's say StopLossAmt = 0.20, with a profit target that is set every day but determined at the beginning of the day according to a static variable ProfitTargetForDay = GetProfitTarget() If the profit target is met for the day, exit the trade and stop trading for the day. If the stop loss is reached, immediately exit the trade (incurring the 0.20 loss) and enter a new trade in the same direction as the stop-loss (hence the stop & reverse strategy).

3. Once a trade is reentered in the opposite direction, the same conditions hold except the direction of the profit target and the stop loss are now opposite to what they were in the trade before.

4. Say I want a maximum of NumStops = 5 to occur during the day, after which the strategy is done excuting for the day and the 0.20 * 5 = 1.00 total loss is incurred for the day.

5. If we get to a certain time for the day at let's say EndTime = 1600 and neither the profit target has been met in any direction or the 5 stops have been hit, we immediately liquidate whatever contracts are still live, incurring either a gain or loss depending on where the ticker is relative to our last trade entry.

Also, the strategy should operate using intra-bar settings for both backtesting and live orders.

Here is my attempt:

 
Code
If (time = BeginTime AND NumStops = 0) then begin
	EntryDirection = EnterLong();
	ProfitTargetForDay = GetProfitTarget(); 

	If EntryDirection then begin
		Buy ("Long Entry") NumContracts contracts next bar at Market;
		MorningEntry = EntryPrice;
	end
	Else begin
		SellShort ("Short Entry") NumContracts contracts next bar at Market;
		MorningEntry = EntryPrice;
	end;
end;

If time = EndTime then begin
	NumStops = 0;
	If MarketPosition = 1 then
		Sell ("Long Timed Exit") NumContracts contracts next bar at Market;
	If MarketPosition = -1 then
		BuyToCover ("Short Timed Exit") NumContracts contracts next bar at Market;
end;


If (time >= BeginTime AND time < EndTime AND MarketPosition = 1 AND NumStops <= 5) then begin
	Sell ("Take Profit Long") NumContracts contracts next bar at MorningEntry + ProfitTargetForDay Limit;
	Sell ("Stop Loss Long") NumContracts contracts next bar at MorningEntry - StopLossAmt Stop;
end;

If (time >= BeginTime AND time < EndTime AND MarketPosition = -1 AND NumStops <= 5) then begin
	BuyToCover ("Take Profit Short") NumContracts contracts next bar at MorningEntry - ProfitTargetForDay Limit;
	BuyToCover ("Stop Loss Short") NumContracts contracts next bar at MorningEntry + StopLossAmt Stop;
end;

If (time >= BeginTime AND time < EndTime AND MarketPosition = 0 AND MarketPosition(1) = 1 AND ExitPrice(1) < EntryPrice(1) AND NumStops <= 5) then begin
	SellShort ("Short Reversal") NumContracts contracts next bar at Market;
	NumStops +=1;
end;

If (time >= BeginTime AND time < EndTime AND MarketPosition = 0 AND MarketPosition(1) = -1 AND ExitPrice(1) > EntryPrice(1) AND NumStops <= 5) then begin
	Buy ("Long Reversal") NumContracts contracts next bar at Market;
	NumStops +=1;
end;
It seems to work properly for some days, and then other days it goes haywire and trades way more than the number of stops that I have programmed in. I cannot figure out what is going wrong. There is probably a couple of coding errors and such throughout, so if anyone could help point out the errors it would be much appreciated. Thanks!

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Trading Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 2,081 since Apr 2013
Thanks: 372 given, 1,331 received


flaaghara,

I would suggest taking a look at the NumStops variable values using the print command or the Debugger. Check if it gets incremented when you think it should and also check its values at the moment you issue new orders.
This should tell you what is going on internally and help you to get to the problem.

Regards,

ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
 
  #4 (permalink)
Trieste Italy
 
 
Posts: 135 since Feb 2018
Thanks: 122 given, 16 received

Hello,

In some of my test I've found useful also using
 
Code
EntriesToday(date)
to check if the incremental of a value was correct (like your numStops) is working correcltly and the only way is using print command to check values...

Anyway maybe you can build your code using EntriesToday(date) and by checking the Last position profit ...

Reply With Quote

Reply



futures io > > > > > Need help with simple stop/reverse strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Show us your trading desks and win over $5,000 in prizes w/Jigsaw Trading

August
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop + Reverse steve2222 Terms (Glossary) 0 February 12th, 2016 08:36 AM
Stop and Reverse steve2222 Terms (Glossary) 0 February 12th, 2016 08:33 AM
Stop & Reverse ausstone TradeStation 8 June 12th, 2014 03:09 AM
Simple trailing stop strategy jeemba EasyLanguage Programming 2 August 2nd, 2013 07:05 AM
Stop and Reverse MWinfrey NinjaTrader Programming 2 January 25th, 2011 07:02 AM


All times are GMT -4. The time now is 12:23 PM. (this page content is cached, log in for real-time version)

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