Strategy tester and closing method problem

 

Hello,

I’d like to programming the following strategy:

1.) If the current H1 bar is in the last half min and the current price is higher than the current bars open + the current bars range * 0.8 then the robot should buy.

2.) The stop is the current bars low.

3.) If the robot bought on the previous bar and the current price (in this case the current means the previous if we compare to the 1.) part’s bar) is higher than the previous bars close then the robot should close the open positions.


if (Ask > Open[0]+(High[0]-Low[0])*0.8  &&  TimeCurrent() >= (Time[0]+59.5*60))
         {
         OrderSend(Symbol(),OP_BUY,1,Ask,0,Low[0]-1*Point,0);
         }
if (Close[1] > Open[1]+(High[1]-Low[1])*0.8 && OrdersTotal()>0  &&  Ask>Close[1])
         {
         for (int i=1; i<=OrdersTotal(); i++)
              {
              if (OrderSelect(i-1,SELECT_BY_POS)==true)
                       {
                       if (OrderType()==0)
                              {
                              int Ticket=OrderTicket();
                              OrderClose(Ticket,1,Bid,0);
                              }
                       }
               }
         }




a.)My first problem is that in the strategy tester no matter what period I set it test just from 2012 jul. 05. So I can set a year or any period it test just from jul. 05…

Is there anybody met this problem before?

b.)The second question is that I checked all the opens and closes on the chart and mostly the close was fine but sometimes the condition where all true but it doesnt close the open orders just some bars later or never. Is there a problem with my close method or what can be the problem?

Hope I was clear and understandable.

Thanks,

David

 
Gotthenut122:

Hello,

I’d like to programm the following strategy:

1.) If the current H1 bar is in the last half min and the current price is higher than the current bars open + the current bars range * 0.8 then the robot should buy.


a.)My first problem is that in the strategy tester no matter what period I set it test just from 2012 jul. 05. So I can set a year or any period it test just from jul. 05…

Is there anybody met this problem before?

b.)The second question is that I checked all the opens and closes on the chart and mostly the close was fine but sometimes the condition where all true but it doesnt close the open orders just some bars later or never. Is there a problem with my close method or what can be the problem?


1. What if there are no ticks in the last 30 seconds of the hour ?

a. you need to get data to cover the period you want to test, use the search on this page top right and you will find sources of data.

b. when closing/deleting orders your loop must count down: Loops and Closing or Deleting Orders

 
RaptorUK:


1. What if there are no ticks in the last 30 seconds of the hour ?

a. you need to get data to cover the period you want to test, use the search on this page top right and you will find sources of data.

b. when closing/deleting orders your loop must count down: Loops and Closing or Deleting Orders


1. If there are no ticks it is not important I think because there will be no open and the condition of close contains that OrderTotal()>0.

But yes I miss some oportuniy in backtesting.

a. Thanks I found a topic about historical data download.

b. Thanks now I got the difference that article was very usefull !

Reason: