NexusFi: Find Your Edge


Home Menu

 





How do I enter at a broken level one time only?


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one ReximusMaximus with 3 posts (0 thanks)
    2. looks_two numberjuani with 1 posts (2 thanks)
    3. looks_3 Germany1960 with 1 posts (1 thanks)
    4. looks_4 kjhosken with 1 posts (0 thanks)
    1. trending_up 2,141 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

How do I enter at a broken level one time only?

  #1 (permalink)
 ReximusMaximus 
SAINT LOUIS
 
Experience: Advanced
Posts: 40 since Aug 2019
Thanks Given: 7
Thanks Received: 23

I'm trying to test a strategy that buys broken pivot levels.

I have the entries working fine, but I am having a very tough time getting the code to allow one trade per setup.

I've attempted to create a variable called buyflag, and when a trade is placed I set it equal to the buy_level_one (broken pivot high). This seems to work in that it allows only one buy, and I would imagine that I'd need to create thousands of these in order to test it over time.

I'm sure there's a simpler way to do this, for example maybe reference the most recent limit price, and I can check for that when placing the trade?

I'm very new to easylanguage and have been banging my head against a wall for a while on this and thought I'd ask for help.

Here's an example of the entry code:

 
Code
//long  entry	
if
	buyflag <> buy_level_one and
	buy_level_one > 0 and
	close > buy_level_one and
	time > starttime and
	time < endtime then begin
		buy next bar tradesize contracts buy_level_one+(buffer) limit;
		buyflag = buy_level_one;
	end;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
Quantum physics & Trading dynamics
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102


ReximusMaximus View Post
I'm trying to test a strategy that buys broken pivot levels.

I have the entries working fine, but I am having a very tough time getting the code to allow one trade per setup.

I've attempted to create a variable called buyflag, and when a trade is placed I set it equal to the buy_level_one (broken pivot high). This seems to work in that it allows only one buy, and I would imagine that I'd need to create thousands of these in order to test it over time.

I'm sure there's a simpler way to do this, for example maybe reference the most recent limit price, and I can check for that when placing the trade?

I'm very new to easylanguage and have been banging my head against a wall for a while on this and thought I'd ask for help.

Here's an example of the entry code:

 
Code
//long  entry	
if
	buyflag <> buy_level_one and
	buy_level_one > 0 and
	close > buy_level_one and
	time > starttime and
	time < endtime then begin
		buy next bar tradesize contracts buy_level_one+(buffer) limit;
		buyflag = buy_level_one;
	end;

Try this before your order EntriesToday(date) = 0 if you want to only allow one trade a day and if you want to make sure its not taking the trade at the same level as before reference the previous entry price.

if EntryPrice(1) = buy_level_one then no trade!

Reply With Quote
  #3 (permalink)
 ReximusMaximus 
SAINT LOUIS
 
Experience: Advanced
Posts: 40 since Aug 2019
Thanks Given: 7
Thanks Received: 23



numberjuani View Post
Try this before your order EntriesToday(date) = 0 if you want to only allow one trade a day and if you want to make sure its not taking the trade at the same level as before reference the previous entry price.

if EntryPrice(1) = buy_level_one then no trade!

Thanks for the suggestion, I'll mess around with this. I typically do only take one trade per day with this when I trade manually.

Cool dog btw!

edit: also that entryprice reserved word also may work perfectly.

Started this thread Reply With Quote
  #4 (permalink)
Germany1960
germany
 
Posts: 4 since Nov 2019
Thanks Given: 1
Thanks Received: 2

You also can add this filter if you want to open only once a day

 
Code
//long  entry	
if
	buyflag <> buy_level_one and
	buy_level_one > 0 and
	close > buy_level_one and
	time > starttime and
        Closed_Daily <> CloseD(1) and
	time < endtime then begin
		buy next bar tradesize contracts buy_level_one+(buffer) limit;
		buyflag = buy_level_one;
                Closed_Daily = CloseD(1);

	end;

Reply With Quote
Thanked by:
  #5 (permalink)
 ReximusMaximus 
SAINT LOUIS
 
Experience: Advanced
Posts: 40 since Aug 2019
Thanks Given: 7
Thanks Received: 23

In case anyone stumbles across this thread with the same question, using entryprice worked like a charm if you're okay with multiple entries per day.

Started this thread Reply With Quote
  #6 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35

Another option if you want more than 1 trade per day, but only once at a given level might be to add a counter. (caveat, not sure the code below would work without knowing more fully how your entire code operates, so think of it conceptually more than anything)
 
Code
//long  entry	
if
	buyflag <> buy_level_one and
	buy_level_one > 0 and
	close > buy_level_one and
	time > starttime and
        Closed_Daily <> CloseD(1) and
        buy_level_one_counter = 0 and
	time < endtime then begin
		buy next bar tradesize contracts buy_level_one+(buffer) limit;
		buyflag = buy_level_one;
                Closed_Daily = CloseD(1);
                buy_level_one_counter = buy_level_one_counter [1] + 1;
	end;

Follow me on Twitter Reply With Quote




Last Updated on December 9, 2019


© 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