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)
How to avoid more than one entry position per week
Please could you recommend me a solution to avoid more than one entry in the same week? I explain better...
I am trying to build a TS. This TS is a statistical trading system with two levels per week to enter and exit into/from the position. For example, if it enters at the beginning of the week but after a while it exits due to a stop loss triggering I don't desire it enters a second time in the same week (it can may be in the next week but not in the same). I already tried by the difference between ELDateToDateTime(0) - PosTradeExitDateTime(1,0)) <= 4.35 but it doesn't work and anyway I am searching for a better (smarter and simplier solution).
Can you help me please?
Thaank you very much
auato
Can you help answer these questions from other members on NexusFi?
you could for example modify the EntriesToday function to work on weeks or set a flag when you enter a trade. This flag could then be checked as part of your entry condition, if the flag is true then no more entries. Now you only have to reset the flag back to false at the end of the week.
The latter idea is probably simpler than modifying the EntriesToday function.
How can add also the setting of a flag just it entered? Could you kindly help me to make this line completing the setting after the buy with "flag=1"?
Then, if I got you, at a subsequent line I could write:
in which flag is reset at 0 only on monday and it means that it is ready to enter. flag=1 means it is already entered a trade (but this part is missing because I don't know how to set flag=1 when it enters)
You can for example set the flag to +1 when your entry conditions are true, although this wouldn't guarantee that you got a fill. So you probably want to either check for a change in the market position or if you are pyramiding check if the number of shares/contracts (using the CurrentContracts reserved word for example) is bigger than on the previous code computation.
flag=0 allows to enter
flag=1 does not allow to enter
every monday I reset flag to 0 to enter.
In the middle of week if I exit for a stoploss, everytime the next bar checks currentcontracts, it realizes that currentcontract is 0 and accordingly the falg will be reset and the next bar is ready to enter.
In an IF condition after then I have the order execution command (buy). In addition to the execution statment can I also insert after then the setting of the flag to 1? In this way I avoid the check every time with currentcontracts.
A sort of "IF condition 1 AND condition 2 then buy next bar at market AND flag=1"
it's hard to guess for me where the problem could be without knowing the code. You don't have to reveal anything you consider proprietary (you could for example exchange those parts with standard open source codes, as long as the new code is still able to demonstrate the issues), but the more information you provide the easier and more likely it will be for someone to help you.
The "if ... then..." statement in your pseudo code won't work, as the "then" only includes the next code statement. You can however use the "if... then begin.... end ;" statement that will include everything within the "begin... end" in your conditional check.
I report below the code. Omitted only the definition of variables (all set 0 at the beginning of the code) and the calculation of Min and Max which represent the levels to enter and exit for the week. If in the week the TS enters but then it is not able to exit because doesn't touch the other level, a forced exit will be applied on Friday. To limit the bad trades I introduced STPLVL to reduce the losses @2%. STPLVL works well but as the two levels Min and Max are the same for the entire week after an exit our to STPLVL, it unfortunately enters again because there are the seme conditions to enter again. On the other hand, I would like to stop all operations if in that week SPTLVL forces the exit. I work with a time frame 5 minutes.
Maybe as you write, the statement if...then... begin ...end is the correct solution for me because I can set a flag to avoid other entries and to reset that flag the monday morning.
that is the original code, I tried in a second moment to insert a flag and to discuss about this solution as you recommended me but unsuccessfully. So I came back to the original code with no flag