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 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Jura with 1 posts (3 thanks)
    1. trending_up 5,746 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

  #11 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

johni,

you will need different order names, I don't think there is a way around that. This would mean for you to create five different entry conditions and making sure the second one is only executed after the first has been filled etc.. Or have one entry condition with five different order parts, where the code would take the appropriate order according to which orders are already filled.

Regards,
ABCTG


johni View Post
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


Follow me on Twitter Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
Futures True Range Report
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
  #12 (permalink)
johni
canada
 
Posts: 29 since Jun 2011
Thanks Given: 0
Thanks Received: 0

ABCTG,

Came out with this code to try the stoch buy signals but some of the signals are not registered

Whn stoch goes above 30 for some bars and fall below 30 the fall below 30 signals are all not registered

The code is fix and not dynamic to account of interval bars

Any idea how to tweak them? Did tried barnumber<count but didnot register those signals too

If Count1 = 0 and Count2 = 0 and Count3 = 0 and Stock < 30 then begin
Buy x shares this bar on close;
Count1 = BarNumber
end;

If Count1 <> 0 and BarNumber >= Count1 + 5 then begin
Sell X shares this bar on close;
Count1 = 0;
end;

If Count1 <> 0 and BarNumber = Count1 + 1 and Count2 = 0 and Stoch < 30 then Begin
Buy x shares this bar on close;
Count2 = BarNumber
end;

If Count2 <> 0 and BarNumber >= Count2 + 5 then begin
Sell X shares this bar on close;
Count2 = 0;
end;

Reply With Quote
  #13 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


johni,

please post the whole code you are having problems with and wrap code tags around it in your post. It's hard to guess what is going wrong from this code piece only.

Regards,

ABCTG

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

ABCTG,

The code is below

Stoch may refer to stochastic

However this code is fix in a way that only 3 signals are accounted for and whn there are interval bar with stoch above 30 subsequent fall below 30 signals are not registered

Also if stoch is below 30 for 100 bars would not the user have to input 100 buy code to account for them?

Need a tweak? a loop or what?

================

Vars: Stoch(O), Count1(0), Count2(0), Count3(0) ;

If MarketPosition <= 0 then Begin
Count1 = 0;
Count2 = 0;
Count3 = 0;
end;

If Count1 = 0 and Count2 = 0 and Count3 = 0 and Stoch < 30 then begin
Buy x shares this bar on close;
Count1 = BarNumber
end;

If Count1 <> 0 and BarNumber >= Count1 + 5 then begin
Sell X shares this bar on close;
Count1 = 0;
end;

If Count1 <> 0 and BarNumber = Count1 + 1 and Count2 = 0 and Stoch < 30 then Begin
Buy x shares this bar on close;
Count2 = BarNumber
end;

If Count2 <> 0 and BarNumber >= Count2 + 5 then begin
Sell X shares this bar on close;
Count2 = 0;
end;

If Count1 <> 0 and Count2 <> 0 and Count3 = 0 and BarNumber = Count2 + 1 and Stoch < 30 then Begin
Buy x shares this bar on close;
Count3 = BarNumber
end;

If Count3 <> 0 and BarNumber >= Count3+ 5 then begin
Sell X shares this bar on close;
Count3 = 0;
end;

==============

Reply With Quote
  #15 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

johni,

please check this post from this thread:


You need to name the orders and tie the exits to the specific entry name. Then this will work:



Your original code without named orders produces this:


Regards,
ABCTG

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

ABCTG,

The second pic is exactly the problem

All the subsequent signals all exit on the same bar despite specifying the number of exit bar for each subsequent signal

Trying to code the first pic

But the problem is there is only one buy condition stoch<30 not like buy (H,1) or (H,2) which can be use to tie the exit to the entry How do you create 10 diff stoch<30? They are the same and result in same buy

Secondly if stoch is < 30 for 100 tims would not the user have to code them 100tims to account for the buy?

Reply With Quote
  #17 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

Just had to give @ABCTG a few thanks in this thread, since I see that the thread starter did not show signs of appreciation for ABCTG's effort (either by saying thanks or pressing on the thanks button).

That's a shame, because people like ABCTG are volunteering their help on the forum while they have probably enough other things to do. Furthermore, it also limits getting help from other people, since not everyone is as patient and compassionate as ABCTG in this thread.

Reply With Quote
Thanked by:
  #18 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Thanks @Jura, I really appreciate your comments.

@johni,

there is no need for (H, 1) or (H, 2) this was just an example. You can include order names to your code like this:



Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #19 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40


johni View Post
ABCTG,

The code is below

Stoch may refer to stochastic

However this code is fix in a way that only 3 signals are accounted for and whn there are interval bar with stoch above 30 subsequent fall below 30 signals are not registered

Also if stoch is below 30 for 100 bars would not the user have to input 100 buy code to account for them?

Need a tweak? a loop or what?


ABCTG has shown amazing patience and helpfulness in this thread, danke schön.


now, if i understand correctly, you want to take x number of simultaneous long positions as long as the stochastic indicator is below some level, and x short positions when the stochastic indicator is above some level. also, each position must be held for a fixed number of bars and then closed.


one way to do it is to code x sets of entries and exits, which must be iterated one by one in the code. the other way i can think of, is to have just one set of entry and exit for long trades and one for short, and in - format strategies - go to the - properties for all - tab and allow up to x (100) positions in the same direction. i'm not sure the exits will work as desired, because when the strategy goes from long positions to short it will close all open long positions at once, and viceversa, but using this option the strategy will pyramid positions up to the specified number.

Reply With Quote
Thanked by:




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