Indicators are still new to me but I would look on code pages 1 and 2 and 3 at the standard indicators posted there and choose to study the one closest to what I want to do and edit it (slowly) to fit my purpose.
I already have. I am now looking at MACD code to try and find a way around my problem. Day 2...
Hi There,
I need to remove the price data that the indicator is displaying (separate window) and show plus and minus values that will be above or below a zero line. I have looked at functions MathRound and NormalizeDouble, but I am still confused. I spent all day yesterday trying to solve this problem. :(
If you want to show data about a zero line you need to do it in the separate window . . . trying to do it in the main window is a nightmare . . . you have to scale the data all the time the chart is moving.
Status update...
Okay, so I have figured out how to change the separate window price values from x.xxxxx to -x.x or x.x. All I had to do was swap the variable type from double to int. My intention is to have different levels for TP/SL and support/resistance and trade negative correlations
Problem solved, right? Wrong. Now I cannot see any lines or anything. I am only a newbie at this and still trying to find my feet, I understand some elements of coding.. But I fear this is a bit past my (ahem) knowledge.
I have posted the code, so if anyone wishes to offer a newbie coder a helping hand, then the beers + kebabs are on me..
#property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Gold #property indicator_color2 Lime #property indicator_color3 Gold #property indicator_color4 Red extern string FX_Pair1 = "---------- Enter parameters for FX pair 1 -------------"; extern string simbol_name = "EURUSD"; extern int bars_for_autoscale = 200; extern bool inverse = false; extern bool MA = true; extern int MAPeriod = 1; extern bool MAOnly = true; extern string FX_Pair2 = "---------- Enter parameters for Hedging pair ----------"; extern string simbol_name1 = "USDCHF"; extern int bars_for_autoscale1 = 200; extern bool inverse1 = true; extern bool MA1 = true; extern int MAPeriod1 = 1; extern bool MAOnly1 = true; double simbolBuffer[]; double MABuffer[]; double simbolBuffer1[]; double MABuffer1[]; // èíèöèàëèçàöèÿ int init() { SetIndexBuffer(0,simbolBuffer); SetIndexStyle (0,DRAW_HISTOGRAM); SetIndexBuffer(1,MABuffer); SetIndexBuffer(2,simbolBuffer1); SetIndexStyle (2,DRAW_LINE); SetIndexBuffer(3,MABuffer1); return (0); } int start() { int simbol_scale = 1; int simbol_offset = 0; int simbol_scale1 = 1; int simbol_offset1 = 0; int i,k,i1,k1; int cb=IndicatorCounted(); int cb1=IndicatorCounted(); i = Bars-cb-1; k = bars_for_autoscale; i1 = Bars-cb1-1; k1 = bars_for_autoscale1; if (bars_for_autoscale==0) k=Bars; if (bars_for_autoscale1==0) k1=Bars; int max_scale=iClose(simbol_name,0,1); int min_scale=iClose(simbol_name,0,1); int max_scale2=Close[1]; int min_scale2=Close[1]; int max_scale1=iClose(simbol_name1,0,1); int min_scale1=iClose(simbol_name1,0,1); int max_scale11=Close[1]; int min_scale11=Close[1]; while(k>=0) { if (max_scale<iClose(simbol_name,0,k)) max_scale=iClose(simbol_name,0,k); if (min_scale>iClose(simbol_name,0,k)) min_scale=iClose(simbol_name,0,k); if (max_scale2<Close[k])max_scale2=Close[k]; if (min_scale2>Close[k])min_scale2=Close[k]; k--; } simbol_scale = (max_scale2 - min_scale2)/(max_scale-min_scale); if(!inverse) { simbol_offset = max_scale2 - simbol_scale*max_scale; } else { simbol_offset = max_scale2 + simbol_scale*min_scale; } while(i>=0) { if(!inverse) { if (!MAOnly) simbolBuffer[i]=simbol_scale*(iClose(simbol_name,0,i))+simbol_offset; if (MA)MABuffer[i]=(iMA(simbol_name,0,MAPeriod,0,0,PRICE_CLOSE,i))*simbol_scale+simbol_offset; } else { if (!MAOnly) simbolBuffer[i]=simbol_offset - simbol_scale*(iClose(simbol_name,0,i)); if (MA)MABuffer[i]=simbol_offset - simbol_scale*(iMA(simbol_name,0,MAPeriod,0,0,PRICE_CLOSE,i)); } i--; } //return(0); while(k1>=0) { if (max_scale1<iClose(simbol_name1,0,k1)) max_scale1=iClose(simbol_name1,0,k1); if (min_scale1>iClose(simbol_name1,0,k1)) min_scale1=iClose(simbol_name1,0,k1); if (max_scale1<Close[k1])max_scale1=Close[k1]; if (min_scale1>Close[k1])min_scale1=Close[k1]; k1--; } simbol_scale1 = (max_scale1 - min_scale1)/(max_scale1-min_scale1); if(!inverse1) { simbol_offset1 = max_scale1 - simbol_scale1*max_scale1; } else { simbol_offset1 = max_scale1 + simbol_scale1*min_scale1; } while(i1>=0) { if(!inverse1) { if (!MAOnly1) simbolBuffer1[i1]=simbol_scale1*(iClose(simbol_name1,0,i1))+simbol_offset1; if (MA1)MABuffer1[i1]=(iMA(simbol_name1,0,MAPeriod1,0,0,PRICE_CLOSE,i1))*simbol_scale1+simbol_offset1; } else { if (!MAOnly1) simbolBuffer1[i1]=simbol_offset1 - simbol_scale1*(iClose(simbol_name1,0,i1)); if (MA1)MABuffer1[i1]=simbol_offset1 - simbol_scale1*(iMA(simbol_name1,0,MAPeriod1,0,0,PRICE_CLOSE,i1)); } i1--; } return(0); }
Status update...
Okay, so I have figured out how to change the separate window price values from x.xxxxx to -x.x or x.x. All I had to do was swap the variable type from double to int. My intention is to have different levels for TP/SL and support/resistance and trade negative correlations
Problem solved, right? Wrong. Now I cannot see any lines or anything.
Your lines are probably off chart . . . look at the values in the separate window using the Data Window to check that the values are within range.
The values are
9000000000000000 and -9000000000000000.
Is it worth me putting this question in the job section?
What is the goal?
What is the value range you are charting?
Consider making values a percentage of a range.
*edit - if you had graph paper how would you put the goal on the graph paper?
The values are 9000000000000000 and -9000000000000000.
Is it worth me putting this question in the job section?
- 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 There,
I need to remove the price data that the indicator is displaying (separate window) and show plus and minus values that will be above or below a zero line. I have looked at functions MathRound and NormalizeDouble, but I am still confused. I spent all day yesterday trying to solve this problem. :(
Can someone offer some much needed advice, and could you throw in an example - that would be great?.. I am still learning MQ4, after all..
Many thanks.
DaveFX