Hi,
ma=iMA(NULL,7,0,0,MODE_SMA,PRICE_CLOSE,0);
ma2=iMA(NULL,25,0,0,MODE_SMA,PRICE_CLOSE,0);
is not correct. You try to Access MA from Timeframe 7 and Timeframe 25!
look iMA for correct parameters and try again :-)
u get any errors?
Hi!
EADeveloper - can you explain a little bit more? In the code I use ma - ma2 for my indicator. How would I get a moving average of weight x and a moving average of weight y, then do arithmetic operations against them?
qjol - I get no errors! :)
Hi!
EADeveloper - can you explain a little bit more? In the code I use ma - ma2 for my indicator. How would I get a moving average of weight x and a moving average of weight y, then do arithmetic operations against them?
qjol - I get no errors! :)
You was putting the wrong order of parameters..
iMA(NULL,7,0,0,MODE_SMA,PRICE_CLOSE,0); = iMA(Symbol,Period,......
should be
iMA( | string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift) |
You was putting the wrong order of parameters..
iMA(NULL,7,0,0,MODE_SMA,PRICE_CLOSE,0); = iMA(Symbol,Period,......
should be
iMA( | string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift) |
EADeveloper is right, i think u missing the TF parameter & supposed to be
ma=iMA(NULL,0,7,0,0,MODE_SMA,PRICE_CLOSE,0); ma2=iMA(NULL,0,25,0,0,MODE_SMA,PRICE_CLOSE,0); // or any TF u want
Thank you all for the help!
That fixed the program, and now I am able to spend time refining my strategy. ;D
Cheers!
PipfX:
The code compiles, it just won't take action when it is supposed to.
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1); ... if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1); ... if(lot<0.1) lot=0.1
This assumes LotStep is 0.1 and MinLot is 0.1. Any other values breaks the codedouble minLot = MarketInfo(Symbol(), MODE_MINLOT), LotStep = MarketInfo(Symbol(), MODE_LOTSTEP), size = MathFloor(size/LotStep)*LotStep; if (size < minLot){ ...
if(Volume[0]>1) return;
Volume is unreliable, can skip ticksstatic datetime Time0; bool newBar = Time0 < Time[0]; if (!newBar) return(0); Time0 = Time[0];
ma=iMA(NULL,7,0,0,MODE_SMA,PRICE_CLOSE,0); ma2=iMA(NULL,25,0,0,MODE_SMA,PRICE_CLOSE,0);
Under the tester you can not access bar 0 for other timeframes/pairs thus 7,25 are wrong. If you meant length=7,25 then your missing TF=0. Since you're only looking at the start of a bar use ima(...,1) ima(...,0) may change/cross frequently.for(int i=0;i<OrdersTotal();i++) ... if(ma - ma2 >= VarianceBuy) OrderClose(...
Always count down when closing multiple orders, or in the presense of EA's (on other charts) or manual orders.
- 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!
I am a very new programmer and I am having trouble getting my EA to take any actions (Buy, Sell, or Close a trade). Can I get some advice here?
The code compiles, it just won't take action when it is supposed to. I want it to Buy when the requirements for VarianceBuy are met, sell when the requirements for VarianceSell are met, and close the position when ma2 changes direction. Any help would be greatly appreciated!