CTrailingMA

 

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;
}

 

 



 

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;
 
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
 

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()
 
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
 
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
 
Maybe you should consider trying to get some paid help creating the expert you want using the "Jobs" section of this site.
 
Matus German:
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
if(curPosition.PositionType()==POSITION_TYPE_BUY)
         {
           bool trailingStop.CheckTrailingStopLong(GetPointer(curPosition), curPosition.StopLoss(), curPosition.TakeProfit());
         }
        if(curPosition.PositionType()==POSITION_TYPE_SELL)
         {
           bool trailingStop.CheckTrailingStopShort(PositionSelect(_Symbol),StopLoss,TakeProfit);

         }


You should agree the type of obj "bool"

 
hugo zeballos:

Why are you replying to a 10 year old topic?

Don't bring old topics to the top for no good reason.

Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.

Reason: