Download MetaTrader 5

CTrailingMA

To add comments, please log in or register
Matus German
2464
Matus German  

I try to use trailing stop but get error 

'CheckTrailingStopLong' - no one of the overloads can be applied to the function call

'CheckTrailingStopShort' - no one of the overloads can be applied to the function call

#include <Trade\PositionInfo.mqh>           
#include <Expert\Trailing\TrailingMA.mqh>

CPositionInfo curPosition;
CTrailingMA trailingStop;

bool CheckTrailingStop()
{
   if(curPosition.Select(Symbol()))
   {
      if(curPosition.PositionType()==POSITION_TYPE_BUY)
         trailingStop.CheckTrailingStopLong(curPosition, curPosition.StopLoss(), curPosition.TakeProfit());
      if(curPosition.PositionType()==POSITION_TYPE_SELL)
         trailingStop.CheckTrailingStopShort(curPosition, curPosition.StopLoss(), curPosition.TakeProfit());
   }
   return true;
}

 

 



Travis Silvers
162
Travis Silvers  

Looks like you are calling with the actual object for curPosition instead of the pointer.

If you look at the documentation for CheckTrailingStopLong  you can see how it should be called.

So in your code it should be  something like:

   if(curPosition.Select(Symbol()))
   {
      if(curPosition.PositionType()==POSITION_TYPE_BUY)
         trailingStop.CheckTrailingStopLong(GetPointer(curPosition), curPosition.StopLoss(), curPosition.TakeProfit());
      if(curPosition.PositionType()==POSITION_TYPE_SELL)
         trailingStop.CheckTrailingStopShort(GetPointer(curPosition), curPosition.StopLoss(), curPosition.TakeProfit());
   }
   return true;
Matus German
2464
Matus German  
firestrand:

Looks like you are calling with the actual object for curPosition instead of the pointer.

If you look at the documentation for CheckTrailingStopLong  you can see how it should be called.

So in your code it should be  something like:

 

not working, same error
Travis Silvers
162
Travis Silvers  

Sorry missed the curPosition StopLoss() and TakeProfit() calls, they return a const double. Take another look at the documentation for how it should be done.

I'm not sure what you are trying to do, you don't it looks like you are duplicating the purpose of CheckTrailingStop()

So looks like you could just call

trailingStop.CheckTrailingStop()

 

 

Matus German
2464
Matus German  
firestrand:

Sorry missed the curPosition StopLoss() and TakeProfit() calls, they return a const double. Take another look at the documentation for how it should be done.

I'm not sure what you are trying to do, you don't it looks like you are duplicating the purpose of CheckTrailingStop()

So looks like you could just call

 

 

not working same error, i want to use the trailing stop class but realy dont know what to do
Matus German
2464
Matus German  
firestrand:

Sorry missed the curPosition StopLoss() and TakeProfit() calls, they return a const double. Take another look at the documentation for how it should be done.

I'm not sure what you are trying to do, you don't it looks like you are duplicating the purpose of CheckTrailingStop()

So looks like you could just call

 

 

i have read wrong your comment i tried trailingStop.CheckTrailingStopLong(); without parameters
and yours trailingStop.CheckTrailingStop() is not defined I think i have there much bigger problem with understanding the whole concept, idea of OOP, Im not good in programing
Travis Silvers
162
Travis Silvers  
Maybe you should consider trying to get some paid help creating the expert you want using the "Jobs" section of this site.
To add comments, please log in or register