Error invalid parameters - page 2

 
luisneves:


Hi RaptorUk,

Now the ea is running and I've update the code per your advise.

As soon the error comes I come back.

Here is the information from the Journal tab of the demo account. This error appears here but not on Experts tab.

  

2013.03.27 11:54:53     '2089041584': modify order #6474890 buy 0.01 EURUSDi at 1.27760 sl: 1.27260 tp: 1.28260 -> sl: 1.27787 tp: 1.28260
2013.03.27 11:54:53     '2089041584': modification of order #6474890 buy 0.01 EURUSDi at 1.27760 sl: 1.27260 tp: 1.28260 -> sl: 1.27788 tp: 1.28260 failed [Invalid S/L or T/P]
2013.03.27 11:54:53     '2089041584': modify order #6474890 buy 0.01 EURUSDi at 1.27760 sl: 1.27260 tp: 1.28260 -> sl: 1.27788 tp: 1.28260
2013.03.27 11:54:53     '2089041584': modification of order #6474890 buy 0.01 EURUSDi at 1.27760 sl: 1.27260 tp: 1.28260 -> sl: 1.27789 tp: 1.28260 failed [Invalid S/L or T/P]
2013.03.27 11:54:53     '2089041584': modify order #6474890 buy 0.01 EURUSDi at 1.27760 sl: 1.27260 tp: 1.28260 -> sl: 1.27789 tp: 1.28260
2013.03.27 11:52:50     '2089041584': order #6474890 buy 0.01 EURUSDi at 1.27760 was modified -> sl: 1.27260 tp: 1.28260
2013.03.27 11:52:50     '2089041584': request in process
2013.03.27 11:52:50     '2089041584': request was accepted by server
2013.03.27 11:52:49     '2089041584': modify order #6474890 buy 0.01 EURUSDi at 1.27760 sl: 0.00000 tp: 0.00000 -> sl: 1.27260 tp: 1.28260
2013.03.27 11:52:49     '2089041584': order was opened : #6474890 buy 0.01 EURUSDi at 1.27760 sl: 0.00000 tp: 0.00000
2013.03.27 11:52:49     '2089041584': request in process
2013.03.27 11:52:49     '2089041584': request was accepted by server
2013.03.27 11:52:49     '2089041584': order buy market 0.01 EURUSDi sl: 0.00000 tp: 0.00000
2013.03.27 11:52:49     '2089041584': order #6474680 buy 0.01 EURUSDi at 1.27777 sl: 1.27279 tp: 1.28279 closed at price 1.27757

 

From the Experts tab

2013.03.27 11:54:53     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.27789 Ticket: 6474890Buy Trailing: 1.2779 Stop Loss: 1.2726 Stop Level: 0 Freeze Level: 0
2013.03.27 11:52:50     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.27760Open Buy Price: 1.27760 Ticket: 6474890 Stop Level: 0 Freeze Level: 0
2013.03.27 11:52:50     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Initial Buy order placed 6474890
2013.03.27 11:52:50     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.27760Ticket: 6474890Stop Level: 0Freeze Level: 0
2013.03.27 11:52:50     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6474890 buy 0.01 EURUSDi at 1.27760 sl: 1.27260 tp: 1.28260 ok
2013.03.27 11:52:49     market_order_ecn_80_800_v7_v3 EURUSDi,M1: open #6474890 buy 0.01 EURUSDi at 1.27760 ok
2013.03.27 11:52:49     market_order_ecn_80_800_v7_v3 EURUSDi,M1: close #6474680 buy 0.01 EURUSDi at 1.27777 sl: 1.27279 tp: 1.28279 at price 1.27757
2013.03.27 11:52:49     market_order_ecn_80_800_v7_v3 EURUSDi,M1: close #6474760 sell 0.04 EURUSDi at 1.27757 sl: 1.28250 tp: 1.27250 at price 1.27761
2013.03.27 11:52:48     market_order_ecn_80_800_v7_v3 EURUSDi,M1: close #6474854 buy 0.18 EURUSDi at 1.27783 sl: 1.27278 tp: 1.28278 at price 1.27758
2013.03.27 11:52:48     market_order_ecn_80_800_v7_v3 EURUSDi,M1: close #6474889 sell 0.80 EURUSDi at 1.27758 sl: 1.28259 tp: 1.27259 at price 1.27761
2013.03.27 11:52:48     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Opposite Sell order placed  6474889Open Price: 1.2776
2013.03.27 11:52:48     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.27759 Ticket: 6474889 Stop Level: 0 Freeze Level: 0
2013.03.27 11:52:48     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6474889 sell 0.80 EURUSDi at 1.27758 sl: 1.28259 tp: 1.27259 ok
2013.03.27 11:52:47     market_order_ecn_80_800_v7_v3 EURUSDi,M1: open #6474889 sell 0.80 EURUSDi at 1.27758 ok

 

 Thank you for your time

