Download MetaTrader 5

calculate the price scale range ( Max-Min)

To add comments, please log in or register
Keith Watford
Moderator
10536
Keith Watford  
Comments that do not relate to the "Please help with one trade per day code", have been moved into this topic.
sherinhamad
8
sherinhamad  

Gentlemen:,

I am newbie , 3 weeks in the making of trading  LOL.


I need a full script that will calculate the price scale range ( Max-Min), then it divides it by the pixel count of the grid then display it in chart window somewhere, and to be dynamic of course if i change scale or visible area,......

I tried to create a script for it, but when I debug it, the chart_price_min display 108 ?????

I don't know what is wrong 


:(

whroeder1
16808
whroeder1  
sherinhamad: I don't know what is wrong
Neither can we; we can't see your broken code; our crystal balls are broken; we're not a mind readers.
nicholishen
1364
nicholishen  
sherinhamad:

Gentlemen:,

I am newbie , 3 weeks in the making of trading  LOL.


I need a full script that will calculate the price scale range ( Max-Min), then it divides it by the pixel count of the grid then display it in chart window somewhere, and to be dynamic of course if i change scale or visible area,......

I tried to create a script for it, but when I debug it, the chart_price_min display 108 ?????

I don't know what is wrong 


:(


This won't work in debug mode because CHART_PRICE_M* returns zero in debug.

void OnStart()
{
   double max = ChartGetDouble(0,CHART_PRICE_MAX);
   double min = ChartGetDouble(0,CHART_PRICE_MIN);
   Print("max= ",max," min= ",min);
   if(min > 0 && max > 0)
   {
      int    height = (int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS);
      int    yBid = int(((max-Bid)/(max-min))*(double)height);
      Print("height = ",height," yBid= ",yBid);
   }
}
To add comments, please log in or register