having trouble restricting to one trade per session - futures io
futures io futures trading



having trouble restricting to one trade per session


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one gonzofist with 3 posts (0 thanks)
    2. looks_two phantomtrader with 2 posts (2 thanks)
    3. looks_3 BlackSwan04 with 2 posts (2 thanks)
    4. looks_4 sptrader with 1 posts (1 thanks)
    1. trending_up 4,564 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 8 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
 

having trouble restricting to one trade per session

(login for full post details)
  #1 (permalink)
PORTLAND, OR
 
Experience: None
Platform: NinjaTrader
Trading: Futures
 
Posts: 185 since Jul 2011
Thanks: 74 given, 167 received

I am having trouble restricting my program to 1 trade per session. I am using it for an overnight session so a lot of the standard "per day" reserved words don't apply unfortunately. I am very new to EZL so my code is probably a little messy...

It works in restricting it to one entry but once that entry closes it opens another and usually closes it immediately since my exit conditions are still in effect and does that until the end of my session.

Below is the snippets of code that apply directly to this problem.

 
Code
if ( ( T > EndTime and T < ( StartTime + 5 ) ) = FALSE ) and ( ry_Upper10NBand <> 0 ) and ( ry_Upper20NBand <> 0 ) and ( OneADay = 0 ) and Date > 1120305 then
	begin
	if ( ry_Upper10NBand > ry_Upper20NBand ) and ( C >= ( ry_Upper10NBand + ( EnterDistance * 0.0001 ) ) ) and ( marketposition = 0 ) then
		begin
		Buy ( "NoiseLong1" ) next bar at ( ry_Upper10NBand + ( ( EnterDistance + 1 ) * 0.0001 ) ) stop ;
		OneADay = OneADay + 1 ;
		end ;
	if ( ry_Upper20NBand > ry_Lower10NBand ) and ( C >= ( ry_Upper20NBand + ( EnterDistance * 0.0001 ) ) ) and ( marketposition = 0 ) then
		begin
		Buy ( "NoiseLong2" ) next bar at ( ry_Upper20NBand + ( ( EnterDistance + 1 ) * 0.0001 ) ) stop ;
		OneADay = OneADay + 1 ;
		end ;
	end ;
and

 
Code
if T = EndTime then OneADay = 0 ;
anything you guys can do to help is much appreciated!

Visit my futures io Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
What blockvolume is visible? - order processing
NinjaTrader
Second Entry Indicator (Looking for testers/feedback)
NinjaTrader
SimplerOptions
Trading Reviews and Vendors
MACD line not plotting after change of plot order
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
109 thanks
Battlestations: Show us your trading desks!
108 thanks
Rank your Futures vs Stocks trading priority
55 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
21 thanks
 
(login for full post details)
  #3 (permalink)
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
 
sptrader's Avatar
 
Posts: 543 since Apr 2010
Thanks: 1,094 given, 696 received


When I used Tradestation several years ago, I remember they had a function called "Tradestoday" ..
So I would write : if tradestoday = 0 then begin (If I only wanted 1 trade/day)..
It's an easy way to limit the number of trades allowed per day.

Reply With Quote
The following user says Thank You to sptrader for this post:
 
(login for full post details)
  #4 (permalink)
PORTLAND, OR
 
Experience: None
Platform: NinjaTrader
Trading: Futures
 
Posts: 185 since Jul 2011
Thanks: 74 given, 167 received

Unfortunately, since my session covers multiple days ( 11:00 PM - 9:00 AM ) the tradestoday function doesn't really work for me, I haven't been able to find something similarly simple that works for session that covers multiple days.

Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Boise Idaho/US
 
 
Posts: 50 since Mar 2012
Thanks: 63 given, 60 received

I played around with Ninjatrader automated strategies for awhile. The way I would tell it to stop trading is at the beginning of the session I'd set "variable x = 0". Add an "if variable x == 0" argument to your trade premise. As part of the command that sets off the trade, also set variable x = 1. This should stop any other trades from happening until the next session.
Not sure if that's possible in tradestation but it worked for me on Ninjatrader.

Pseudocode example (All additions in Blue/be sure to scroll over to the right to see them all):
 
