
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
There is no OnStart() in EA's but I get what you meant. However, the OP even in response to your comments said and I quote:
Yes, I meant OnTick(). You are still attaching too much significance to "while EA running". It doesn't necessarily, or even most plausibly mean, "while the EA is executing its OnTick()", rather than "while the EA is attached to a chart, i.e. during its entire lifetime".
We need more information from paranoyakX.
Yes, I meant OnTick(). You are still attaching too much significance to "while EA running". It doesn't necessarily, or even most plausibly mean, "while the EA is executing its OnTick()", rather than "while the EA is attached to a chart, i.e. during its entire lifetime".
We need more information from paranoyakX.
Hi guys,
let me clarify this. My code is looking for a very basic pattern on previous bars and will decide if an order will be opened but opening new order will be check only when a new bar comes up. what I mean I am waiting for the last bar close, then check the pattern if it is ok I will open the order. so opening an order is happening at new bar's opening. as @jjc said, I am holding basic pattern information at global variables, like when my pattern started and ended, what the highest and lowest value is, etc.
Somehow if I have to re-run EA, I want to find these basic information again (pattern start and end bar, highest, lowest prices etc) and fill my global variables again, that's why I need this. I will use start and end info to decide when to close my order. so it is enough if a new bar does not come up at OnInit, while EA running, it is not a problem.
Yes, I meant OnTick(). You are still attaching too much significance to "while EA running". It doesn't necessarily, or even most plausibly mean, "while the EA is executing its OnTick()", rather than "while the EA is attached to a chart, i.e. during its entire lifetime".
We need more information from paranoyakX.
Hi guys,
let me clarify this. My code is looking for a very basic pattern on previous bars and will decide if an order will be opened but opening new order will be check only when a new bar comes up. what I mean I am waiting for the last bar close, then check the pattern if it is ok I will open the order. so opening an order is happening at new bar's opening. as @jjc said, I am holding basic pattern information at global variables, like when my pattern started and ended, what the highest and lowest value is, etc.
Somehow if I have to re-run EA, I want to find these basic information again (pattern start and end bar, highest, lowest prices etc) and fill my global variables again, that's why I need this. I will use start and end info to decide when to close my order. so it is enough if a new bar does not come up at OnInit, while EA running, it is not a problem.
You should NOT be doing all of that in the OnInit(). You should be doing all that logic (including recovery) in the OnTick(). This is important! Doing it in OnInit() will cause you further problems which you have not foreseen and will leave your EA in a state of "initialising" while you are doing all of that logic. So, do it right! Do only your initialisation (such as variables, external parameter checks, etc.) in OnInit() and everything else in the OnTick().
No no no! I couldn't explain my selft sorry, I am running everything in the OnTick. but simply I checked if this tick is belong to a new bar and do my staff. What I run in OnInit is, re-find the orders and the pattern that I calculated before, recalculate it. I said that this is running at OnInit, find my pattern that currently opened order is belong to.
I hope I can explain.
No no no! I couldn't explain my selft sorry, I am running everything in the OnTick. but simply I checked if this tick is belong to a new bar and do my staff. What I run in OnInit is, re-find the orders and the pattern that I calculated before, recalculate it. I said that this is running at OnInit, find my pattern that currently opened order is belong to.
I hope I can explain.
Yes, I understood that in your post! What I am saying is DON'T do that in the OnInit(). You should find your orders and patterns and all that calculation in the OnTick().
Just define a local static variable in OnTick() and do all your checking and pattern definition, and then set the variable to false.
Yes, I understood that in your post! What I am saying is DON'T do that in the OnInit(). You should find your orders and patterns and all that calculation in the OnTick().
Just define a local static variable in OnTick() and do all your checking and pattern definition, and then set the variable to false.
Sorry then, I misunderstood you before. Why I do not do that OnInit ? Is not it more convenient ? When I do that, for every tick after the first one, I will be running and if statement that wont be true every. I thought that unnecessary load on the code.
is not the reason OnInit exists, to initialize something like my global variables ?
I hope I can explain.
I think that we need to see some code to be certain of what you are talking about. For example, it is not clear whether you are looking for the historic pattern which generated an existing open trade because (a) that tells you how to manage the open trade, where/when to close it etc, or (b) just in order to draw some markers on the chart explaining to yourself why the existing trade was opened.
I generally agree with FMIC that you should try to do as much as possible in OnTick(), and to keep as little state as possible in global variables.
Sorry then, I misunderstood you before. Why I do not do that OnInit ? Is not it more convenient ? When I do that, for every tick after the first one, I will be running and if statement that wont be true every. I thought that unnecessary load on the code.
is not the reason OnInit exists, to initialize something like my global variables ?
thanks for the advice, here is a very simple version of my code, this is not my real code but I hope this will be more clear.
as I said this is not the real code, finding pattern etc is just an example. the reason I opened this thread is DetectExistingPattern() function