New to Coding need a little Help - page 3

 
Angel Dickinson:

Sorry mate I just felt like this EA was pretty simple its not too complex


Hi, @Marco vd Heijden has told you something right.

Fortunately, I'm not busy today (^̮^)

 
Yohana Parmi:

hehe.. God help me better than I did (✿´‿`)


Well everything was fine in metaeditor but strategy tester is still bringing up that order close 4051 euro run it through strategy to see for yourself. Shoot I may just leave my EA as entry only if this is too hard cause I have no clue why its giving that error everything looks fine to me

 
Angel Dickinson:

Well everything was fine in metaeditor but strategy tester is still bringing up that order close 4051 euro run it through strategy to see for yourself. Shoot I may just leave my EA as entry only if this is too hard cause I have no clue why its giving that error everything looks fine to me


Actually, you still have logic challenge here :

1.

void OnTick()
{
//---
   if (TotalNoOfOrders() > 0) 
        return;
    

How your EA can close an order? :))


2. You have to select a ticket number before call OrderClose()

 
Yohana Parmi:

Actually, you still have logic challenge here :

1.

How your EA can close an order? :))


2. You have to select a ticket number before call OrderClose()


I knew that had to be the issue remember when I stated that above? lol I just need to learn how to give opened orders a ticket number I'm glad you are teaching me how and not just doing it for me completely. So how do I go by giving my orders a ticket number? is it something like this OrderSelect(result,SELECT_BY_TICKET)? If so where do I place this at the top under TotalNoOforders? What else do I need to define? I'm guessing I would need to define "result" as well what to do then? I know I would need int result=0 correct?

 

in a orderloop its usually

SELECT_BY_POS
 
Marco vd Heijden:

in a orderloop its usually


ok so it would look like this then? OrderSelect(cnt,SELECT_BY_POS, MODE_TRADES)? But how if I need to give orders a ticket number? is this the correct code? I feel like I'm doing something wrong here any help? I thought I would need the result param but instead I switched it to cnt=0 is this correct?

 for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   
         OrderSymbol()==Symbol() &&
         OrderMagicNumber()==MagicNumber
 
   int orders=OrdersTotal();
     {
      for(int pos=orders;pos>0;pos--)
        {
         if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
           {
            Print(" This is the OrderMagicNumber() ",(int)OrderMagicNumber());
              {
               Print(" This is the OrderSymbol() ",OrderSymbol());
                 {
                  Print(" This is the OrderType() ",OrderType());
                    {
                     Print(" This is the OrderLots() ",(double)OrderLots());
                       {
                        Print(" This is the OrderOpenPrice() ",(double)OrderOpenPrice());
                          {
                           Print(" This is the OrderOpenTime() ",(datetime)OrderOpenTime());
                             {
                              Print(" This is the OrderStopLoss() ",(double)OrderStopLoss());
                                {
                                 Print(" This is the OrderTakeProfit() ",(double)OrderTakeProfit());
                                   {
                                    Print(" This is the OrderExpiration() ",(datetime)OrderExpiration());
                                   }
                                }
                             }
                          }
                       }
                    }
                 }
              }
           }
        }
     }
 
Marco vd Heijden:

oh wow I was no where close where does this code go ? Or is this how I should start the code off and input my coding into this? and I have a question why would I need the OrderOpenTime() OrderExpiration() functions for? If the EA doesn't trade based on time only indicators

 

It's an example.

Where are you from?

Maybe i can grab a plane and visit you so that i can point my finger at your screen where the code goes....

Please look in CODEBASE for examples.

Here is a good one: https://www.mql5.com/en/code/viewcode/18803/170499/Tipu_EA.mq4

But there are more: https://www.mql5.com/en/code/viewcode/13147/167356/TrailingStop__1.mq4

Actually there are plenty: https://www.mql5.com/en/code/viewcode/18021/165340/HeikenAshiIdea.mq4

I could sit here all night: https://www.mql5.com/en/code/viewcode/17373/163435/Proper.mq4

But i hope you get the idea.

 
Marco vd Heijden:

It's an example.

Where are you from?

Maybe i can grab a plane and visit you so that i can point my finger at your screen where the code goes....

Please look in CODEBASE for examples.


You have to remember I'm new to this I'm learning as I go and I can't learn by just reading Im a visual learner the coding I made for this EA was based off what I learned or actually what I interpreted from mql book thats why I came here for help not for someone to bash me with insults and try to make me look dumb with all due respect I do appreciate you taking your time to help me with this

Reason: