Something is not good in this code
  #1 (permalink)  
Old 06-08-2005, 05:10 AM
alp alp is offline
Freshman
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
alp is on a distinguished road
Default Something is not good in this code

This code has not compilation errors but I have a vogue idea that it's not correct. It's a simple EA based on Momentum crossing zero level.
The problem is how to define this zero level in trading logic?
Thanks

Code:
//*---------------------------------------------------------------------------------------------------------*\ // 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 := MomCross Author := Alex Link := Coded_by_FXFisherman_ZeroCode_@www.fxfisherman.com Lots := 1 Stop Loss := 30 Take Profit := 0 Trailing Stop := 30 ]]*/ defines: Slippage(3); defines: ; var: cnt(0),IsBuying(False),IsSelling(False),IsClosing(False),RealTP(0),RealSL(0); var: mom1_1(0),mom1_0(0); // Check for invalid bars and takeprofit If Bars<200 then Exit; // Calculate indicators' value mom1_1 = iMomEx(14,PRICE_CLOSE,1); mom1_0 = iMomEx(14,PRICE_CLOSE,0); // Check for BUY, SELL, and CLOSE signal IsBuying = (mom1_0 > mom1_1) and (mom1_1 < mom1_0); IsSelling = (mom1_0 < mom1_1) and (mom1_1 > mom1_0); IsClosing = False; // 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(cnt,VAL_LOTS),Bid,3,Violet); Alert("MomCross: 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(cnt,VAL_LOTS),Ask,3,Violet); Alert("MomCross: 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*TrailingStop) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Ask+Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROFIT),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("MomCross: 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,RED); Alert("MomCross: Selling"); }; }; //-------------- Coded by FXFisherman ZeroCode v1.0.1982.33196

Last edited by scorpion : 06-08-2005 at 07:15 AM. Reason: Wrap the code in [Code][/Code] block
Reply With Quote
ProFX Powerful Trading System
  #2 (permalink)  
Old 06-08-2005, 07:10 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,958
Thanks: 117
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

alp,

Suppose you want to buy when Mom crosses up 0 and sell when crosses down 0 then:

Buy Logics:
AND Mom (x) Previous < 0
AND Mom (x) Current > 0

Sell Logics:
AND Mom (x) Previous > 0
AND Mom (x) Current < 0
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
Some additional remarks
  #3 (permalink)  
Old 06-08-2005, 07:13 PM
alp alp is offline
Freshman
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
alp is on a distinguished road
Default Some additional remarks

Hello,
Thank you very much Scorpion.

Would it be the same logic with, say, RSI crossing 25 and 75 levels?

It's relatively simple to create EAs using a crossover principle, however if the task is more complex some part of mql code is needed which requires some skill.
Example: ADX crossing on 1D chart. The position is to be opened the next 1 or more days after the +DI/-DI crossing each other on condition that the price breaks out the highest high or the lowest low of the day the crossing has occured (Wilder's rule).
Is it possible for a newbie to make it by means of Zero Code?

Regards,
alp
Reply With Quote
  #4 (permalink)  
Old 06-09-2005, 09:10 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,958
Thanks: 117
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

Quote:
Originally Posted by alp
Would it be the same logic with, say, RSI crossing 25 and 75 levels?
Yes, the same with RSI and others.

Quote:
It's relatively simple to create EAs using a crossover principle, however if the task is more complex some part of mql code is needed which requires some skill.
Example: ADX crossing on 1D chart. The position is to be opened the next 1 or more days after the +DI/-DI crossing each other on condition that the price breaks out the highest high or the lowest low of the day the crossing has occured (Wilder's rule).
Is it possible for a newbie to make it by means of Zero Code?
In this case, ZeroCode is not capable of doing so yet. However, ZeroCode helps you not to start coding from scratch, so you might just need to code only the Highest high/Lowest low breakout checking only.
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Code request : Action breakeven stop Automatic Digs Trading Systems 0 09-24-2006 06:43 AM
Please code this Woodie ZLR trend EA.... Joules360 System Coding 0 08-30-2006 01:26 AM
Systems created with Zero Code beta 1 Belzebut MetaTrader and ZeroCode 19 07-19-2005 07:34 AM
Zero code beta 2 suggestions Belzebut MetaTrader and ZeroCode 0 06-12-2005 09:40 AM
MQL Code Maker scorpion MetaTrader and ZeroCode 42 06-07-2005 03:27 PM


All times are GMT. The time now is 12:10 AM.
Powered by vBulletin Version 3.6.2
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

Main Menu

Economic Forecast