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)
Easylanguage/Multicharts still buying next bar even no more code to buy signal!
I am using Multicharts and Easylanguage program to code the following:
1. Buy if low[1]>Moving average
2. Limit orders from all signal to once per bar was checked.
3. Intrabarordergeneration is true.
However it seemed the code did not recognize the buy if low[1]>MA because even it is false buy signal was generated. I noticed that this happened preceding a stop sell execution the previous bar.
Please help!
Can you help answer these questions from other members on NexusFi?
it's hard to tell what is going on without knowing your code. It's possible that you are using a flag for the entry condition check that is not reset and simply stays true, but there are many other reasons. One could only guess without seeing the code.
I think it might also help if you share what you're trying to do. From the three points that your code does, I get that it should buy when the previous low is above a moving average value. But in point 2 you mention 'orders from all signal'. Does that mean you're combining several signals into one?
So as ABCTG says, post the code (or a reduced example that replicates the problem). But I'd add to that to also clarify your goal(s). Perhaps your code is needlessly complicating things.
Your code misses the variables and IOG declaration, which is not a big thing but it makes me wonder whether it's complete.
Why did you choose to use intra-bar order generation, by the way? If you may know, SetStopLoss is also evaluated intra-bar and thus does not need IOG, while IOG can also affect your variables' values (see IntraBarPersist).
Now there's nothing wrong with using IOG, but if you have an issue with your code I'd suggest to bring the code back to its basic form and then step-by-step add each new component to see what breaks it.
I use IOG so it can react to intra day opportunity. Here's what I did. I remove one by one all the buy signals and the result was still the same. That is it still Buy at open after the previous bar was stopped or executed a sell signal. Even I checked the "limit entries from same signal in this strategy to once per bar" it still trade the next bar. I am lost now!
I suspect that a spill over of signal from the previous bar that is executed at the next bar open. How can I ensure that the code will only buy if the condition is true. Right now even if false it still buy then immediately sell it soon after.
If I look at the code you previously posted (with the `BuyCondition` variable), then that should buy only if the condition is true. So based on that code snippet I don't see a reason why this behaviour occurs.
Have you tried outputting the variable that you use for submitting buy orders (e.g., `BuyCondition`) on every script calculation to verify that it doesn't remain true?
It might also help to double-check that the variable used for submitting the order (e.g., `BuyCondition`) is only assigned a value above the code that submits the order. If you place `BuyCondition` below the code that submits the order, then this variable will be true on the next script calculation even though it shouldn't be.
Otherwise, can you perhaps post the full script that is causing this problem? Perhaps with more eyes looking at the code we can spot the error faster.
After isolating buy signal one by one. I think I found the culprit. Since the IOG is True, the buy signal Low[1]>var0 is executed per tick and the code is doing what it meant as coded but not what I intended to do.
I set the chart to 30 minutes and I like the last bar Low should be > var0 to buy. But unfortunately I am not getting it if the last tick low from the previous bar is higher than var0 even if the Low of the previous 30 minute bar is < var0.
How can I code that the last 30 min bar Low is > var0 to buy and IOG = True?
Many thanks. Your code above works. I only changed (BarStatus(1) = 1) then it worked according to my strategy otherwise if it is (BarStatus(1) = 2) it takes the close of the last bar.