| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
||||
|
Need help with coding ease of movement indicator
I tried to code it myself but the indicator line doesn't show in the indicator window when I run it. If you go here MANUAL - TECHNICAL INDICATORS it has a definition of the indicator with the formula for calculating it.
Here's the code I have written: //+------------------------------------------------------------------+ //| Ease of Movement.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| Forex Trading Software: Forex Trading Platform MetaTrader 4 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_minimum -50 #property indicator_maximum 50 #property indicator_buffers 1 #property indicator_color1 Yellow //---- buffers double ExtMapBuffer1[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); string short_name = "Ease of Movement"; IndicatorShortName(short_name); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //----check for errors if (counted_bars<0) return(-1); //----last counted bar will be recounted if (counted_bars>0) counted_bars--; int k = Bars - counted_bars; double midptT, midptY, boxR, midptM, EMV; while (k>0) { midptT = (High[k] + Low[k])/2; midptY = (High[k+1] + Low[k+1])/2; midptM = midptT - midptY; boxR = Volume[k]/(High[k] - Low[k]); EMV = midptM / boxR; ExtMapBuffer1[k] = EMV; k--; } return(0); } //+------------------------------------------------------------------+ can anyone tell me what I'm doing wrong? I attached the indicator too if you want to try to run it for yourself.
__________________
"Duct tape is like the force: it has a dark side and a light side, and it holds the universe together." |
|
||||
|
Quote:
Something like this: if ( long2 == true) { Ordersend(); { Print(" long2 signal taken "); } } Hope that helps. ![]() |
|
||||
|
Thanks Wolfe
I had to laugh I put in what you suggested and it worked sort of but now I only have the comment and no positions opening. any hints bool Long = MAofRSI11>MAofRSI21 && MAofRSI12<=MAofRSI22 && VolCH>VolHL && RSIndex1<HLM && RSIndex1>HL2 && TrStop<Close[shift] && MOM>0.0 && SDLL && ma<Close[shift]; bool Short = MAofRSI11<MAofRSI21 && MAofRSI12>=MAofRSI22 && VolCH>VolHL && RSIndex1<HL1 && RSIndex1>HLM && TrStop>Close[shift] && MOM<0.0 && SDLS && ma>Close[shift]; bool Long2 = MAofRSI11>HLM && MAofRSI12<=HLM && MAofRSI21>HLM && MAofRSI22<=HLM && VolCH>VolHL && TrStop<Close[shift] && MOM>0.0 && SDLL && ma<Close[shift]; bool Short2 = MAofRSI11<HLM && MAofRSI12>=HLM && MAofRSI21<HLM && MAofRSI22>=HLM && VolCH>VolHL && TrStop>Close[shift] && MOM<0.0 && SDLS && ma>Close[shift]; bool Long3 = RSIndex1-RSIndex2>20<HL2 && TrStop<Close[shift] && MOM>0.0 && SDLL && ma<Close[shift]; bool Short3 = RSIndex2-RSIndex1>20>HL1 && TrStop>Close[shift] && MOM<0.0 && SDLS && ma>Close[shift]; bool Long4 = zscore>0.0 && ma<Close[shift]; bool Short4 = zscore<0.0 && ma>Close[shift]; buysig = Long || Long2 || Long3 || Long4; sellsig = Short || Short2 || Short3 || Short4; closebuy=sellsig; closesell=buysig; if (curprof>=AccountBalance()*ProfitExit/100.0) { exit=true; } if (last>0 && (Time[0]-last)/(Period()*60)>=CancelOrderBars) { remorder=true; } } void CheckForOpen() { int res,tr; //---- sell conditions co=CalculateCurrentOrders(Symbol()); if(sellsig && lastsig!=-1) { co=CalculateCurrentOrders(Symbol()); if (co==0) { if ( Short == true) if ( Short2 == true) if ( Short3 == true) res = OpenStop(OP_SELLSTOP,LotsRisk(StopLoss), Low[shift]-OrderPipsDiff*Point, StopLoss, TakeProfit1); Print(" Short signal taken "); Print(" Short2 signal taken "); Print(" Short3 signal taken "); Print(" Short4 signal taken "); } lastsig=-1; last=Time[0]; return; } //---- buy conditions if(buysig && lastsig!=1) { co=CalculateCurrentOrders(Symbol()); if (co==0) { if ( Long == true) if ( Long2 == true) if ( Long3 == true) if ( Long4 == true) res = OpenStop(OP_BUYSTOP,LotsRisk(StopLoss), High[shift]+OrderPipsDiff*Point, StopLoss, TakeProfit1); Print(" Long signal taken "); Print(" Long2 signal taken "); Print(" Long3 signal taken "); Print(" Long4 signal taken "); } last=Time[0]; lastsig=1; return; } } Fixed it Thanks Last edited by Beno; 12-08-2007 at 04:37 PM. |
|
||||
|
Debugging code
How and where would you use a bit of code like this. I have a Zero divide error that I can't find how the fix.
extern bool DEBUGGING = true ... if(DEBUGGING && variableName == 0) Print("CodePoint 1 -- This variable is now ", variableName); ... more code if(DEBUGGING && variableName == 0) Print("CodePoint 2 -- This variable is now ", variableName); ... more code if(DEBUGGING && variableName == 0) Print("CodePoint 3 -- This variable is now ", variableName); ... |
|
|||
|
can you help me?why there are many mistakes in the code?
this is to calculate SMMA:
for(j=0;j<Bars;j++) { for(i=0,sum=0;i<ma_period;i++) { sum=sum+Close[j+i]; // buffer[j]=(sum-sum/ma_period+Close[j+i])/ma_period; } buffer[j]=(sum-sum/ma_period+Close[j])/ma_period; } this is to calculate LWMA for(j=0;j<Bars;j++) { for(i=0,sum=0,sum1=0;i<ma_period;i++) { sum=sum+Close[j+i]; sum1=sum1+Close[j+i]*(j+i); // buffer[j]=sum/ma_period; } buffer[j]=sum1/sum; } and how to calculate EMA? ![]() ![]() ![]() |
|
||||
|
question on indicators
Hi everyone.
I am stuck on a programming issue. Does anyone know how to use 1 indicator result to change another setting? For example, if the daily stockasti was above 20, I would want a moving average of (x). I tried to get the code working below but to know avail. I don't seem to be able to get the switch or if else command to work eithor. double fourhrUP; double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,1); double daystoch20 = 20; if (daystoch1 > daystoch20) four_hrUP = 5 ; double iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift) |
|
|||
|
Quote:
Maybe this could help double ma4hr=iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift); if the stoch calculation is in the same loop, let say "for(int shift=limit-1; shift>=0; shift--)", the stoch code should be double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,shift+1); CMIIW
__________________
Need a professional MQL4 programmer? PM me Last edited by Devil2000; 12-10-2007 at 04:25 AM. |
|
|||
|
Hello.
I am looking for EA that copies a pending order and makes it muptiple with exactly the same conditions. For example, let's say I have a pending order USD/JPY entry-stop sell 1 lot at 115.00, and I wanna have 5 same orders. I do not wanna merely increase the trade size, instead of having multiple positions with the same conditions. Is there an EA that does such a thing for me? Also, I tried e-Trailing.mq4 but I could not place the trailing stop for multiple orders. I need to place a trailing stop at 5 pips from the current price, for multiple open orders. Any good EA for it? Regards Last edited by Hisashi; 12-10-2007 at 01:53 PM. |
|
|||
|
A Little Help with an Indicator - Coder's Please Look
I am testing an MT4 Broker's Platform that uses Fractional Pips (pipettes) in it's price quotations: For Example on EURJPY they quote as 164.381 instead of 164.38 - This means that the spread has a decimal such as 4.1 pips (instead of 4).
Can anyone tell me how to MODIFY the following code so that the Spread reads properly? Right now a 4.1 pip spread would read as 41.0 in the Indicator. Any help is appreciated. Dan //---- spread Spread=NormalizeDouble((Ask-Bid)/Point,1); ObjectSetText("Spread Monitor1","Spread:", 10, "Arial", labelColor); ObjectSetText("Spread Monitor2",DoubleToStr(Spread,1),10, "Arial", clockColor); |
![]() |
| Bookmarks |
| Tags |
| candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
|
||||
| Posted By | For | Type | Date | |
| Need an experienced programmer? - Page 2 | Post #0 | Refback | 09-24-2008 07:24 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 05:22 PM |