if (NewBar() == false) return(0);
and if not ...... first tick new is true OrderSend(..........)
//+------------------------------------------------------------------+ //| NewBar | //| Returns true when new bar gets first tick | //| Returns false otherwise | //+------------------------------------------------------------------+ bool NewBar() { static datetime dt = 0; if (Time[0] != dt) { dt = Time[0]; return(true); } return(false); }
Placing at first tick NewBar.....
A way to do it....
Could I do like this:
if(MAslope>0 && NewBar()==true){RisingPrice=1;}
if(MAslope<=0 && NewBar()==true){RisingPrice=-1;}
?
BTW, you're my new favourite person who doesn't live in my house. (Wife kind of wins by default for the entire world)
Do you want a copy of this EA when it's finished? I predict that it will work very well.
- deVries:While creating/using functions is the normal way to go, I have an exception with NewBar. It can not be called more than once per tick (will return false on subsequent calls.)
if (NewBar() == false) return(0);
int start(){ static datetime Time0; if (Time0 == Time[0]) return; Time0 = Time[0]; :
- trivates:1) You wouldn't ever write if( (x==2) == true ) would you? You'd simply write if (x==2). So you need not write if( BOOL==true ) but simply if( BOOL )
if(MAslope>0 && NewBar()==true){RisingPrice=1;}if( MAslope>0 && NewBar() ){RisingPrice=1;}
The opposite sense if(BOOL == false) would be written if(!BOOL) and read as if not BOOL.
2) If the condition is false - what is the value of RisingPrice? You'd better have initialized it to non-one previously. But what is the meaning of one? RisingPrice sounds like true or false. So the one is misleading:bool RisingPrice = false; if(MAslope>0 && NewBar()){RisingPrice=true;}
3) bool B=false; If( true ) B=true; can be simplifiedbool RisingPrice = MAslope>0 && NewBar();
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
Hello Folks. I am trying to create a condition that will send an order to market but I don't want it to happen on EVERY TICK. (arrgh!)
What do I have to do the following in order to make the value of RisingPrice change ONLY if the current tick is in fact the opening tick? (RisingPrice=0 before the program finds the following code)
if(MAslope>0){RisingPrice=1;}if(MAslope<=0){RisingPrice=-1;}
As a side note, when RisingPrice=0, my EA does not send orders to the market. The value of RisingPrice is changed back to 0 after an order goes through. That's why I need it to change ONLY on the OPENING TICK. MAslope is calculated in my EA as the difference between a moving average's current value and the value of the same at the previous bar.
Thank you.