Code
if ( ( T > EndTime and T < ( StartTime + 5 ) ) = FALSE ) and ( ry_Upper10NBand <> 0 ) and ( ry_Upper20NBand <> 0 ) and ( OneADay = 0 ) and Date > 1120305 then
	SET VARIABLE "X=0";
        begin
	if ( ry_Upper10NBand > ry_Upper20NBand ) and ( C >= ( ry_Upper10NBand + ( EnterDistance * 0.0001 ) ) and (VARIABLE "X==0") ) and ( marketposition = 0 ) then
		begin
		Buy ( "NoiseLong1" ) next bar at ( ry_Upper10NBand + ( ( EnterDistance + 1 ) * 0.0001 ) ) stop ;
		OneADay = OneADay + 1 ;
                SET VARIABLE "X=1" ;
		end ;
	if ( ry_Upper20NBand > ry_Lower10NBand ) and ( C >= ( ry_Upper20NBand + ( EnterDistance * 0.0001 ) ) and (VARIABLE "X==0") ) and ( marketposition = 0 ) then
		begin
		Buy ( "NoiseLong2" ) next bar at ( ry_Upper20NBand + ( ( EnterDistance + 1 ) * 0.0001 ) ) stop ;
		OneADay = OneADay + 1 ;
                SET VARIABLE "X=1";
		end ;
	end ;

Reply With Quote
The following user says Thank You to BlackSwan04 for this post:
 
(login for full post details)
  #6 (permalink)
Reno, Nevada
 
Experience: Advanced
Platform: NinjaTrader
Trading: ZN, ZB, CL
 
phantomtrader's Avatar
 
Posts: 356 since May 2011
Thanks: 103 given, 613 received

Hi: I do something similar and use the following code setup:

Inputs: Time1(100), Time2(2400), Amount(1) .........


Then undernearth your variables put in:

If time >= time1 and time <= time2 then begin

If TradesToday(Date) < (amount) then
begin


It will require an "end", "end" somewhere and can be tricky - I write my codes as individual conditions and one "end" goes after the conditions and the other at the bottom after the execution trigger code. You might have to play with the placement of "end" if it doesn't trigger.

You would have to remove your "StartTime" code to use this or it will conflict.

This should trigger a single trade per day within a 24 hour period.

Let me know if it works.

Reply With Quote
The following user says Thank You to phantomtrader for this post:
 
(login for full post details)
  #7 (permalink)
PORTLAND, OR
 
Experience: None
Platform: NinjaTrader
Trading: Futures
 
Posts: 185 since Jul 2011
Thanks: 74 given, 167 received

BlackSwan :Thanks for the help, this is essentially what my code is already attempting to do. The "OneADay" variable is intended to stop the "if" statement from executing. My placement within the code is slightly different than what you suggest here so I'll give it a try in the spot you have it and see how it goes.

Phantomtrader : I really like this way of doing it and will attempt to apply it to my code, I'm trying to think of a way to restrict my trades to the 11:00 PM to 9:00 AM (PST) custom session and still use your 1 trade every 24 hours code.

Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #8 (permalink)
Reno, Nevada
 
Experience: Advanced
Platform: NinjaTrader
Trading: ZN, ZB, CL
 
phantomtrader's Avatar
 
Posts: 356 since May 2011
Thanks: 103 given, 613 received


gonzofist View Post
BlackSwan :Thanks for the help, this is essentially what my code is already attempting to do. The "OneADay" variable is intended to stop the "if" statement from executing. My placement within the code is slightly different than what you suggest here so I'll give it a try in the spot you have it and see how it goes.

Phantomtrader : I really like this way of doing it and will attempt to apply it to my code, I'm trying to think of a way to restrict my trades to the 11:00 PM to 9:00 AM (PST) custom session and still use your 1 trade every 24 hours code.

I may have an idea about that - let me look in my code library and I'll get back to you.

Reply With Quote
The following user says Thank You to phantomtrader for this post:
 
(login for full post details)
  #9 (permalink)
Boise Idaho/US
 
 
Posts: 50 since Mar 2012
Thanks: 63 given, 60 received


gonzofist View Post
BlackSwan :Thanks for the help, this is essentially what my code is already attempting to do. The "OneADay" variable is intended to stop the "if" statement from executing. My placement within the code is slightly different than what you suggest here so I'll give it a try in the spot you have it and see how it goes.

Phantomtrader : I really like this way of doing it and will attempt to apply it to my code, I'm trying to think of a way to restrict my trades to the 11:00 PM to 9:00 AM (PST) custom session and still use your 1 trade every 24 hours code.

Hi Gonzofist,

If the OneADay feature restricts 1 trade to a 24 hour period, you may run into missing a setup in the next session, say if your trade goes off at 12:30am, and your next signal hits the next night at 12:15 it could conceivably skip it since it would still have 15 more minutes on its "clock".
Just speculating. I have no experience with trade station and the little experience I have with Ninja automated was more for backtesting than anything else.
Backstory: I was looking for a mechanical strategy that I could manually trade, so I had a pretty tight session limit (12am - 2am at the time). However, I had to have bars on the chart before the session so that the indicators would work. As I wasn't limiting my trades to 1 a day but configuring to have them not trade outside those hours, that variable did the trick.
That said, good luck in your search. The automated road is a hard one.

Regards,
BlackSwan

Reply With Quote
The following user says Thank You to BlackSwan04 for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > having trouble restricting to one trade per session


Last Updated on January 18, 2013


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



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