Back-testing issue

 

Back-testing issue.

Heres a little problem that i have been experiencing for a long time but haven't bothered to find a solution until now.


My system is based on an hourly chart.

Now lets say my system opens a trade at 19:00 (time). and the TP (or SL) is hit at 21:00. There is no problems here (the TP / SL is hit 2 hours later).


but now lets instead say my system opens a trade at 19:00 and the TP is hit just 20 mins later at 19:20. What happens now is that my system will open another trade essentially the same as the one that was just closed. This is because my system calculates that all conditions (for OrderSend()) are still met and opens another trade (because we're still in the same hour the signal occured).


There is a very a simple way to overcome this, that is:

OrderSend();

Sleep(x);

but obviously sleep() doesnt work in a back test. so im getting seriously inaccurate testing.

How can i prevent my system from opening more than one trade in the same hour without using sleep()?

 
alpha430:


Heres a little problem that i have been experiencing for a long time but haven't bothered to find a solution until now.

My system is based on an hourly chart.


Now lets say my system opens a trade at 19:00 (time). and the TP (or SL) is hit at 21:00. There is no problems here (the TP / SL is hit 2 hours later).

but now lets instead say my system opens a trade at 19:00 and the TP is hit just 20 mins later at 19:20. What happens now is that my system will open another trade essentially the same as the one that was just closed. This is because my system calculates that all conditions (for OrderSend()) are still met and opens another trade (because we're still in the same hour the signal occured).

There is a very a simple way to overcome this, that is:

OrderSend();

Sleep(x);

but obviously sleep() doesnt work in a back test. so im getting seriously inaccurate testing .


How can i prevent my system from opening more than one trade in the same hour without using sleep()?






REALLY I CANT HELP BCOS I DONT KNOW. AM NEW.
but maybe u can help me. i tried using the defaolt macd EA and made some chaanges. in back testing i got some results. but when i attached to my chart EUR/USD 15mins(demo) it isnt making any trades. even though the smiley is there. what am i not doing?pls PLs!
 
when you are trading wit EA and maybe u change profile or account. does the EA stop working?
 
post your question in a new thread.
 
Can anyone help me with my question (post #1)?
 

TimeHour(Time[0]) will give you a value for the current bar.

If you take a trade, find what hour it is. Until the hour changes (new bar), take no more trades.

 

I tried this already. Wrote a function that checks Hour before OrderSend, but the problem still persisted. I will post the code when i get home and maybe theres a flaw in the logic.

Reason: