Plus the reverse trade on stopped orders is also not working.
You've already been told about this being unreliable
if(Volume[0]>1) return(0);
This does nothing
//+------------------------------------------------------------------+//| OnTick function |//+------------------------------------------------------------------+voidOnTick(){
staticdatetime timeCur; datetime timePre = timeCur; timeCur=Time[0];
bool isNewBar = timeCur != timePre;
if(isNewBar){
return; // Once per bar
}
return; // every tick
}
You return if it is a new bar and also return if it isn't, so you always return without doing anything.
When you do find a new bar, you need to reset the value.
voidOnTick(){
datetime timeCur=Time[0];
staticdatetime timePre = timeCur;
bool isNewBar = timeCur != timePre;
if(isNewBar){
timePre=timeCur;
//Do what you want at each new bar // Once per bar
}
//Do other stuff that you may need to do every tickreturn; // every tick
}
Your code for checking the last order assumes that the highest index in the order history is the latest closed trades. I am not sure if this is always true.
Ok I applied the code...but when i try to call the start function at each new bar...its not taking any order...
voidOnTick(){
datetime timeCur=Time[0];
staticdatetime timePre = timeCur;
bool isNewBar = timeCur != timePre;
if(isNewBar){
timePre=timeCur;
//Do what you want at each new bar // Once per bar
start();
}
//Do other stuff that you may need to do every tickreturn; // every tick
}
Even if I add buyCall & sellcall function inside new bar zone..& start() inside the tick zone...its creating multiple orders.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Plus the reverse trade on stopped orders is also not working.
You've already been told about this being unreliable
This does nothing
You return if it is a new bar and also return if it isn't, so you always return without doing anything.
When you do find a new bar, you need to reset the value.
Your code for checking the last order assumes that the highest index in the order history is the latest closed trades. I am not sure if this is always true.
Ok I applied the code...but when i try to call the start function at each new bar...its not taking any order...
Even if I add buyCall & sellcall function inside new bar zone..& start() inside the tick zone...its creating multiple orders.
Along with this start function...i have following extra function..which get called in main function.
int split(double x)
void BuyCall(double BC)
void SellCall(double SC)
& lastly void onTick function about which i am confused...how to set it in a way..that will not repeat pending orders tick by tick
..just one sequence of pending orders in each hour...plus it will check if any pending order got stopped out
..then it will open another trade in opposite direction..but just one sequence per hour.
Please help just stuck in same area over and over again...but obviously wants to learn...so that i don't need to ask silly question in future
...want to clear my concept..:(
Thank you for your time.