Hi,
I wrote an indicator that works fine with live data, but it doesn't draw forward on the strategy tester (prints attached).
Can someone please point out what am I getting wrong? I'm looking for answers for days but couldn't find any..
Thank!
It's not related to the Strategy Tester. It doesn't update on a live chart either, it only works on history data.
// On live update this will only be different from 0 on a new candle (=1), is it your intention ? int limit=rates_total-prev_calculated; int to_copy; // Useless as prev_calculated is NEVER greater than rates_total or lower than 0 (this is not allowed by the platform). if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total; else { to_copy=rates_total-prev_calculated; if(prev_calculated>0) to_copy++; } // EMA_Buffer is an indicator buffer, how is it indexed ? What EMA_Buffer values (indexes) the CopyBuffer will update ? CopyBuffer(MA_handle,0,0,to_copy,EMA_Buffer); // ALWAYS check the return value of CopyBuffer(), it can fail. ... // I didn't check further
1. You need to refuse iXXXX functions (iLow and the like) - all these arrays are in OnCalculate
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) {
2. You must discard "ArraySetAsSeries (***, true)
ArraySetAsSeries(BullishBreakerPriceBuffer,true); ArraySetAsSeries(BullishBreakerSLBuffer,true); ArraySetAsSeries(BearishBreakerPriceBuffer,true); ArraySetAsSeries(BearishBreakerSLBuffer,true);
3. You must make a detour not in "+", but in "-"
You need to do this:
//--- detect current position int limit=prev_calculated-1; if(prev_calculated==0) { limit=3 ; ArrayInitialize(BullishBreakerPriceBuffer,NULL); ArrayInitialize(BullishBreakerSLBuffer,NULL); ArrayInitialize(BearishBreakerPriceBuffer,NULL); ArrayInitialize(BearishBreakerSLBuffer,NULL); } *** for(int i=limit;i<total&& !IsStopped() ;i++) { if(IsBullCandle(i-2,open,close) &&
You need to go to "-" -> that is, from the current bar to the left (if you look at the chart)
int limit=prev_calculated-1; if(prev_calculated==0) { limit=numberOfCandles-1; // for half data divide rates total here and minus the number of candles ArrayInitialize(BullishBreakerPriceBuffer,EMPTY_VALUE); ArrayInitialize(BullishBreakerSLBuffer,EMPTY_VALUE); ArrayInitialize(BearishBreakerPriceBuffer,EMPTY_VALUE); ArrayInitialize(BearishBreakerSLBuffer,EMPTY_VALUE); } //--- Bullish Breaker Cycle double buyBreakerPrice=EMPTY_VALUE; double buySL=EMPTY_VALUE; for(int i=limit; i<rates_total && !IsStopped(); i++) { //--- BullishBreakerPriceBuffer[i]=EMPTY_VALUE; BullishBreakerSLBuffer[i]=EMPTY_VALUE; BearishBreakerPriceBuffer[i]=EMPTY_VALUE; BearishBreakerSLBuffer[i]=EMPTY_VALUE; // Left Most Candle i.e. 3rd && Middle Candle i.e. 2nd && 1st Candle i.e. 1st bool bullishPattern1 = IsBullCandle(i,open,close) && IsBearCandle(i-1, open, close) && IsBullCandle(i-2, open, close); bool bullishPattern2 = bullishPattern1 && IsBullCandle(i-3,open,close); if(bullishPattern1 && close[i-2] > high[i-1])
Is it reason why I'm not having plots and data in tester for time period under testing???
Forum on trading, automated trading systems and testing trading strategies
Indicator not plotting on strategy tester
Vladimir Karputov, 2021.07.11 13:10
Draw your patterns in the form of pictures - this will make it much clearer.Have you tried this code? That you coded yourself? Cause upon changing it doesn't show anything.
Forum on trading, automated trading systems and testing trading strategies
Indicator not plotting on strategy tester
Vladimir Karputov, 2021.07.11 13:10
Draw your patterns in the form of pictures - this will make it much clearer.Yeah sure the request should be clear enough to covey the message not that unambiguous one.
Here is the concerned screen shot of one of the pattern that I have code it the indicator. Hope that makes any sense now.
Here is the correct numbering:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I wrote an indicator that works fine with live data, but it doesn't draw forward on the strategy tester (prints attached).
Can someone please point out what am I getting wrong? I'm looking for answers for days but couldn't find any..
Thank!