coding error?
  #1 (permalink)  
Old 11-07-2005, 07:16 AM
Freshman
 
Join Date: Nov 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Scicronys is on a distinguished road
Question coding error?

I would like to create a simple expert advisor using ZeroCode that opens and closes orders at the cross of two moving averages. The moving averages I have chosen are EMAs 2 & 20.

I believe I have written the correct buy and sell logics using ZeroCode:

Buy logics:

MA (1) Previous < MA (2) Previous
AND MA (1) Current > MA (2) Current
Vol < 5

Sell logics:

MA (1) Previous > MA (2) Previous
AND MA (1) Current < MA (2) Current
Vol < 5

It is my understanding that 'Vol < 5' means the expert can open a new trade within the current candle. However the problem seems to be with this logic because when I compile my newly created advisor into my experts folder, a .txt file is created and when opened it states:

42;7;1;25;variable not defined - token "Vol"

Here is the system in coded form:

Code:
//*---------------------------------------------------------------------------------------------------------*\ // This MQL is automatically generated by FXFisherman ZeroCode v1.0.2014.30845 (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 := ZeroCode Test System Author := ZeroCoder Link := Coded_by_FXFisherman_ZeroCode_@www.fxfisherman.com Lots := 1 Stop Loss := 40 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(2,MODE_EMA,0,PRICE_CLOSE,1); ma1_0 = iMAEx(2,MODE_EMA,0,PRICE_CLOSE,0); ma2_1 = iMAEx(20,MODE_EMA,0,PRICE_CLOSE,1); ma2_0 = iMAEx(20,MODE_EMA,0,PRICE_CLOSE,0); // Check for BUY, SELL, and CLOSE signal IsBuying = (ma1_1 < ma2_1) and (ma2_0 > ma2_0) and (Vol < 5); IsSelling = (ma1_1 > ma2_1) and (ma1_0 < ma2_0) and (Vol < 5); 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("ZeroCode Test System: 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("ZeroCode Test System: 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("ZeroCode Test System: 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("ZeroCode Test System: Selling"); }; }; //-------------- Coded by FXFisherman ZeroCode v1.0\
If anyone can help it would be much appreciated.
Reply With Quote
  #2 (permalink)  
Old 11-07-2005, 08:24 AM
Freshman
 
Join Date: Nov 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Scicronys is on a distinguished road
Default

Seems to be working fine now with the following adjustments:

Buy logics:

MA (1) Previous < MA (2) Previous
AND MA (1) Current > MA (2) Current
Volume < 5

Sell logics:

MA (1) Previous > MA (2) Previous
AND MA (1) Current < MA (2) Current
Volume < 5

A big thanks to SCORPION for creating ZEROCODE !

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
Coding the takeprofit/stoploss gazuz Trading Systems 5 11-10-2007 06:28 AM
Stochastic system - Error tradetrade Trading Systems 11 07-26-2006 08:14 AM
Coding Needed plz !!!! nnjeim MetaTrader and ZeroCode 5 03-21-2006 10:37 PM
What is this error ? sulz MetaTrader and ZeroCode 5 07-27-2005 05:50 PM


All times are GMT. The time now is 12:36 PM.
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