CTrade is what is often termed a "wrapper", in order words it is a simple packaging of like functions into the one class, with a few checks. The documentation at the top of each method is sufficient to work out how the class is used.
To do the actions that you suggest using CTrade, I would write it like this.
CTrade trade;
MqlTick CurrentTick;
SymbolInfoTick(_Symbol,CurrentTick);
// open new position
double sl,tp; // set these to appropriate distance from CurrentTick.ask
if (!trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,0.1,CurrentTick.ask,sl,tp,"comment"))
{
Print("Problem with CTrade::PositionOpen");
return;
}
// change sl and tp to new values
// sl=??????;
// tp=??????;
if (!trade.PositionModify(_Symbol,sl,tp))
{
Print("Problem with CTrade::PositionModify");
return;
}
No comments:
Post a Comment