Results 1 to 2 of 2
 1 Attachment(s)    

Thread: 3sma unbalanced left parenthesis

  1. #1

    Default 3sma unbalanced left parenthesis

    Hi mr funyoo,
    please can you help check this code?I jsut manaahed to put it togetehr.during compilation it keeps giving me the following error:

    /"end of program"-unbalanced left parenthesis,
    Please can you help me fix it?
    also can you help me fix in a usehour code?
    thanks

    //+------------------------------------------------------------------+
    //| 3sma
    //| Copyright 2008, enabu
    //|
    //+------------------------------------------------------------------+


    extern double Lots = 0.01;
    extern double ma_val1;
    extern double ma_val2;
    extern double ma_val3;
    extern int MagicNumber=9055500;
    extern double frame=14;



    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    int start()
    {

    int BuyNum, SellNum; // max order
    int ticket;



    ma_val1=iMA( NULL,0,5,0,0,0,0); // data been put into external variables for easy manipulation

    ma_val2=iMA( NULL,0,15,0,0,0,0); // data been put into external variables for easy manipulation

    ma_val3=iMA( NULL,0,36,0,0,0,0); // data been put into external variables for easy manipulation

    BuyNum = OpenTradesForMNandType(MagicNumber, OP_BUY);
    SellNum = OpenTradesForMNandType(MagicNumber, OP_SELL);

    if (BuyNum >=1 && ma_val1 > ma_val2 CloseAllBuyOrders(MagicNumber);

    if (SellNum >=1 && ma_val1) < ma_val2 CloseAllSellOrders(MagicNumber);



    // Check again after possible closures
    BuyNum = OpenTradesForMNandType(MagicNumber, OP_BUY);
    SellNum = OpenTradesForMNandType(MagicNumber, OP_SELL);

    if (BuyNum == 0 && (ma_val1 > ma_val2 // check for long possibility

    {
    OrderSend(Symbol(),OP_BUY,Lots,Ask, 2,0,0,NULL, MagicNumber , 0,Blue);
    }

    //
    if (SellNum ==0 && (ma_val1 < ma_val2) // check for short possibility

    {
    ticket=OrderSend(Symbol(),OP_SELL, Lots, Bid, 2,0,0,NULL, MagicNumber,0,Red); //sell!
    }



    return(0);


    }

    void CloseAllBuyOrders(int MN)
    {
    int i, iTotalOrders;

    //iTotalOrders=OrdersTotal();
    //for (i=0; i<iTotalOrders; i++)

    iTotalOrders=OrdersTotal()-1; // Rosh line

    for (i=iTotalOrders; i>=0; i--) // Rosh line

    {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
    if (OrderMagicNumber()==MN)
    {
    if (OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,5,Violet) ;
    if (OrderType()==OP_BUYSTOP) OrderDelete(OrderTicket());
    if (OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket());

    }
    }
    }
    }

    void CloseAllSellOrders(int MN)
    {
    int i, iTotalOrders;

    // iTotalOrders=OrdersTotal();
    // for (i=0; i<iTotalOrders; i++)

    iTotalOrders=OrdersTotal()-1; // Rosh line

    for (i=iTotalOrders; i>=0; i--) // Rosh line
    {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
    if (OrderMagicNumber()==MN)
    {
    if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,5,Violet) ;
    if (OrderType()==OP_SELLSTOP) OrderDelete(OrderTicket());
    if (OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket());
    }
    }
    }
    }

    int OpenTradesForMNandType(int iMN, int iType)
    {
    // Counts orders by MagicNumber and OrderType
    int icnt, itotal, retval;


    retval=0;
    itotal=OrdersTotal();

    for(icnt=0;icnt<itotal;icnt++)
    {
    OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES);
    // check for opened position, symbol & MagicNumber
    if(OrderType()==iType)
    {
    if(OrderMagicNumber()==iMN)
    {
    retval++;

    //Print("Orders opened : ",retval);
    }
    }
    }

    return(retval);
    }


    // the end.

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Hi enabu,

    Here it is.
    Attached Files Attached Files

Similar Threads

  1. No equity present in left-side corner of backtest
    By Doodman in forum Expert advisors backtesting
    Replies: 4
    Last Post: 03-04-2012, 23:27

Tags for this Thread

funyoo, magic, sells, sma

Posting Permissions

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