I was able to implement the granularity by looking at a sample code provided by this awesome forum. The thing that has me wondering is the fact that I always enter a trade at the top of the hour or a minute past. Please allow me to explain:
I'm doing a strategy that is implemented based on moving average crossover. I do have other things to filter out the bad signals. The chart time-frame that my strategy will be applied to is the hourly. But, I want to enter the trade as soon as possible; hence, I decided to use granularity, which has an inner bar object set to 1 minute to assist with me getting in the trade as soon as possible. Being a trader I know that the moving average can cross anytime during the one hour bar. The example code that I looked at does the same thing with all of the crossovers happening at the top of the bar or a minute past as well as my code. What can I do to fix this?
Another problem that I'm having is with the stop loss. For some reason, I'm always getting out of the trade at the top of the hour. The pips for the stop-loss are correct, but I find it strange that this ALWAYS happens at the top of the hour.
These two things, once I get them fix, should allow me to have a somewhat profitable strategy. I can't wait to start applying the strategy optimizer to get the exact moving averages that work the best.
Comment