Check Last Order Type AND Lots???

 

Hello World! :)


i am using the Forex EA Generator. There is a "Check last order type" block. with this you can say "if last order was a buy order than...."


my question is now. is there a solution for "check last order type AND lots"????


i mean:

"if last order was a buy order with 1.00 Lots than......"



here is a litle buy expert. it open a buy order and check the last closed order. if the last closed order was a buy than open sell order


//-------------------------------------------------------------
//  Etasoft Inc. Forex EA and Script Generator version 4.4   EA
//-------------------------------------------------------------
// Keywords: MT4, Forex EA builder, create EA, expert advisor developer

#property copyright "Copyright © 2011, Etasoft Inc. Forex EA Generator v4.4"
#property link      "http://www.forexgenerator.com/"

#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables
extern double BuyLots2 = 1;
extern int BuyStoploss2 = 20;
extern int BuyTakeprofit2 = 30;
extern double SellLots5 = 0.1;
extern int SellStoploss5 = 20;
extern int SellTakeprofit5 = 30;


// local variables
double PipValue=1;    // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n";  // use this in custom or utility blocks where you need line feeds
int NDigits = 4;   // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;

bool FirstTime4 = true;


int init()
{
    NDigits = Digits;
    
    if (false) ObjectsDeleteAll();      // clear the chart
    
    
    Comment("");    // clear the chart
}

// Expert start
int start()
{
    if (Bars < 10)
    {
        Comment("Not enough bars");
        return (0);
    }
    if (Terminated == true)
    {
        Comment("EA Terminated.");
        return (0);
    }
    
    OnEveryTick1();
    
}

void OnEveryTick1()
{
    if (true == false && false) PipValue = 10;
    if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
    
    BuyOrder2();
    CheckLastOrderType4();
    
}

void BuyOrder2()
{
    double SL = Ask - BuyStoploss2*PipValue*Point;
    if (BuyStoploss2 == 0) SL = 0;
    double TP = Ask + BuyTakeprofit2*PipValue*Point;
    if (BuyTakeprofit2 == 0) TP = 0;
    int ticket = -1;
    if (true)
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots2, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
    else
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots2, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
    if (ticket > -1)
    {
        if (true)
        {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
            
    }
    else
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
}

void CheckLastOrderType4()
{
    int orderType = -1;
    int orderId = -1;
    datetime lastCloseTime = 0;
    int cnt = OrdersHistoryTotal();
    for (int i=0; i < cnt; i++)
    {
        if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
        if (OrderSymbol() == Symbol() && lastCloseTime < OrderCloseTime() && (orderId == 1 || true))
        {
            lastCloseTime = OrderCloseTime();
            orderType = OrderType();
            orderId = OrderMagicNumber();
        }
    }
    if (orderType == OP_BUY || FirstTime4)
    {
        FirstTime4 = false;
        SellOrder5();
        
    }
}

void SellOrder5()
{
    double SL = Bid + SellStoploss5*PipValue*Point;
    if (SellStoploss5 == 0) SL = 0;
    double TP = Bid - SellTakeprofit5*PipValue*Point;
    if (SellTakeprofit5 == 0) TP = 0;
    int ticket = -1;
    if (true)
    ticket = OrderSend(Symbol(), OP_SELL, SellLots5, Bid, 4, 0, 0, "My Expert", 1, 0, Red);
    else
    ticket = OrderSend(Symbol(), OP_SELL, SellLots5, Bid, 4, SL, TP, "My Expert", 1, 0, Red);
    if (ticket > -1)
    {
        if (true)
        {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
            
    }
    else
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
}



int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
}

 
cool_max:
my question is now. is there a solution for "check last order type AND lots"????
            lastCloseTime = OrderCloseTime();
            orderType = OrderType();
            orderId = OrderMagicNumber();
            size  = OrderLots();
 
WHRoeder:


wow i am so stupid^^


but. what is with the Variables?
 
No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 
WHRoeder:
No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.

hey, thanks. i will try the job-site in next time.
Reason: