| / | Forum |
|
lancelot
2010.07.22 13:30
I am new for this program I am practicing to code EA now I want to close the order but in the report it said the " invalided ticket for order close function" Please help me... { thank... |
|
Using MetaTrader 4 for a Time Based Pattern Analysis Time based pattern analysis can be used in the currency market to determine a better time to enter a trade or time in which trading should be avoided at all. Here we use MetaTrader 4 to analyze history market data and produce optimization results that can be useful for application in mechanical trading systems. |
|
zzuegg
2010.07.22 13:33
have you preaviously selected the right order? |
|
ubzen
2010.07.22 13:39
![]() |
|
lancelot
2010.07.22 13:55
thanks I will come back with new question?... thank for your answer? |
|
lancelot
2010.07.22 13:58
I tried to close order when the candle stick bar close!!! Do you have any recommendation? |
|
zzuegg
2010.07.22 14:02
common method is to close when new bar opens, which generally is the same price as close of last one. check out the timeseries function. maybe a comparsion between currentBar OpenTime and a previously stored reference time would work fine ;) |
|
lancelot
2010.07.22 14:04
The Idea is to open price when candle stick open and close price when candle stick close I am not sure for this, I am too new for the codes any can give me suggestion so trade every bar.. //+------------------------------------------------------------------+ //---- input parameters //+------------------------------------------------------------------+ int start() candle=iOpen("EURUSD",PERIOD_H1,1); this is my code but it is not right I think |
|
zzuegg
2010.07.22 14:10
if you have a working code for open trade when candle opens you can use the same code to close the order, currentOpen Tick = previousClose Tick here is pseudocode: static time lastBar static time currBar currBar = OpenTimeOfCurrentBar IF lastBar != currBar THEN lastBar = currBar //Here goes code for isA-NewBar ELSE //here goes code for NotA-NewBar |
|
lancelot
2010.07.22 14:25
So my codes in there it is wrong way, right? I think It is when I use iOpen and iClose Proble is : it can't not close when the bar is close: because it is wrong logic as you said. but the code you give me. It is too advance for me, I need time to study.... Thank mate I will come back soon |
|
zzuegg
2010.07.22 14:32
hi, i am having a good day so here is the full mql code: static datetime lastBar=0; //static surpresses that the variable gets overwrited every tick datetime currBar=0; //here static is not neccesary because initialisation is done every tick currBar=Time[0]; if(currBar!=lastBar){ //if time of current Open bar not is (!=) time of the lastOpen, then we have a new Bar lastBar=currBar; //setting oldBarOpenTime to the currentOpenTime //The code here will be executed //at the tick when a new Bar has //formed and the previous closed }else{ //here comes the code which will be //executed in all the ticks between } but please do not only copy and paste this code, but try to understand what every line of code does..-. |
|
Viffer
2010.07.22 14:34
lancelot: candle=iOpen("EURUSD",PERIOD_H1,1); Why don't you just look at the open of the latest bar with the open of the prev bar candle=iOpen("EURUSD",PERIOD_H1,1); candle1=iOpen("EURUSD",PERIOD_H1,0); open is always just the first tick so you won't have to muck about with NewBar. Is any gapping variance going to make any difference on this code? V Oh and as ubzen said, please use the source button. It's difficult to read unformated code and you are less likely to get a response. V |