Redone:
//+------------------------------------------------------------------+ //| ICHIMOKU_SIMPLE.mq4 | //| Copyright © 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" extern double Lots = 1.0; //---- int start() { double tenkan_sen=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 1); double kijun_sen=iIchimoku(NULL, 0, 9, 26, 52, MODE_KIJUNSEN, 1); int cnt,ticket,total,order_id; // BUY total=OrdersTotal(); if(total<1 && tenkan_sen>kijun_sen) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Ask+*Point,3,0,"ichimoku",16384,0,Green); } // SELL for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) if(tenkan_sen<kijun_sen && OrderType()==OP_BUY) { OrderClose(order_id,1,Bid,3,Red); return(0); } } return(0); }
What's wrong with that line?
Because you're closing orders... if you close order#1, order#2 becomes the new order#1 during the for(). Your next command becomes close order#2 but that order is now order#1 and you end up skipping it.
Ok, well anway, do you think my idea is even possible?
ToBa:
Ok, well anway, do you think my idea is even possible?
Ok, well anway, do you think my idea is even possible?
Ofcours I can tell you all should do at once, but step by step is in my opinion a better way
I haven't seen your coding counting down searching for the trades to close when will it come ?
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've been trying to create an expert advisor which will automatically buy 1 unit when the tenkan-sen>kijun-sen (when the tenkan-sen line is above the kijun-sen line) and then sell it once the tenkan-sen is lower than the kijun-sen.
However, it has been difficult to take profit once the tenkan-sen is lower than the kijun-sen.
Does anyone know how this may be done?
Thanks in advance.
The code so far: