Change timeframe of the current chart with a script doesn't work

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
371
mar 2015.01.18 21:43 #
 

Please have a look at this picture. I coloured the space where the chart is hidden and on the very right you see a bar. If you see this example and you wanted to analyze that chart and predict where it may go, then you know exactly that price will rise. So your bias will be long because you see that bar. That is the problem. There are 2-3 pixel columns that can't be coloured.

 

If there is no chance to colour the last bar then it is so. I have to live with it and I will use that fixed scale relating to the not-hidden part of the chart. 

avatar
371
mar 2015.01.18 22:42 #
 
I use smaller boxes now and it works. There are no non-hidden pixels left on the very right border. So this is done. Now I finish the expert advisor that will adjust the fixed scale to the visible part of the chart.
avatar
Moderator
3206
angevoyageur 2015.01.18 22:55 #
 
mar:
I use smaller boxes now and it works. There are no non-hidden pixels left on the very right border. So this is done. Now I finish the expert advisor that will adjust the fixed scale to the visible part of the chart.
Good, but I suggest you to use a RECTANGLE_LABEL object, instead of label for this.
avatar
735
honest_knave 2015.01.18 23:49 #
 

You can easily match the color of your rectangle label to the chart background

color BG=(color)ChartGetInteger(0,CHART_COLOR_BACKGROUND)


 

avatar
371
mar 2015.01.19 13:38 #
 

Done! :)

There is just one general thing I would like to improve but I haven't done that before. I only made expert advisors which run on tick. But this is a backtesting/learning expert advisor and so I don't need ticks (I also would like to test at the weekends when no ticks arrive). I saw that there is a possibility to run the expert advisor on a chart event. Because I scroll the chart by pressing F12 I want to use CHARTEVENT_KEYDOWN.

So I wanted to do a test with the keystroke-event but I don't know what's wrong here:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if (id == CHARTEVENT_KEYDOWN && lparam == 123) Alert("F12 pressed"); // F12 pressed?
  }
//+------------------------------------------------------------------+

Can't I just ignore OnTick() ? I only want to run the expert advisor on a keystroke and therefore I need no tick but I guess that's not possible, is it?

avatar
Moderator
3206
angevoyageur 2015.01.19 14:33 #
 
mar:

Done! :)

There is just one general thing I would like to improve but I haven't done that before. I only made expert advisors which run on tick. But this is a backtesting/learning expert advisor and so I don't need ticks (I also would like to test at the weekends when no ticks arrive). I saw that there is a possibility to run the expert advisor on a chart event. Because I scroll the chart by pressing F12 I want to use CHARTEVENT_KEYDOWN.

So I wanted to do a test with the keystroke-event but I don't know what's wrong here:

Can't I just ignore OnTick() ? I only want to run the expert advisor on a keystroke and therefore I need no tick but I guess that's not possible, is it?

Yes it's possible. But F12 is an MT4 predefined shortcut key, you can't use it with CHARTEVENT_KEYDOWN.
avatar
371
mar 2015.01.19 15:49 #
 

Completed! 

Thank you very much for your help! 

Back to topics list   | 1 2  

To add comments, please log in or register