NexusFi: Find Your Edge


Home Menu

 





buy order effective period


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one johni with 8 posts (0 thanks)
    2. looks_two ABCTG with 8 posts (9 thanks)
    3. looks_3 Jura with 1 posts (3 thanks)
    4. looks_4 maggtrading with 1 posts (1 thanks)
    1. trending_up 5,818 views
    2. thumb_up 13 thanks given
    3. group 4 followers
    1. forum 18 posts
    2. attach_file 3 attachments




 
Search this Thread

buy order effective period

  #1 (permalink)
johni
canada
 
Posts: 29 since Jun 2011
Thanks Given: 0
Thanks Received: 0

How to code a buy order in effect for the next 15 bars?

Say close is > ema and once satified buy at c-atr limit for the next 15 bars rather for the next bar

The buy price does not change

If next bar c-atr buy price is lower is consider another signal for the next 15 bars

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


johni,

something like this could do it. Basically you'd have to store the bar number at the time you send the order and as long as the current bar number is smaller than the saved one + 15 you are good to take the trade.
This is the pseudo code for doing that:

 
Code
if close > ema vakue and LongOrderSent = false then
begin
       LongOrderSent = true;
       MyCurrentBar = CurrentBar + 15;
       LongEntryPrice = c-atr;
end;

if CurrentBar <= MyCurrentBar  then
    Buy ("Long") next bar LongEntryPrice limit;

//reset the order sent flag
if CurrentBar > MyCurrentBar or MarketPosition > 1 then
   LongOrderSent = false;
Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
johni
canada
 
Posts: 29 since Jun 2011
Thanks Given: 0
Thanks Received: 0

ABCTG,

input your code and add a exit using number of bars like 6 bars from entry but multiple entries exit on the same bar of first signal rather 6 bars from entry

say c<ema and bar 0 1 2 3 all are c<ema and are valid entries

signal 0 should exit at 6 bars and signal 1 should exit at bar 7 signal 2 should exit at bar 8 but instead all the signals exit together at bar 6

how to ensure all signal each exit 6 bars from entry?

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

johni,

your original request was for a order being active for X bars. You reply now suggest you are actually looking for something different i.e. a trade being closed after X bars. Maybe you can elaborate on what you are exactly looking for and I (or other) would be able to much better help you.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #6 (permalink)
johni
canada
 
Posts: 29 since Jun 2011
Thanks Given: 0
Thanks Received: 0

Want to have each signal exit at x bars

The signal would be from the condition which is valid for next 15 bars

Say for c<ema15 is the signal and bar 0 there is a signal the exit would be on next x bars

if on bar 1 c is still < ema15 this would be a second signal and would exit on the next x bars counting from the second signal bar NOT on the first signal entry bar

The second third signals would buy despite first signal has not exited

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

johni,
this is an example taken from the Tradestation forum, showing how you can tie an exit to a specific entry.
This will be something you need to do as well in your code.

 
Code
Buy ("LE.Sys1" ) next bar at Highest(H,1) stop ; 
Buy ("LE.Sys2" ) next bar at Highest(H,2) stop ; 
Buy ("LE.Sys3" ) next bar at Highest(H,3) stop ; 
Buy ("LE.Sys4" ) next bar at Highest(H,4) stop ; 
Buy ("LE.Sys5" ) next bar at Highest(H,5) stop ; 
Buy ("LE.Sys6" ) next bar at Highest(H,6) stop ; 
 
 
Sell("LX.Sys1") from entry ("LE.Sys1") next bar at Lowest(L,6) stop; 
Sell("LX.Sys2") from entry ("LE.Sys2") next bar at Lowest(L,5) stop; 
Sell("LX.Sys3") from entry ("LE.Sys3") next bar at Lowest(L,4) stop; 
Sell("LX.Sys4") from entry ("LE.Sys4") next bar at Lowest(L,3) stop; 
Sell("LX.Sys5") from entry ("LE.Sys5") next bar at Lowest(L,2) stop; 
Sell("LX.Sys6") from entry ("LE.Sys6") next bar at Lowest(L,1) stop;
Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #8 (permalink)
johni
canada
 
Posts: 29 since Jun 2011
Thanks Given: 0
Thanks Received: 0

Did try the from entry code but the problem is if the signal condition is valid for more than the number of buy code you specified they may not be accounted for

Is there a loop code to ensure all signals are accounted for?

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

You need to adapt the code to the number of entries you are taking of course. This was just an example to get you going.
As orders can't be within a loop you will probably have to hard code all entries and exits.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #10 (permalink)
johni
canada
 
Posts: 29 since Jun 2011
Thanks Given: 0
Thanks Received: 0


ABCTG,

The signals are considered different

Buying at Highest(H,1) and Highest(H,2) are different signals thus require from entry to tag them

However the problem is having similar signals with exiting filled order

Say buy whn stoch<30 and today there is a buy signal (stoch<30) and tomorrow stoch is still <30 so there is another buy similar signal with existing signal filled (yesterday)

Want to have each buy (similar signal) exit 5 bars from the entry

So today buy signal would tmr exit 5 bars from today but tmr buy signal would exit 5 bars from tmr not today

Reply With Quote




Last Updated on April 16, 2014


© 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