Luis 

 

 
luisneves:


Hi RaptorUk,

Now the ea is running and I've update the code per your advise.

As soon the error comes I come back.

Here is the code for order modify;  

After a quick look this may be your issue . . .

int TrailingStop = 0.25 + StopLevel;

 . . .  this can't be an int . . .   10 + 0.25 as an int = 10

It's difficult to be sure without all the information though . . . 

This makes no sense . . .  don't convert to points twice . . .

Spread = MarketInfo(Symbol(),MODE_SPREAD)*Point;
      StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;    //  StopLevel is STOPLEVEL in points
      FreezeLevel =MarketInfo(Symbol(),MODE_FREEZELEVEL)*Point;
      TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
      MinimumStop = StopLevel + Spread;


int TrailingStop = 0.25 + StopLevel;                             //  How can you add 0.25 to anything and use an int  to hold the value ? ?
       double BuyTrailing =  Bid - (TrailingStop * pips2dbl);    //  converted to points . . again
       double SellTrailing = Ask + (TrailingStop * pips2dbl);

 Maybe do this instead for clarity . . .

Spread = MarketInfo(Symbol(),MODE_SPREAD)*Point;
      StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);    
      StopLevel.point = StopLevel * Point;              //  StopLevel.point is STOPLEVEL in points

      FreezeLevel = MarketInfo(Symbol(),MODE_FREEZELEVEL);
      FreezeLevel.point = FreezeLevel * Point;

      TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
      MinimumStop = StopLevel + Spread;


double TrailingStop = 0.25 + StopLevel;                          //  this  MUST   be a double ! ! !
       double BuyTrailing =  Bid - (TrailingStop * pips2dbl);    
       double SellTrailing = Ask + (TrailingStop * pips2dbl);
 
RaptorUK:

After a quick look this may be your issue . . .

 . . .  this can't be an int . . .   10 + 0.25 as an int = 10

It's difficult to be sure without all the information though . . . 

This makes no sense . . .  don't convert to points twice . . .

 Maybe do this instead for clarity . . .


Hi RaptorUK,

 Is the code that follows the right one to get the total OrderPprofit ?

I mean, if the result is the same that the AccountProfit() but in this case just limited to the orders that the ea is processing. 

 

void GetTotalOrderProfit()
       {//0
       TotalOrderProfit = 0;
       int TotalOrders;
       
       for(int Orders = OrdersTotal()-1; Orders >= 0; Orders--)       
          {//1
          if(!OrderSelect(Orders,SELECT_BY_POS,MODE_TRADES))continue;
            {//2
            if(OrderSymbol() == Symbol()&& OrderMagicNumber() == MagicNumber)            
              {//3
               TotalOrders++;
               TotalOrderProfit += OrderProfit() + OrderCommission() + OrderSwap();                                       
              }//3          
           }//2
        }//1
     }//0                  
      

Thank you for clarification.

Luis 

 
luisneves:


Hi RaptorUK,

 Is the code that follows the right one to get the total OrderPprofit ?

I mean, if the result is the same that the AccountProfit() but in this case just limited to the orders that the ea is processing. 

It looks OK . . .   but haven't we just totally jumped to a different subject ?  what about the OrderModify() issues ? 
 
