Results 1 to 2 of 2
 2 Attachment(s)    

Thread: A Good Trading System

  1. #1
    Junior Member
    Join Date
    Dec 2009

    Default A Good Trading System

    Hello funyoo,

    I need your help on this EA. Actually I already got system in Amibroker TA.
    I am trying to code same system as Metatrader EA.

    Below is amibroker code(AFL) for system that I want to code as EA.
    no= Param("period",7,1,100,1);

    a = Cross(H,res);
    b = Cross(sup,L);
    eq=Param("0 equity",1,0,1,1);

    state = IIf(BarsSince(a)<BarsSince(b),1,0); //(<<this return 1 or 0 based on condition)


    As you can see there is external parameter ("no") which can be selected by user is in integer value.

    Calculation on lines/variables RES & SUP (Resistance & Support)

    “res” can be calculated using EMA of period 3 & PRICE will be highest high price of last 7 bars. This 7 bars is integer value which set by external parameter by user “no”.
    Same goes for “sup” which is EMA of period 3, But only difference is that price of EMA calculation is lowest low price of last 7 bars.

    Now variable “a” will set to “1” or “0” based on the crossing of current bar high & variable “res”.
    For variable “b” set to “1” or “0” based on the crossing of current bar low & variable “sup”.
    Here is definition of this “CROSS” afl code.

    SYNTAX Cross( ARRAY1, ARRAY2 )
    FUNCTION Gives a "1" or true on the day that ARRAY1 crosses above ARRAY2. Otherwise the result is "0".
    To find out when ARRAY1 crosses below ARRAY2, use the formula cross(ARRAY2, ARRAY1)
    EXAMPLE cross( close, ema(close,9) )
    Now the variable “state” which also can be set to “1” or “0” based on following condition.

    BarsSince(a) : Calculates the number of bars (time periods) that have passed since ARRAY was true (or 1) in this case array was variable “a”

    BarsSince(b) : Calculates the number of bars (time periods) that have passed since ARRAY was true (or 1) in this case array was variable “b”.

    state = IIf(BarsSince(a)<BarsSince(b),1,0);

    FUNCTION "Immediate-IF" - a conditional function that returns the value of the second parameter (TRUE_PART) if the conditional expression defined by the first parameter (EXPRESSION) is true; otherwise, the value of third parameter is returned (FALSE_PART). Please note that IIF is a function - so the result of evaluation is returned by that function and should be assigned to some variable. IIf always evaluates both TRUE_PART and FALSE_PART, even though it returns only one of them. Because of this, you should watch for undesirable side effects. The following example shows one common error made with IIF function: IIF( condition, result = 7, result = 9 ); // THIS IS WRONG Correct usage is: result = IIF( condition, 7, 9 ); /* 7 or 9 is *returned* and assigned to a variable depending on condition */
    EXAMPLE The formula result = iif( macd()<signal(), Volume, -Volume) will assign positive volume values to the result variable on days when macd was below its signal line, and negative volume values on theother days.
    Now I created EA based on above system. But my knowledge with MQL is not good.
    I try to create some MQL code but I am not able to get same results in Metatrader which was I am getting in Amibroker.

    Please download attached MQL code file & Amibroker Trading system chart .

    Note: This system generates buy/sell without vanishing. When buy/sell comes at some point it stays there so no fake signals.

    Thank You
    Attached Images Attached Images A Good Trading System-chart-jpg 
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Dec 2009


    Right now I have coded this MQL code for above system. Only last part of calculating number of bars rremianed.

    val_high=High[iHighest(NULL,60,MODE_HIG H,6,0)]; // highest high
    val_low=Low[iLowest(NULL,60,MODE_LOW, 6,0)]; // lowest Low
    res=iMA(NULL,0,Period_EMA ,0,MODE_EMA,val_high,0); // variable res
    sup=iMA(NULL,0,Period_EMA ,0,MODE_EMA,val_low,0); // variale sup

    if (iHigh(NULL,60,0)>res) // Current bar high crosses above res
    if(sup>iLow(NULL,60,0)) // sup crosses above current bar Low

    if (condition for buy) //
    { //
    Opn_B=true; //
    Cls_S=true; //
    if (condition for sell) //
    { //
    Opn_S=true; //
    Cls_B=true; //
    I want to know how to calculate or start counting number of bars since certain condition true for sometime till false value set. Say current close is greater than moving average close for say 5 bars in 1 hour chart including current bar when condition found to be true. How to calculate this number of "5" bars? I think this will solve my last code of part if I am able to count this numbers of bars after condition true till condition false .

Similar Threads

  1. What trading system is good for gold scalping?
    By sentimentfx in forum Trading discussion
    Replies: 0
    Last Post: 03-27-2015, 17:06
    By jaayazan in forum Ideas for expert advisors
    Replies: 4
    Last Post: 07-15-2013, 13:02
  3. Good manual system, Inidicator needed
    By pippimp in forum Ideas for manual systems
    Replies: 6
    Last Post: 06-07-2013, 09:05
  4. Good system 1 hour
    By forexpop in forum Ideas for manual systems
    Replies: 2
    Last Post: 08-21-2011, 16:37
  5. Good trading system needs coder
    By forexpop in forum Ideas for expert advisors
    Replies: 0
    Last Post: 01-27-2010, 15:16

Tags for this Thread

100, average, funyoo, high, how to, low, macd, metatrader, metatrader ea, moving average, mql, resistance, signal, signals, support, system, time, trading, trading system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts