int start(){ : if (Bid => longEntry + pip2dbl){ // open long else if (Bid <= shortEntry - pip2dbl){ // open short
Is Bid and Ask price only taken at the close of the bar? I was trying to figure how to do it just as soon as it crossed in more as in price comes in... Thanks
start() is run for each tick . . . assuming it completes before the next tick arrives . . . for each tick there is a new price.
I made this function and it works just fine. It follows price until it gets between a long and short entry prices. When that condition is met it then looks for a break of one of those prices in the start(). But when the price breaks those points the function signals its in the wrong place and a trade does not occur. I'm trapped in it....
int locate_price() { if(level[1,2] == 1) { if(Ask>level[1,1] && Ask<level[2,1]){ return (1); } else { return (0); } } if(level[1,2] == 2) { if(Bid<level[1,1] && Bid>level[2,1]){ return (2); } else { return (0); } } }
- Do your levels in Bid only. Ignore the Ask (except in the order send.)
static double BidPrev; bool previousInside = level[1,1] > Bid && Bid < level[2,1], signalBuy = previousInside && Bid > level[1,1], signalSell = previousInside && Bid < level[2,1]; BidPrev = Bid;
- Self document your code so you can understand it.
#define xxxxx 0 // are you using zero? #define UPPER 1 // level[x #define LOWER 2 #define COUNT1 3 #define PRICE 1 // level[,y #define STATE 2 #define COUNT2 3 #define OUTSIDE 0 // state #define INSIDE 1 double level[COUNT1, COUNT2]; // Did you size your array to at least [3,3] #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 int locate_price() { if(level[UPPER,STATE] == OUTSIDE) { if(Ask>level[UPPER,PRICE] && Ask<level[LOWER,PRICE]){ return (SIGNAL_BUY); } else { return (SIGNAL_NONE); } } if(level[UPPER,STATE] == INSIDE) { if(Bid<level[UPPER,PRICE] && Bid>level[LOWER,PRICE]){ return (SIGNAL_SELL); } else { return (SIGNAL_NONE); } } }
Your code is so elegant mine I just bash with a blunt instrument to try and make it work. Thanks!
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
I can’t seem to wrap my head around this if someone could please help me. I have two prices that I calculate for both a long and short entry. I want the EA to follow price so that if it breaks my long price it initiates buy after a pip and if it breaks my short price it initiates a sell after a pip.
I’m ok with the OrderSend code I’m not sure how the best way to monitor price when my target is reached to initiate the order.