RaptorUK:
It looks OK . . .   but haven't we just totally jumped to a different subject ?  what about the OrderModify() issues ? 


Hi RaptorUk,

Yes, I'am testing the ea on demo account and waiting for an error to appear. Once the error appear I will come back with the issue. The error do not appear always and now the ea have is code updated per your recommendations.

Thank you for your concern in keep support me.

Best regards

Luis 

 

Update: Seems that the error comes when the spread increase and in case that the spread value is at least equal to the opposite distance that forces the other order to open and then the error appears....That occurred just now.

Need to scratch my head to find a way that is spread proof....... 

 Here is the Log from experts tab;

 

2013.03.27 21:01:09     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.2779 Ticket: -1 Stop Level: 0Freeze Level: 0
2013.03.27 21:01:09     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Alert: Opposite Sell Failed 0: no error
2013.03.27 21:01:09     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Opposite Sell Order Failed 4051
2013.03.27 21:01:09     market_order_ecn_80_800_v7_v3 EURUSDi,M1: invalid lots amount for OrderSend function  < --------------------------------------
2013.03.27 21:01:08     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.27820Open Buy Price: 1.27820 Ticket: 6491837 Stop Level: 0 Freeze Level: 0
2013.03.27 21:01:08     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Initial Buy order placed 6491837
2013.03.27 21:01:08     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.27820Ticket: 6491837Stop Level: 0Freeze Level: 0
2013.03.27 21:01:08     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6491837 buy 0.01 EURUSDi at 1.27820 sl: 1.27320 tp: 1.28320 ok
2013.03.27 21:01:08     market_order_ecn_80_800_v7_v3 EURUSDi,M1: open #6491837 buy 0.01 EURUSDi at 1.27820 ok
2013.03.27 21:01:07     market_order_ecn_80_800_v7_v3 EURUSDi,M1: close #6491691 buy 0.01 EURUSDi at 1.27810 sl: 1.27310 tp: 1.28310 at price 1.27788
 
luisneves:


Update: Seems that the error comes when the spread increase and in case that the spread value is at least equal to the opposite distance that forces the other order to open and then the error appears....That occurred just now.

Need to scratch my head to find a way that is spread proof....... 

 Here is the Log from experts tab;

That is something else,  that is a problem with an Ordersend() not an OrderModify()  you are not printing the position size as part of the error reporting,  you need to print all the information you need so that after the event you can diagnose the issue . . .  you only see why error reporting is so important when you have an issue and you don't have the information you need to understand what is causing the issue.
 
RaptorUK:
That is something else,  that is a problem with an Ordersend() not an OrderModify()  you are not printing the position size as part of the error reporting,  you need to print all the information you need so that after the event you can diagnose the issue . . .  you only see why error reporting is so important when you have an issue and you don't have the information you need to understand what is causing the issue.


Hi RaptorUK,

So, the error appears again. follows are the logs from Journal and Experts tabs. 

I've update the error routine with more information as Lotsize for the Initial orders and MLots from the Opposite orders as well spread for both. 

From Journal an error appears but from the Experts there is no information for the same order....... 


From Journal

 

