Results 1 to 10 of 44

Thread: (Ask) my EA only can open sell cannot open order buy

Threaded View

  1. #1
    Junior Member nonamefx is an unknown quantity at this point nonamefx's Avatar
    Join Date
    Jul 2015
    Posts
    1
    Thanks
    0
    Thanked 6 Times in 1 Post
    SubscribeSubscribe
    subscribed 0

    (Ask) my EA only can open sell cannot open order buy

    hello i have created ea yesterday and today i was try to simulator but when i see my ea can't open order buy
    this is my ea code
    Spoiler Spoiler:
    extern int MagicNumber=0;
    extern double Lots =0.01;
    extern double StopLoss=5;
    extern double TakeProfit=100;
    extern int TrailingStop=3;
    extern int Slippage=0;
    //+------------------------------------------------------------------+
    // expert start function
    //+------------------------------------------------------------------+
    int start()
    {
    double MyPoint=Point;
    if(Digits==3 || Digits==5) MyPoint=Point*10;

    double TheStopLoss=0;
    double TheTakeProfit=0;
    if( TotalOrdersCount()==0 )
    {
    int result=0;
    if((iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0)<iMA(NU LL,0,5,0,MODE_SMA,PRICE_CLOSE,0)))
    if((iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,0)>iMA(NUL L,0,5,0,MODE_SMA,PRICE_CLOSE,0))) // Here is your open buy rule
    {
    result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    if((iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0)>iMA(NU LL,0,5,0,MODE_SMA,PRICE_CLOSE,0))) // Here is your open Sell rule
    {
    result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippag e,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    }

    for(int cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()<=OP_SELL &&
    OrderSymbol()==Symbol() &&
    OrderMagicNumber()==MagicNumber
    )
    {
    if(OrderType()==OP_BUY)
    {
    if((iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0)<iMA(NU LL,0,5,0,MODE_SMA,PRICE_CLOSE,0))) //here is your close buy rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
    {
    if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
    return(0);
    }
    }
    }
    }
    else
    {
    if((iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0)<iMA(NU LL,0,5,0,MODE_SMA,PRICE_CLOSE,0))) // here is your close sell rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
    {
    if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyP oint*TrailingStop,OrderTakeProfit(),0,Red);
    return(0);
    }
    }
    }
    }
    }
    }
    return(0);
    }

    int TotalOrdersCount()
    {
    int result=0;
    for(int i=0;i<OrdersTotal();i++)
    {
    OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
    if (OrderMagicNumber()==MagicNumber) result++;

    }
    return (result);

    i hope anyone can solve my problem
    thanks before

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  2. The Following 6 Users Say Thank You to nonamefx For This Useful Post:

    Alizahid (2020-10-20), bahi00 (2020-10-19), Boss12 (2020-10-19), Kanwal (2020-10-19), LOC (2020-10-20), raheel00 (2020-10-19)

Posting Permissions

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

Currently Active UsersCurrently Active Users

There are currently users online. members and guests

Forex Forum India | Forex Community Place Statistics Forex Forum India Statistics

Most users ever online was .

Welcome to our newest member,

Threads:

Posts:

Member: