Executing trade while a bar has not closed yet? - Sierra Chart Programming | futures io social day trading
futures io futures trading


Executing trade while a bar has not closed yet?
Updated: Views / Replies:869 / 5
Created: by Amnesia 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 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
 
Thread Tools Search this Thread
 

Executing trade while a bar has not closed yet?

  #1 (permalink)
Trading for Fun
Vienna Austria
 
Futures Experience: Advanced
Platform: Sierra Chart
Favorite Futures: NQ, FGBL, 6E, GC
 
Posts: 116 since Mar 2012
Thanks: 16 given, 65 received

Executing trade while a bar has not closed yet?

I am trying a way to continously monitor a bar for certain conditions and then executing a trade once that condition has occured. Unfortunately i cannot find examples of how to implement/facilitate this without either freezing up sierra due to what i can only assume is a massive amount of memory leaks caused by a self repeating while loop.

But if you have autoloop=1 on, then basically once you reach the end of the code it ends and essentially reboots when there is a function call (a new bar opening, current bar closing etc). So if you use an if statement and the conditions are not met then that trade is never going to be executed from what i understand, even if the conditions are met lateron while the bar is forming.

To the point:
 
Code
while(sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED){ 

 

    SCFloatArrayRef Last = sc.Close; 

    s_SCNewOrder NewOrder; 

    NewOrder.OrderQuantity = 2; 

    NewOrder.OrderType = SCT_MARKET; 

    if (Long) { 

      if (sc.CrossOver(Last, sc.Subgraph[1]) == CROSS_FROM_TOP)  

        {  

          sc.BuyEntry(NewOrder); 

        }
This is essentially what i need to happen but this leads to memory leaks.

Now if you try this
 
Code
if (sc.CrossOver(Last, sc.Subgraph[1]) == CROSS_FROM_BOTTOM && sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) 

  { 

    sc.BuyEntry(NewOrder);
It actually works but not in the way youd expect them to.

To be more specific i am dealing with Flexrenkos here, and if you use larger settings like 32-31-30 for ES or YM then obviously those retracebars (long wick bars) can last forever, to see what i mean you can look at Outlanders Flexrenko Day Trading Thread.
So what i need is some form of loop that checks whether or not the bar has not closed yet that will not lead to sierra freezing.

I'm open to suggestions or pointers towards ACSIL member functions i should be using.

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)
Elite Member
las vegas
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 836 received


It evaluates in real time by default, you don't have to tell it to do that. Autoloop should equal 1 unless you are controlling the indexing, which it doesn't appear you are. Also, there is a tradingsystem.cpp file you can look at that has a bunch of examples in it.

Reply With Quote
 
  #4 (permalink)
Trading for Fun
Vienna Austria
 
Futures Experience: Advanced
Platform: Sierra Chart
Favorite Futures: NQ, FGBL, 6E, GC
 
Posts: 116 since Mar 2012
Thanks: 16 given, 65 received

@vegasfoster

setting autoloop = 1 means that for every function call (new bar) the code will be repeated. This doesnt change the fact that if you have something along the lines of the crossover example in an if statement for executing a trade that it should not be executed if the conditions are not met.

If the If statement is not executed then the program ends at that point and has to wait being reloaded once a new bar pops up.

So this is why i thought about using a while loop, because a while loop will not terminate until the condition stops being true, this way you can do stuff like execute trades and monitor the bar while it has not closed yet. Unfortunately as you may imagine at this point the while loop needs to end and given the way its structured its going to repeat in an infinite loop right now.

So either i am dead wrong or ill have to try and rewrite the if statement and see if that works later on. In which case i would be very confused because as far as i understand the matter: If statements are skipped if the condition is not met. So in my case wouldnt it simply be skipped?

As for the tradingstudies.cpp file... almost all examples in there (from what ive seen) execute trades after a bar has closed and not while the bar is still open.

So how do i perform a condition check while a bar is still open, where the condition is not met yet, but may be met 2-3 minutes later without terminating the program and awaiting a function call

Reply With Quote
 
  #5 (permalink)
Elite Member
San Jose, CA
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: IB/IQFeed
Favorite Futures: Futures
 
Posts: 110 since Jan 2011
Thanks: 54 given, 89 received


Amnesia View Post
@vegasfoster

setting autoloop = 1 means that for every function call (new bar) the code will be repeated.

The study function is called every time there is new trade data or bid/ask data, so by default it is called many times while the bar is still open. See Working with Arrays and Looping - Sierra Chart. You don't have to do anything special to check for crossover intrabar. @vegasfoster is correct.

Reply With Quote
 
  #6 (permalink)
Trading for Fun
Vienna Austria
 
Futures Experience: Advanced
Platform: Sierra Chart
Favorite Futures: NQ, FGBL, 6E, GC
 
Posts: 116 since Mar 2012
Thanks: 16 given, 65 received


Jolew View Post
The study function is called every time there is new trade data or bid/ask data, so by default it is called many times while the bar is still open. See Working with Arrays and Looping - Sierra Chart. You don't have to do anything special to check for crossover intrabar. @vegasfoster is correct.

You are right, got it to work. Thanks

Reply With Quote

Reply



futures io > > > > > Executing trade while a bar has not closed yet?

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
How to step forward bar by bar (F12) with full bar not half bar? mercyman MetaTrader 1 October 23rd, 2012 05:49 PM
Trade intra-bar or at close of bar? r3algood The Elite Circle 7 October 4th, 2011 02:20 PM
One Trade Per Bar NINJASCRIPT LastShadowRider NinjaTrader Programming 8 August 2nd, 2011 03:15 PM
executing strategy in backtesting cicondo NinjaTrader Programming 11 May 5th, 2011 09:13 AM
Prevent strategy from executing trade at the same price level within a session suprsnipes NinjaTrader Programming 1 February 28th, 2010 11:40 PM


All times are GMT -4. The time now is 02:14 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-14 in 0.10 seconds with 19 queries on phoenix via your IP 54.221.76.68