Trouble with buy code. Help/Ideas? - EasyLanguage Programming | futures io social day trading
futures io futures trading


Trouble with buy code. Help/Ideas?
Updated: Views / Replies:1,469 / 20
Created: by Dallasboy Attachments:5

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 90,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
 5  
 
Thread Tools Search this Thread
 

Trouble with buy code. Help/Ideas?

  #1 (permalink)
Trading Apprentice
dallas texas
 
Futures Experience: Advanced
Platform: NinjaTrader, Ensign, MC
Favorite Futures: ES
 
Posts: 13 since Jan 2016
Thanks: 6 given, 2 received

Trouble with buy code. Help/Ideas?

Hi all!

So I am trying to figure out a problem with this simple buy code. First of all, this is a strategy that uses the zig zag and retrace points to setup an entry. Entering on a pivot from the highest low....but the problem is with the executing code.

In the charts, bar 1 is the highest low, with bar 2 completing a zigzag (pullback) based on a user defined retrace points/pips. Once that condition sets up, any bar after that should buy at low of bar 1 (also the cyan horizontal line). Here is the code:

if MP <> 0 or TT[1] < TT then BuyBelow = 0;
if BuyBelow > 0 and BuyBelow - low >= retracepnts then Buy Size Contracts next bar at BuyBelow stop;
end;

So BuyBelow is the low of bar 1. Fairly simple stuff. As you can see in chart 1 (current.jpg) it does not trigger like it should on bar 3, but will on the next bar. This only happens when a setup completes the zigzag and triggers the next bar....for some reason it waits one more bar. Otherwise, the code works (more than one bar after setup before a trigger).

So, I made [IntraBarOrderGeneration = true] and now it seems to work (chart 2). It buys at that pivot low, but that is not what I want for other situations. So I am stuck...maybe something to do with BarStatus, but I can't figure it out.

Hope this is not too confusing. According to my code, if the condition is true (it is after bar 2), then if it triggers bar 3 it should be no problem from my reading of the code. Again, it works fine when there are more than 1 bar after a setup. In fact I'll post a chart of that too (charts 3 (working.jpg)) to show.

Thanks for any help!

Attached Thumbnails
Trouble with buy code.  Help/Ideas?-current.jpg   Trouble with buy code.  Help/Ideas?-iogtrue.jpg   Trouble with buy code.  Help/Ideas?-working.jpg  
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)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary


Dallasboy,

from your screenshots it appears that the buy condition is fulfilled on the bar after bar 2. Without intrabar order generation the code is evaluated at the end of the bar. Then the order is send for the next bar - which seems to be what happens in the first screenshot. With IOG enabled the code can be executed intrabar and the order is send at the moment the conditions are fulfilled.

There are not too many options - either find a way to have your order send on the bar before the entry would occur (this will likely be problematic or impossible) or use IOG and make sure that the orders that you don't want to get filled intrabar will only send at the end of a bar.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #4 (permalink)
Trading Apprentice
dallas texas
 
Futures Experience: Advanced
Platform: NinjaTrader, Ensign, MC
Favorite Futures: ES
 
Posts: 13 since Jan 2016
Thanks: 6 given, 2 received

Hi ABCTG,

Thanks for your reply! I see what you are saying, but I am trying to get my brain wrapped around this. I'm not an expert at EL, but better than a newbie ;-).

My issue seems that at the close of bar 2 (in picture one), all the conditions are met (we have the highest low (bar 1) established now by the zigzag down (bar 2)), thus I can't understand why or how the code wouldn't be ready to buy the "BuyBelow" point starting at the opening of bar 3 (if it hits the trigger point). Again, this is only problematic when a highest low is established (1) by a zigzag down(2) then triggers immediately on the next bar(3)...which is about 15% of the time.

If you have any other insights, I would be greatly appreciated.....going to dig/study more on the problem

Reply With Quote
 
  #5 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Dallasboy,

you are welcome. It's hard to tell what is going on with having only the small code snippet that doesn't give a clue about the values for all variables. However if you are using the build in zig zags or one that relies on the pivot function and using it's values, I am almost certain that it's impossible to get the low of point 2 at the close of that bar.
These functions work in a way that they only fix a swing point after a sufficient move in the opposite direction.

Regards,

ABCTG

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
dallas texas
 
Futures Experience: Advanced
Platform: NinjaTrader, Ensign, MC
Favorite Futures: ES
 
Posts: 13 since Jan 2016
Thanks: 6 given, 2 received


ABCTG View Post
Dallasboy,

you are welcome. It's hard to tell what is going on with having only the small code snippet that doesn't give a clue about the values for all variables. However if you are using the build in zig zags or one that relies on the pivot function and using it's values, I am almost certain that it's impossible to get the low of point 2 at the close of that bar.
These functions work in a way that they only fix a swing point after a sufficient move in the opposite direction.

Regards,

ABCTG

I'll post the code in drawing the zigzag/swing TL that may help. But is there an easier way to post code instead of copying and pasting? Like a [/code] function?

Reply With Quote
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Dallasboy,

if it's the standard code or uses the pivot function (which the swing high, swing low and many others do, too), then there is no need for that, as you will likely receive the value with a delay. That might explain the delay you are seeing, too.

You can wrap CODE tags around code to make it easier to read, but you'd still have to copy and paste it.

Regards,

ABCTG


Dallasboy View Post
I'll post the code in drawing the zigzag/swing TL that may help. But is there an easier way to post code instead of copying and pasting? Like a [/code] function?


Reply With Quote
 
  #8 (permalink)
Trading Apprentice
dallas texas
 
Futures Experience: Advanced
Platform: NinjaTrader, Ensign, MC
Favorite Futures: ES
 
Posts: 13 since Jan 2016
Thanks: 6 given, 2 received

Hi ABCTG,

Below is the code on drawing the trend lines for the zigzag/pivot and how "BuyBelow" is established. Yes, I agree there seems to be that one bar delay, but maybe you can see something I can't.

Price = Low
RetracePnts is user defined....say 5 points.

 
Code
{ Candidate swings are just-confirmed, 3-bar (Str=1), SwingHi's and SwingLo's}

NewSwingPrice = SwingHigh (1, Price, 1, 2) ;
if NewSwingPrice <> -1 then
	begin
	if TLDir <= 0 and NewSwingPrice >= SwingPrice + RetracePnts then
		{ prepare to add new up TL }
		begin
		SaveSwing = true ;
		AddTL = true ;
		TLDir = 1;
		buybelow=NewSwingPrice;;
		end
	else if TLDir = 1 and NewSwingPrice >= SwingPrice then
		{ prepare to update prev up TL }
		begin
		SaveSwing = true ;
		UpdateTL = true ;
		BuyBelow=NewSwingPrice;
		end;
	end
else
	begin
	NewSwingPrice = SwingLow (1, Price, 1, 2) ;
	if NewSwingPrice <> -1 then
		begin
		if TLDir >= 0 and NewSwingPrice <= SwingPrice - RetracePnts then
			{ prepare to add new dn TL }
			begin
			SaveSwing = true ;
			AddTL = true ;
			TLDir = -1;
			end
		else if TLDir = -1 and NewSwingPrice <= SwingPrice then
			{prepare to update prev dn TL }
			begin
			SaveSwing = true;
			UpdateTL = true;
			end;
		end;
Any other suggestions or insight would be greatly appreciated.

Thanks!


Last edited by Dallasboy; June 21st, 2016 at 12:19 PM. Reason: edit
Reply With Quote
The following user says Thank You to Dallasboy for this post:
 
  #9 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Dallasboy,

you can check when the zig zag updates using market replay for example. This will show you how "late" it actually is in realtime, compared to what it looks like on a historical chart. This might give you some ideas about how to change the logic with something else. In my opinion using these functions you'll have to live with the delay. One work around would be to create your own custom zig zag that is able to detect swing points in realtime, but this might have other disadvantages (like more development time and "false" entries when you act on non confirmed swing points).

Regards,

ABCTG

Reply With Quote
 
  #10 (permalink)
Trading Apprentice
dallas texas
 
Futures Experience: Advanced
Platform: NinjaTrader, Ensign, MC
Favorite Futures: ES
 
Posts: 13 since Jan 2016
Thanks: 6 given, 2 received



ABCTG View Post
Dallasboy,

you can check when the zig zag updates using market replay for example. This will show you how "late" it actually is in realtime, compared to what it looks like on a historical chart. This might give you some ideas about how to change the logic with something else. In my opinion using these functions you'll have to live with the delay. One work around would be to create your own custom zig zag that is able to detect swing points in realtime, but this might have other disadvantages (like more development time and "false" entries when you act on non confirmed swing points).

Regards,

ABCTG

Thanks ABCTG!

It seems I need to create a way for the zig/zag to be drawn in realtime, instead of waiting for the highest low next bar to draw it. I actually use this with pesavento patterns in Ensign that draws in realtime (zigzag lines) that I could never recreate it in TS/MC or Ninja. I assume my next step is learning more code....C#/Python? Still think there is something I am not yet thinking about.

Reply With Quote

Reply



futures io > > > > > Trouble with buy code. Help/Ideas?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easylanguage/Multicharts still buying next bar even no more code to buy signal! risaldeb MultiCharts 14 May 27th, 2015 10:56 AM
market profile code trouble with tradestation rmiller863 EasyLanguage Programming 1 October 8th, 2013 11:04 AM
Buy / Sell Code Problem resirca52009 MetaTrader 3 November 12th, 2012 10:02 AM
How to code a "buy 1 lot (forex)" in EL Arich EasyLanguage Programming 2 September 16th, 2012 04:00 AM
New Guy Question => Difference between Buy Ask and Buy Bid? Cisco NinjaTrader 8 March 20th, 2012 11:42 PM


All times are GMT -4. The time now is 01:18 AM.

Copyright © 2017 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
Page generated 2017-12-18 in 0.15 seconds with 20 queries on phoenix via your IP 54.92.201.232