why no tick-actualization

thread: why no tick-actualization

  1. #1

    why no tick-actualization

    Hello everybody,

    this is my very first message in this forum. Some weeks of trading. Some years of programming (pascal, basic and a little c).

    But here, I attempt to attempt to .... But can not find no solution. So I tried with a tiny example from S. Kovalyov, Programming in Algorithmic Language , but this doesn't work also.

    Here is a bit, modified code
    -----------START-----------
    //countiter.mq4
    // The code should be used for eduional purpose only.
    //--------------------------------------------------------------------

    int init()

    //--
    Alert (Function init() triggered at beginning);// Alert

    return; // Exit init()
    //--
    return(0);


    int start() // Particular funct. Start()

    int I, Count; // Declaring variables
    for (I=1; ilt;=5; I ) // Prove for 5 ticks

    Count=0; // Clearing counter
    while(RefreshRates()==false) // Until...
    //. . A brand new tick comes
    Count = Count 1; // Iteration counter

    Alert(Tick ,I,, loops ,Count); // Following each tick

    return; // Exit beginning()



    The only message that appears on the alert-window:
    Function init() triggered at launch

    and I anticipated something like

    Tick 3 98622348
    Tick 2 64534421
    Tick 1 32343443

    the chart is a simple EURUSD M1-chart without any other EA's or Indiors.
    But it is a demo account.



    Can anyone help me? This would be very kind of You

  2. #2
    Problem is solved - Thank You and sorry,

    so stupid, it was Only the fact that EA wasn't Triggered in MT. oh no

  3. #3
    The code above does function as a script at least. It will get a little too hard on the CPU though. It might be worth adding Sleep() call (or even an indior) and IsStopped() check to the internal loop.

    How can you run the case?

  4. #4
    Hi Irtron,

    thank You very much for Your Answer. The issue is when I begin from the conclusion, that means with codeing rather than from the start - handling MT.

    I thought: the Init runs, why not the rest, not knowing, that EA has to be triggered along with a exit includes start ().

    Curious



    The code above does function as a script at least. It will get a little hard on the CPU. It might be worth adding Sleep() call (if not an indior) and IsStopped() check to the inner loop.

    How can you run the example?

  5. #5
    start() itself will be called for every sign, your script should be event driven, the event is the arrival of a new tick. You should process only this 1 tick in start() and immediately return.
    You perplexing EA and scripts. Start() function of the prior is triggered by upcoming ticks really and RefreshRates() is imperative to make sure the trade environment has not changed whilst start() is conducting. The latter (a script) runs its start() just once and it is acceptable for asynchronous processing like from the code above. It's far from perfect though as I mentioned already and should be considered as an instance for instructional purposes just just the copyright states.

  6. #6
    Inserted Code for (I=1; ilt;=5; I ) // Display for 5 ticks Count=0; // Clearing counter while(RefreshRates()==false) // Until... //.. A brand new signal comes Count = Count 1; // Iteration counter Alert(Tick ,I, loops ,Count); // Following every tick
    You should not do it like this. Start() itself will probably be called for each and every tick, your script ought to be event driven, the event is the coming of a new tick. You should procedure only this one tick in launch() and instantly return.

    The usage of extended polling loops in these functions is possible, but you should only do if there is not any other option and you cannot do this at indiors, just at expert advisors since indiors operate in the GUI thread and you also block the whole Metatrader GUI until launch() returns.

    If you need just 5 ticks you can specify a global counter to 0 then in start() write the current price to a range, raise the counterclockwise, and only if the counter has reached 5 then do everything must be accomplished with the last 5 ticks and reset the counter, else just return.

  •