2013.03.28 10:50:46     '2089041584': request in process
2013.03.28 10:50:13     '2089041584': modify order #6514480 buy 0.01 EURUSDi at 1.28049 sl: 1.28066 tp: 1.28553 -> sl: 1.28067 tp: 1.28553
2013.03.28 10:50:12     '2089041584': order #6514480 buy 0.01 EURUSDi at 1.28049 was modified -> sl: 1.28066 tp: 1.28553
2013.03.28 10:50:12     '2089041584': request in process
2013.03.28 10:50:12     '2089041584': request was accepted by server
2013.03.28 10:50:12     '2089041584': modify order #6514480 buy 0.01 EURUSDi at 1.28049 sl: 1.27553 tp: 1.28553 -> sl: 1.28066 tp: 1.28553
2013.03.28 10:50:11     '2089041584': modification of order #6514480 buy 0.01 EURUSDi at 1.28049 sl: 1.27553 tp: 1.28553 -> sl: 1.28069 tp: 1.28553 failed [Invalid S/L or T/P]<-------------------------------
2013.03.28 10:50:11     '2089041584': modify order #6514480 buy 0.01 EURUSDi at 1.28049 sl: 1.27553 tp: 1.28553 -> sl: 1.28069 tp: 1.28553
2013.03.28 10:49:02     '2089041584': order #6514480 buy 0.01 EURUSDi at 1.28049 was modified -> sl: 1.27553 tp: 1.28553
2013.03.28 10:49:02     '2089041584': request in process
2013.03.28 10:49:02     '2089041584': request was accepted by server
2013.03.28 10:49:01     '2089041584': modify order #6514480 buy 0.01 EURUSDi at 1.28049 sl: 0.00000 tp: 0.00000 -> sl: 1.27553 tp: 1.28553
2013.03.28 10:49:01     '2089041584': order was opened : #6514480 buy 0.01 EURUSDi at 1.28049 sl: 0.00000 tp: 0.00000
2013.03.28 10:49:01     '2089041584': request in process
2013.03.28 10:49:01     '2089041584': request was accepted by server
2013.03.28 10:49:01     '2089041584': order buy market 0.01 EURUSDi sl: 0.00000 tp: 0.00000
2013.03.28 10:48:57     '2089041584': order #6514445 buy 0.01 EURUSDi at 1.28029 was modified -> sl: 1.28050 tp: 1.28529

From Experts;

 

2013.03.28 10:50:11     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.28071 Ticket: 6514480Buy Trailing: 1.2807 Stop Loss: 1.2755Spread: 0 Stop Level: 0 Freeze Level: 0
2013.03.28 10:49:02     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.28053Open Buy Price: 1.28049Lots: 0.01 Ticket: 6514480Spread: 0 Stop Level: 0 Freeze Level: 0
2013.03.28 10:49:02     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Initial Buy order placed 6514480
2013.03.28 10:49:02     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.28053Ticket: 6514480Spread: 0Lots: 0.04Stop Level: 0Freeze Level: 0<---------------------------------
2013.03.28 10:49:02     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6514480 buy 0.01 EURUSDi at 1.28049 sl: 1.27553 tp: 1.28553 ok
2013.03.28 10:49:01     market_order_ecn_80_800_v7_v3 EURUSDi,M1: open #6514480 buy 0.01 EURUSDi at 1.28049 ok
2013.03.28 10:48:57     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.28052 Ticket: 6514445Buy Trailing: 1.2805 Stop Loss: 1.2805Spread: 0 Stop Level: 0 Freeze Level: 0
2013.03.28 10:48:57     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6514445 buy 0.01 EURUSDi at 1.28029 sl: 1.28050 tp: 1.28529 ok
2013.03.28 10:48:57     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.28049 Ticket: 6514445Buy Trailing: 1.2805 Stop Loss: 1.2753Spread: 0 Stop Level: 0 Freeze Level: 0
2013.03.28 10:48:57     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6514445 buy 0.01 EURUSDi at 1.28029 sl: 1.28047 tp: 1.28529 ok
2013.03.28 10:48:18     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.28029Open Buy Price: 1.28029Lots: 0.01 Ticket: 6514445Spread: 0 Stop Level: 0 Freeze Level: 0
2013.03.28 10:48:18     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Initial Buy order placed 6514445
2013.03.28 10:48:18     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Ask: 1.28029Ticket: 6514445Spread: 0Lots: 0.04Stop Level: 0Freeze Level: 0
2013.03.28 10:48:18     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6514445 buy 0.01 EURUSDi at 1.28029 sl: 1.27529 tp: 1.28529 ok
2013.03.28 10:48:18     market_order_ecn_80_800_v7_v3 EURUSDi,M1: open #6514445 buy 0.01 EURUSDi at 1.28029 ok
2013.03.28 10:48:16     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.28030 Ticket: 6514401Buy Trailing: 1.2803 Stop Loss: 1.2803Spread: 0 Stop Level: 0 Freeze Level: 0
2013.03.28 10:48:16     market_order_ecn_80_800_v7_v3 EURUSDi,M1: modify #6514401 buy 0.01 EURUSDi at 1.28010 sl: 1.28028 tp: 1.28510 ok

 Thank you in advance for support provided.

Luis 

 
luisneves:


Hi RaptorUK,

So, the error appears again. follows are the logs from Journal and Experts tabs. 

I've update the error routine with more information as Lotsize for the Initial orders and MLots from the Opposite orders as well spread for both. 

From Journal an error appears but from the Experts there is no information for the same order....... 

This means you are not printing the required information to the log . . .  so we still don't know what the error number was,  or any other needed information.  It is critical that you sort out your error reporting and test it on Several Brokers so that you know it is working as it should . . .  when you have an error it is all you have to determine the cause.

In the mean time lets look at the information you do have:

You have this:

2013.03.28 10:50:11     '2089041584': modification of order #6514480 buy 0.01 EURUSDi at 1.28049 sl: 1.27553 tp: 1.28553 -> sl: 1.28069 tp: 1.28553 failed [Invalid S/L or T/P]

 and this:

2013.03.28 10:50:11     market_order_ecn_80_800_v7_v3 EURUSDi,M1: Bid: 1.28071 Ticket: 6514480 Buy Trailing: 1.2807 Stop Loss: 1.2755 Spread: 0 Stop Level: 0 Freeze Level: 0

Note:  not the line you marked,  check the date and time at the start of the line.

What do we know:

  • it was an OP_BUY
  • Bid price was  Bid: 1.28071
  • SL was 1.27533
  • new SL was 1.28069
  • Stop Level and Freeze Level are 0

You also report that the  Spread: 0   which it obviously isn't,  are your Freeze Level and Stop Levels also wrong ?  why are you reporting the Spread incorrectly ?  why do you only have 4 digits for the Trailing and Stop Loss figures ?  

Buy Trailing: 1.2807 Stop Loss: 1.2755

Perhaps your Bid and Ask are becoming out of date ? you can determine this by printing Bid, Ask,  MarketInfo(Symbol(), MODE_BID) and  MarketInfo(Symbol(), MODE_ASK)  when a function fails that could be as a result of stale Bid or Ask.

 

You cannot write code that will never experience an issue you had not thought of . . .  even the best coders will have issues, what is important is how you handle these issues.   You cannot go back in time and see what happened,  the best you can do is to print all the information you need when you detect a problem,  so when a function fails print ALL the info you are going to need when you come to diagnose the problem later on.

You need to do this for ALL your major Trading Function calls, OrderSend(),  OrderModify(),  OrderClose(),  OrderDelete() & OrderCloseBy()

 
RaptorUK:

This means you are not printing the required information to the log . . .  so we still don't know what the error number was,  or any other needed information.  It is critical that you sort out your error reporting and test it on Several Brokers so that you know it is working as it should . . .  when you have an error it is all you have to determine the cause.

In the mean time lets look at the information you do have:

You have this:

 and this:

Note:  not the line you marked,  check the date and time at the start of the line.

What do we know:

  • it was an OP_BUY
  • Bid price was  Bid: 1.28071
  • SL was 1.27533
  • new SL was 1.28069
  • Stop Level and Freeze Level are 0

You also report that the  Spread: 0   which it obviously isn't,  are your Freeze Level and Stop Levels also wrong ?  why are you reporting the Spread incorrectly ?  why do you only have 4 digits for the Trailing and Stop Loss figures ?  

Perhaps your Bid and Ask are becoming out of date ? you can determine this by printing Bid, Ask,  MarketInfo(Symbol(), MODE_BID) and  MarketInfo(Symbol(), MODE_ASK)  when a function fails that could be as a result of stale Bid or Ask.

 

You cannot write code that will never experience an issue you had not thought of . . .  even the best coders will have issues, what is important is how you handle these issues.   You cannot go back in time and see what happened,  the best you can do is to print all the information you need when you detect a problem,  so when a function fails print ALL the info you are going to need when you come to diagnose the problem later on.

You need to do this for ALL your major Trading Function calls, OrderSend(),  OrderModify(),  OrderClose(),  OrderDelete() & OrderCloseBy()

