Is it possible to "change" the logic of a strategy to OHLC?

 

Hi! I was wondering if it is possible to "change the logic" of a strategy to work with OHLC parameters. I'm looking forward this because I have to very different results with the same code on different backtesting modes.

So what I understandis that "the market is telling me that I should do the strategy focused on OHLC and no real ticks"..is my interpretation of this correct? Is this "doable"?

The strategy is nothing fancy, it justs looks to breakouts of the donchian channel. Maybe my code is wrong? Any help will be appreciated!




      upper20 = iHigh(Symbol(),PERIOD_CURRENT,iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,barsBack20,1));
      lower20 = iLow(Symbol(),PERIOD_CURRENT,iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,barsBack20,1));

      upper20 = upper20 + (upper20-lower20)*margin/100;
      lower20 = lower20 - (upper20-lower20)*margin/100;

      upper10 = iHigh(Symbol(),PERIOD_CURRENT,iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,barsBack10,1));
      lower10 = iLow(Symbol(),PERIOD_CURRENT,iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,barsBack10,1));

      upper10 = upper10 + (upper10-lower10)*margin/100;
      lower10 = lower10 - (upper10-lower10)*margin/100;
     

   if(ask>upper20 && sellsOpen==0)
     {
      Sell(0.05);
      }

   if(bid<lower20 && buysOpen==0)
     {
      Buy(0.05);
     }
 

I'm asking because the results based on each mode is way too different. How is an OHLC code looks like?


I'm posting some pics also.

Real tick data:


OHLC mode:


They look almost like if they were flipped. Is there a way to fix this?

 

Do not double/triple post.

I have deleted your other posts.

 
Yes, I think it's possible. You need to make sure that you only make decisions at open or close prices. Everything in between must not be taken into consideration, because the high/low tick contains prediction of the current timeframe's future. If a high/low tick hits SL/TP then be with it.
 
lippmaje:
Yes, I think it's possible. You need to make sure that you only make decisions at open or close prices. Everything in between must not be taken into consideration, because the high/low tick contains prediction of the current timeframe's future. If a high/low tick hits SL/TP then be with it.

But how is a sample code of an OHLC logic? I mean, I'm not using SL/TP directly, I'm using the channel's levels to open and close trades. If the price touches the upper channel then it sells and aims to the lower channel (opposite for buys, same logic). I don't know how it can be so different :/.

Should I wait for a new candle to update the channel values and then buy/sell?

 
Keith Watford:

Do not double/triple post.

I have deleted your other posts.

I'm sorry. I posted on other topics I opened because I'm looking for answers. I just want to learn all this and see if this is possible by any means :(

 
ppsev:

Should I wait for a new candle to update the channel values and then buy/sell?

Yes, make decisions only on open price of candle. Close of candle is 1) harder to detect and 2) almost the same as open, just a tick away, so...

 
lippmaje:

Exactly. Make decisions only on open price of candle. Close of candle is 1) harder to detect and 2) almost the same as open, just a tick away, so...

BTW here's OHLC chart fixed. Have fun.

Ok, I'll see if I can figure it out. How does a ohlc code looks like? Any suggestion?

Ohh wooow! How did you fixed that! Lol hahaha 
 
ppsev:
Ok, I'll see if I can figure it out. How does a ohlc code looks like? Any suggestion?

Check whether a new candle has opened and only work on its first tick.

void OnTick() {
   if (Volume[0]>1) return;
   MakeDecisionsOnFirstTickOfCurrentBar();
}

void MakeDecisionsOnFirstTickOfCurrentBar() {
   FlipChartHorizontal();
   // more crazy stuff
}
Reason: