Download MetaTrader 5

Repainting indicator

To add comments, please log in or register
difenp
354
difenp  
Hello guys. After few days of testing I noticed that the indicator I developed was not working properly. It seems that MT4 already had the M1 timeframe data to feed the indicator, so everything seemed amazingly good in backtest, but when I used icustom to call the indicator into the EA the result was a catastrophe.

I wanted to ask what is the right procedure to rewrite an indicator to read a "technical indicator" like PSAR over three higher timeframes and show if those readings are all in the same direction.

I have been doing this task using ibarshift(), but there we are I got this problem "Lucid Dreams" I would say.

Thank you in advance, Francesco.
whroeder1
16306
whroeder1  
zen4x:
Hello guys. After few days of testing I noticed that the indicator I developed was not working properly. It seems that MT4 already had the M1 timeframe data to feed the indicator, so everything seemed amazingly good in backtest, but when I used icustom to call the indicator into the EA the result was a catastrophe.

I wanted to ask what is the right procedure to rewrite an indicator to read a "technical indicator" like PSAR over three higher timeframes and show if those readings are all in the same direction.
  1. No mind readers here. How can we help when you don't provide any code?
  2. You read the values of the CI using iCustom. Detailed explanation of iCustom - MQL4 forum
  3. You can not read Hi/Lo of bar zero for other TF/pairs in the tester. Testing Features and Limits in MetaTrader 4 - MQL4 Articles
difenp
354
difenp  
WHRoeder:
  1. No mind readers here. How can we help when you don't provide any code?
  2. You read the values of the CI using iCustom. Detailed explanation of iCustom - MQL4 forum
  3. You can not read Hi/Lo of bar zero for other TF/pairs in the tester. Testing Features and Limits in MetaTrader 4 - MQL4 Articles




Hello WHRoeder, thank you for the articles. My only concern is about testing this strategy before to try to go to live trading with it.

I did not want to bother anybody to help me with the code, but I am getting confused.


//+------------------------------------------------------------------+
//|                                         mtf-parabolic-system.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                        Pierfrancesco Di Fenza p.difenza@yahoo.it |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Pierfrancesco Di Fenza"
#property link      "p.difenza@yahoo.it"


#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 2.0
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int thickness = 1;
extern int tmf_1 = 240;
extern int tmf_2 = 60;
extern int tmf_3 = 15;
//extern bool alertEnabled = false;
extern bool debugOn = false;
static double alertBar;

double step = 0.02;
double maximum = 0.2;
double long[];
double short[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0, long);
   SetIndexStyle(0, DRAW_ARROW, EMPTY, thickness);
   SetIndexArrow(0, 117);
   SetIndexEmptyValue(0, 0.0);
   SetIndexBuffer(1, short);
   SetIndexStyle(1, DRAW_ARROW, EMPTY, thickness);
   SetIndexArrow(1, 117);
   SetIndexEmptyValue(1, 0.0);
   IndicatorShortName("Evil Trading System v-1.0");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int detectPsar(double psar, int tmf, int shift) {

   
   if (psar >= iHigh(Symbol(), tmf, shift) ) {
      return (2);
   } 
   
   if (psar <= iLow(Symbol(), tmf, shift) ) {
      return (1);
   }
   
   return (0);
}


int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   
   int totBars, tmf_1_shift, tmf_2_shift, tmf_3_shift;
   double tmf_1_psar, tmf_2_psar, tmp_3_psar;
   
   
   if (counted_bars < 0) counted_bars = 0;
   if (counted_bars > 0) counted_bars--;
   totBars = Bars - counted_bars;
   
   for (int i = 0; i < totBars; i++) {
      
      tmf_1_shift = iBarShift(Symbol(), tmf_1, iTime(Symbol(), 0, i), false);
      tmf_2_shift = iBarShift(Symbol(), tmf_2, iTime(Symbol(), 0, i), false);
      tmf_3_shift = iBarShift(Symbol(), tmf_3, iTime(Symbol(), 0, i), false);
      
      tmf_1_psar = iSAR(Symbol(), tmf_1, step, maximum, tmf_1_shift);
      tmf_2_psar = iSAR(Symbol(), tmf_2, step, maximum, tmf_2_shift);
      tmp_3_psar = iSAR(Symbol(), tmf_3, step, maximum, tmf_3_shift);
      
      
      
      if (detectPsar(tmf_1_psar, tmf_1, tmf_1_shift + 1) == 2 && 
          detectPsar(tmf_2_psar, tmf_2, tmf_2_shift) == 2 && 
          detectPsar(tmp_3_psar, tmf_3, tmf_3_shift) == 2) {
          
          short[i] = 1;
          
          if (alertBar != Time[0] && debugOn == true) {
            alertBar = Time[0];
            Print("status sell" + TimeHour(Time[0]) + ":" + TimeMinute(Time[0]));
          }
          
      }
      
      if (detectPsar(tmf_1_psar, tmf_1, tmf_1_shift + 1) == 1 && 
          detectPsar(tmf_2_psar, tmf_2, tmf_2_shift) == 1 && 
          detectPsar(tmp_3_psar, tmf_3, tmf_3_shift) == 1) {
         
          long[i] = 1;
          
          if (alertBar != Time[0] && debugOn == true) {
            alertBar = Time[0];
            Print("status buy" + TimeHour(Time[0]) + ":" + TimeMinute(Time[0]));
          }
         
      }
      
      
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
difenp
354
difenp  
zen4x:

Hello WHRoeder, thank you for the articles. My only concern is about testing this strategy before to try to go to live trading with it.

I did not want to bother anybody to help me with the code, but I am getting confused.


I did some testing going through different timeframes at time and the indicator does repaints due the problem I mentioned before.

I got two questions now:

How can I really find a way to backtest any MTF strategy.

How can I develop an indicator that helps me to visual backtest this information.

Thank you guys, I hope I did not bother anybody with this topic.

difenp
354
difenp  
zen4x:

I did some testing going through different timeframes at time and the indicator does repaints due the problem I mentioned before.

I got two questions now:

How can I really find a way to backtest any MTF strategy.

How can I develop an indicator that helps me to visual backtest this information.

Thank you guys, I hope I did not bother anybody with this topic.

I post it as job so somebody can help me to save a bit of time.

https://www.mql5.com/en/job/4505

Tjipke de Vries
6405
Tjipke de Vries  
zen4x:

I post it as job so somebody can help me to save a bit of time.

https://www.mql5.com/en/job/4505



This moment there is an error on JOBS MQL5 site so that noone can take part till that error 500 is repaired.

So you have to wait to get respons there....

difenp
354
difenp  
deVries:


This moment there is an error on JOBS MQL5 site so that noone can take part till that error 500 is repaired.

So you have to wait to get respons there....


Hello guys sorry. Again one of the developer of mql5 told me that is does not know how to accomplish this task.

Is there anybody that can help me if is possibly possible to write the indicator and after an EA that works with the SAR on three or timeframes using the 0 index ?

Thank you, Francesco.

To add comments, please log in or register