Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
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.
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;
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.
Buy ("LE.Sys1" ) next bar at Highest(H,1) stop ;
Buy ("LE.Sys2" …
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:
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?
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.
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.