Hi RaptorUK,

Thank you for your time in support  me.

Regarding the spread and as far I understand that information comes from;

Spread = MarketInfo(Symbol(),MODE_SPREAD);

 So, why this line of code do not return the spread value as should ?

Is there other way to get the spread value ?

Regarding Bid and Ask don't these values are updated if one use RefreshRates(); just on the line where theses values are  and in such case there is not the need to use the markinfo ?

Nevertheless I go update the error line to include these information of Bid and Ask, as well get the right way to get these values using doubleToStr.

Another issue that  keeps me confused is how the error appear in Journal and not in Experts tabs. 

 

By the way, the code as is now regarding Ask  and Bid is;

DoubleToStr(Ask,Digits)

How can I include 

MarketInfo(Symbol(),MODE_ASK)

 Regarding your advise about;

Spread = MarketInfo(Symbol(),MODE_SPREAD)*Point;
      StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);    
      StopLevel.point = StopLevel * Point;              //  StopLevel.point is STOPLEVEL in points

      FreezeLevel = MarketInfo(Symbol(),MODE_FREEZELEVEL);
      FreezeLevel.point = FreezeLevel * Point;

      TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
      MinimumStop = StopLevel + Spread;


double TrailingStop = 0.25 + StopLevel;                          //  this  MUST   be a double ! ! !
       double BuyTrailing =  Bid - (TrailingStop * pips2dbl);    
       double SellTrailing = Ask + (TrailingStop * pips2dbl);

 Am confused. Should I use;

StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL); 

 or;

StopLevel.point = StopLevel * Point; 

 

 Thank you for keep support me

Luis 

 
luisneves:

Hi RaptorUK,

Thank you for your time in support  me.

Regarding the spread and as far I understand that information comes from;

I'm not sure how you are getting 0 for the Spread,  are you multiplying the figure from MarketInfo() by point ?  or just using the value as it is ?  the Spread is also Ask - Bid.

Bid and Ask are updated by using RefreshRates(),  if you use MarketInfo() to get Bid and Ask you don't need to use RefreshRates() . . .  either method is OK but you need to be aware of when prices can become out of date and then take precautions to guard against it happening.

luisneves:


By the way, the code as is now regarding Ask  and Bid is;

DoubleToStr(Ask,Digits)

How can I include 

MarketInfo(Symbol(),MODE_ASK)

You can do this . . .

DoubleToStr( MarketInfo( Symbol(),MODE_ASK ), Digits )
luisneves:


 Regarding your advise about;

 Am confused. Should I use;

StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL); 

 or;

StopLevel.point = StopLevel * Point; 

You can use either,  you need to understand the difference though.  StopLevel  is the STOPLEVEL expressed as a number of points,  so a STOPLEVEL of 10 is 10 points, the value is 10.    StopLevel.point for the same STOPLEVEL is 0.0001

I would use the code as you have posted it above . . . with some additional changes.

      Spread = MarketInfo(Symbol(),MODE_SPREAD);  //  change this line
      Spread.point = Spread * Point;              //  add this line

      StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);    
      StopLevel.point = StopLevel * Point;              //  StopLevel.point is STOPLEVEL in points

      FreezeLevel = MarketInfo(Symbol(),MODE_FREEZELEVEL);
      FreezeLevel.point = FreezeLevel * Point;

      TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
      MinimumStop = StopLevel.point + Spread.point;     //  this is a price value so we use the .point values


double TrailingStop = 0.25 + StopLevel;                          //  this  MUST   be a double ! ! !
       double BuyTrailing =  Bid - (TrailingStop * pips2dbl);    
       double SellTrailing = Ask + (TrailingStop * pips2dbl);

 

I think the issue with the Spread showing as 0 will be fixed if you use DoubleToStr(x, Digits) with the variable,  any variables that are price values must be used with DoubleToStr(x, Digits).  So if you print FreezeLevel you can do it without DoubleToStr(x, Digits),  if you print FreezeLevel.point you must use DoubleToStr(x, Digits) . . .    do you see the difference ? 

Reason: