Tick by milsec. Hard help please - page 2

 
ubzen:

Yes you can use a GlobalVariable like I did. Or you can use an External Variable like I did.

Yes I coded this function which tries to sum all Ticks from last 30 seconds and Average them. You'll want to test it :(

Well thats really up_to you and what you want to display, You can display the SumTicks : AverageTicks | MilliSeconds Between Ticks... Up to you.

I just did Because 1_Second=1000 MilliSeconds, should I get 5_Ticks within the same second, then average MilSec between them = 1000/5; I'm not sure if it equates the same thing but thats what I did.

Just some notes.

Your version is Indicator therefore it has little less control with timing, and depends on the frequency of in_coming ticks. Mines a contentious script, therefore the concept of missing ticks is irrelevant. Its checking the tick_count from the broker about every 20 milli_seconds or so.

Anyways, I'm not the fastest coder so I'm hoping you have enough to built your own Indicator or Script. If you're looking for a programmer then check the jobs section.

Why not use Volume then you won't miss any ticks and will have a much more accurate average of tick frequency ? with the activity right now there are more ticks being missed than received on most Brokers . . .
 
RaptorUK: Why not use Volume then you won't miss any ticks and will have a much more accurate average of tick frequency ? with the activity right now there are more ticks being missed than received on most Brokers . . .
The script is using iVolume so I'm not sure what you mean. Yeah :) its nuts right now.
 
ubzen:
The script is using iVolume so I'm not sure what you mean. Yeah :) its nuts right now.

LOL . . . oops, I assumed you had done something along the lines of the OP . . . I'll get my coat, again.
 

Thank you a lot for your help, I really appreciate it.


I wasn't expecting that much.


I wish market gives you heaps of pips : )


Cheers

 

Ps: Yes on FOMC ticks get crazy:


  // Modify TP
  
      for (int z10=OrdersTotal()-1; z10 >= 0; z10 --) 
   {
      OrderSelect(z10, SELECT_BY_POS, MODE_TRADES);

If ( Average Ticks < 400 millisec ) {
  
  if ( OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY && MathAbs(OrderTakeProfit()-OrderOpenPrice()) <= Takeprofit*Point    ) 
  {OrderModifyReliable(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit()+Takeprofit*Point,0,White);}
  
  if ( OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL && MathAbs(OrderTakeProfit()-OrderOpenPrice()) <= Takeprofit*Point   ) 
  {OrderModifyReliable(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit()-Takeprofit*Point,0,White);}

        }
  }

// Use this Risk/Reward for yourself to maximize profits
 

For those Interested, here's the updated script. If you find some bugs [ most_likely :) ] please let me know.

  • I name it AvgMlsPerTic [Average MilliSeconds Per Ticks].
  • You can specify the Symbol when attaching [ Untested ].
  • You can change Parameters by Pressing F3 [ Global_Variables].
  • The GV_SetOffAltCnt is the smallest Average Mls ... to sound Alert.
  • The GV_DelaySeconds is the smallest Time between Alarms.
  • The GV_NumSecForAvg is the # of Seconds to Average [ <60 ].
  • Creates a GV_AvgMlsPerTic which could be used by Expert.
  • Creates a Comment on chart its attached upon.
  • Save-As Script to reserve open slot for Expert Advisor.

Primary use for active vs slow market obviously. I don't know how useful it'll be but there. Other usage, in combination with Indicator for perhaps Missing_Ticks?

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Property SaveAs Script
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#property show_inputs
extern string Symbolx="";
#define SECONDS 60
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void init(){
    if(Symbolx==""){Symbolx=Symbol();}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void start(){
    while(!IsStopped()){
        static int SavLstSecond=0;
        static int RuningVolCount=0;
        static int SavLstVolCnt=0;
        
        int CurSecond=TimeSeconds(TimeCurrent());
        if(CurSecond!=SavLstSecond){
            SavCurRunCnt(RuningVolCount,SavLstSecond);
            static int StartTickCount=0;
            StartTickCount=GetTickCount();
            RuningVolCount=0;
        }
        
        int CurVolCount=iVolume(Symbolx,PERIOD_M1,0);
        if(SavLstVolCnt>CurVolCount) SavLstVolCnt=0;
        
        if(SavLstVolCnt>0
        && GetTickCount()<StartTickCount+1000){
            RuningVolCount+=(CurVolCount-SavLstVolCnt);
        }
        
        SavLstSecond=CurSecond;
        SavLstVolCnt=CurVolCount;
        Sleep(1); RefreshRates();
    }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void deinit(){
    GlobalVariableDel("GV_SetOffAltCnt");
    GlobalVariableDel("GV_DelaySeconds");
    GlobalVariableDel("GV_NumSecForAvg");
    GlobalVariableDel("GV_AvgMlsPerTic");
    Comment("");
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void SetGlobalVariables(){
    if(!GlobalVariableCheck("GV_SetOffAltCnt"))
        GlobalVariableSet("GV_SetOffAltCnt",1000);
    if(!GlobalVariableCheck("GV_DelaySeconds"))
        GlobalVariableSet("GV_DelaySeconds",30);
    if(!GlobalVariableCheck("GV_NumSecForAvg"))
        GlobalVariableSet("GV_NumSecForAvg",30);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void SavCurRunCnt(int RuningVolCount, int SavLstSecond){
    int SecVolCntRay[ SECONDS ];    int TemporaryRay[ SECONDS ];
    ArrayCopy(TemporaryRay,SecVolCntRay,1,0,ArraySize(SecVolCntRay)-1);
    ArrayCopy(SecVolCntRay,TemporaryRay,0,0,ArraySize(TemporaryRay));
    SecVolCntRay[0]=RuningVolCount;
    static int CountDown=0; if(CountDown<=SECONDS){CountDown++; return;}
    
    int SumTicks=0; SetGlobalVariables();
    int SecondsForAvg=GlobalVariableGet("GV_NumSecForAvg");
    for(int i=0; i<SecondsForAvg; i++){
        SumTicks+=SecVolCntRay[i];
    }
    
    if(SumTicks==0) return;
    int AvgMilSecPerTic=(SecondsForAvg*1000) / SumTicks;
    GlobalVariableSet("GV_AvgMlsPerTic",AvgMilSecPerTic);
    Comment(Symbolx+": AvgMilSecPerTic = "+AvgMilSecPerTic);
    
    static int LstFresherTme=0;
    int Trigger=GlobalVariableGet("GV_SetOffAltCnt");
    int Fresher=GlobalVariableGet("GV_DelaySeconds");
    if(AvgMilSecPerTic<=Trigger){
        if(GetTickCount()>LstFresherTme+(Fresher*1000)){
            Alert(Symbolx+": AvgMilSecPerTic = "+AvgMilSecPerTic);
            LstFresherTme=GetTickCount();
    }   }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

So

extern string Symbolx="";

works fine.


Using such Global variables means that we can only monitor on pair/MT4?


If the script is running for EURUSD...and EA also attached on many pairs, so refering for GV_AvgMlsPerTic is a gauge for all?


Does it work if we implement the script into EA and we use directly ?

int AvgMilSecPerTic=(SecondsForAvg*1000) / SumTicks;
 

Referencing GV_AvgMlsPerTic is a gauge for only the pair its [Attach_to] Or [Name_Specified]. The Symbol_Name can only be specified when you attach, cannot be modify while the program is running. The GV however can.

If you turn the script into an EA then you'll need to add allot of things. AvgMilSecPerTic is a local variable, you'll either want to make it Global* or pass its value to other functions.

Reason: