Systems created with Zero Code beta 1
![]() |
|
|||
|
Hi Belzebut,
wow! great system! Sorry for this silly question. I'm a big zero when it comes to programming! how can I write a logic that will open a trade when the price closes above MA 'x' and close the trade when price closes below MA 'y'? Thanks in advance, Yasir. |
|
||||
|
I can tell you the last trade thing. You see, when you are ttrading without a stoploss, and ( or ) without any exit criteria , there will be some positions , which just wont be profitable. They are summed up in the last trade. So they were opened, but never got to the 100 pips, so trailing stop could not been enabled. Possible solutions:
-Add a stop loss -Add some closing position criteria ( for example , macd is crossing back, or stochastic is closing back and so on ) - Lower the trailing stop level, from say 100 pips to 50 pips. I would prefer a combination of an exit criteria and reduced trailing stop. Only to get the best exit criteria you have to do some research. Let us know how it goes.
__________________
Regards, Ravique |
|
||||
|
Quote:
|
|
||||
|
Well, it is not a bug. C for yourself. If an expert open positions , and has no exit criteria or stopp loss , then theese positions would be open until they will reack take profit , or until they will eat your account up. So the backtester just closes them at the end of backtesting and this last trade shows the actual opened position loss. Maybe someday they will be profitable, they say that the market goes up and down always.
__________________
Regards, Ravique |
|
|||
|
Thank you very much Guys
I created a simple trend following strategy! but when i tried to include both buying and selling logic to one expert, it was not working correct. may be I am wrong. please check this for me. Here is what I wanted, Buy when price closes above 89 ema high close when price closes below 21 em low ------------------------------------- Sell when price closes below 89 ema low close when price closes above 21 ema high ============================== I have attached the expert and screenshots. Please tell me how can I include both logics to one expert. ================================================== ==== //*---------------------------------------------------------------------------------------------------------*\ // This MQL is automatically generated by FXFisherman ZeroCode v1.0.1982.33196 (www.fxfisherman.com) // // DISCLAIMER: // // FXFisherman ZeroCode is provided free of charge, and, therefore, on an "as is" basis, without warranty // of any kind, express or implied, including without limitation the warranties that it is free of defects, // virus free, able to operate on an uninterrupted basis, merchantable, fit for a particular purpose or // non-infringing. In any case, the author(s) will not be responsible or liable for ANY SPECIAL, INCIDENTAL, // CONSEQUENTIAL, INDIRECT OR ANY OTHER LOSSES caused by using of this software. USE IT AT YOUR OWN RISK. // //*-----------------------------------PLEASE DO NOT REMOVE THIS HEADER--------------------------------------*/ /*[[ Name := Trend trader Author := Yasir Link := Coded_by_FXFisherman_ZeroCode_@www.fxfisherman.com Lots := 1 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ defines: Slippage(3); defines: ; var: cnt(0),IsBuying(False),IsSelling(False),IsClosing( False),RealTP(0),RealSL(0); var: ma1_1(0),ma1_0(0),ma2_1(0),ma2_0(0); // Check for invalid bars and takeprofit If Bars<200 then Exit; // Calculate indicators' value ma1_1 = iMAEx(89,MODE_EMA,0,PRICE_HIGH,1); ma1_0 = iMAEx(89,MODE_EMA,0,PRICE_HIGH,0); ma2_1 = iMAEx(21,MODE_EMA,0,PRICE_LOW,1); ma2_0 = iMAEx(21,MODE_EMA,0,PRICE_LOW,0); // Check for BUY, SELL, and CLOSE signal IsBuying = (PriceBid > ma1_0) and (Volume < 10); IsSelling = False; IsClosing = (PriceBid < ma2_0) and (Volume < 10); // Control open trades for cnt=1 to TotalTrades { // Control only market trades not entry order if OrderValue(cnt,VAL_TYPE)<=OP_SELL and OrderValue(cnt,VAL_SYMBOL)=Symbol then { // Check for close signal for bought trade If OrderValue(cnt,VAL_TYPE)=OP_BUY then { If IsSelling or IsClosing then { // Close bought trade CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(c nt,VAL_LOTS),Bid,3,Violet); Alert("Trend trader: Closing BUY order."); }; // Check trailing stop If TrailingStop>0 then { If (Bid-OrderValue(cnt,VAL_OPENPRICE))>(Point*TrailingStop ) then { If OrderValue(cnt,VAL_STOPLOSS)<(Bid-Point*TrailingStop) then { // Modify trailing stop ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue( cnt,VAL_OPENPRICE), Bid-Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROFIT), Red); }; }; }; } else { // Check sold trade for close signal If IsBuying or IsClosing then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(c nt,VAL_LOTS),Ask,3,Violet); Alert("Trend trader: Closing SELL order."); }; // Control trailing stop If TrailingStop>0 then { If (OrderValue(cnt,VAL_OPENPRICE)-Ask)>(Point*TrailingStop) then { If OrderValue(cnt,VAL_STOPLOSS)=0 or OrderValue(cnt,VAL_STOPLOSS)>(Ask+Point*TrailingSt op) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue( cnt,VAL_OPENPRICE), Ask+Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROF IT),Red); }; }; }; }; }; }; // If there is no open trade If TotalTrades<1 then { // If we have enough money for 1 lot If FreeMargin<1000 then Exit; // Check for BUY entry signal If IsBuying and IsSelling=False and IsClosing=False then { // Buy If StopLoss>0 then { RealSL=Ask-StopLoss*Point; } If TakeProfit>0 then { RealTP=Ask+TakeProfit*Point; } SetOrder(OP_BUY,Lots,Ask, Slippage,RealSL,RealTP,RED); Alert("Trend trader: Buying"); }; // Check for SELL entry signal If IsSelling and IsBuying=False and IsClosing=False then { // Sell If StopLoss>0 then { RealSL=Bid+StopLoss*Point; } If TakeProfit>0 then { RealTP=Bid-TakeProfit*Point; } SetOrder(OP_SELL,Lots,Bid,Slippage,RealSL,RealTP,R ED); Alert("Trend trader: Selling"); }; }; //-------------- Coded by FXFisherman ZeroCode v1.0.1982.33196 ================================================== == |
|
||||
|
Hi bezlebut,
Can you post the equity curve of the system? For me the smoothness of that curve is very important. About closing the last open trade. I agree with you it shouldn't be in the calulations. We would need and extra 'unrealized p/l' entry. But the report is medicore are best anyway. Everything is calculated with the amount of cash in your account. ($10000) But in reality the system only uses $1000 + required margin.
__________________
If your system fails just swap long & short :whistling |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Download ZeroCode Beta 1 | scorpion | MetaTrader and ZeroCode | 16 | 06-30-2008 09:40 PM |
| Trading E-Books Download | jgrimney | Tutorials, Tips & Tricks | 46 | 09-28-2007 07:32 PM |
| Zero code beta 2 suggestions | Belzebut | MetaTrader and ZeroCode | 0 | 06-12-2005 09:40 AM |
All times are GMT. The time now is 10:44 PM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now






(normally the trade will be always open but the backtesting processus close it)









Linear Mode

