Quote:
|
Originally Posted by jojolalpin
I don't like to have orders with no SL or no TP and when using superclose(), there is no TP untill Trailing be activated. So I ask why not set an initial takeprofit (before superclose set one) to be secured in case of computercrash. That's why I proposed two times the value of takeprofit variable.
Also to initiate on the test plan, parameters are:
Stoploss: 10 to 30?
Takeprofit: 20 to 100?
TimeFrames: M1 M15 H4 Daily Weekly..
Currencies: 12 from Holyguy7 selection? only those with a little spread (<=5)?
those are just suggestions.
|
Ok, I see what you mean now. It's fairly easy to do. I use a dedicated server with 100% up time, so i neglect to think about things like that.
And here are some notes on the superclose(). I was hoping to be able to have the ability to track TS prices by the ticket number, so you can set MaxTrades to more than 1 AND be able to trail by less than 10 pips.
PHP Code:
void SuperClose(){
for(int i=0;i<OrdersTotal();i++){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderSymbol()==Symbol() && OrderMagicNumber()==ID){//Pulls in order that meets the criteria for processing
int num=0;int pos=0;
for(int b=0;b<21;b++){// this (loopB) compares the ticket# of the selected order against the number stored in the ticket array
if(tsTicket[b]==OrderTicket() ){
num++; pos=b;// if ticket numbers match, pos is the position in the array where the trailing data is stored
Print("(",pos,") Ticket ",tsTicket[pos]," found. SL is ",tsPrice[pos]);
break;
}
}
if(num==0){ // if the loopB did not find a matching ticket number it is time to initialize the data
for(int j=0;j<21;j++){
if(tsTicket[j]==0){// this is looking for the earliest instance within the array to store the data
pos=j;
break;
}
}
tsTicket[pos]=OrderTicket();// setting the ticket number
tsok[pos]=false;// this is to determine when trailing kicks in
Print("(",pos,") New ticket initialized = ",tsTicket[pos]);
}
if (OrderType()==OP_SELL) {
if (!tsok[pos] && (OrderOpenPrice()-Ask>=TSactivation*Point || TSactivation==0 ) ) {// if the trailing factor is false, but it has hit the activation point continue
tsPrice[pos]=Ask+TrailPips*Point;// this is the new trailinf stop price
tsok[pos]=true;// it's ok to proceed with trailing stop
if(TrailPips>8){// if this distance from the current price to the new stop, then modify the order.
ModifyStopLoss(Ask+TrailPips*Point);//modifies order
}
}
if (tsok[pos] && Ask+TrailPips*Point < tsPrice[pos] ){//if the position is gaining in profit
tsPrice[pos]=Ask+TrailPips*Point;
if(TrailPips>8){
ModifyStopLoss(Ask+TrailPips*Point);
}
}
if (tsok[pos] && Ask >= tsPrice[pos] ){// if the postion hits the stop price
CloseOrder(2);
Print("Order ",tsTicket[pos]," Closed from TS");
}
}
if (OrderType()==OP_BUY) {// reverse of SELL
if(!tsok[pos] && (Bid-OrderOpenPrice() >= TSactivation*Point || TSactivation==0 ) ) {
tsPrice[pos]=Bid-TrailPips*Point;
tsok[pos]=true;
if(TrailPips>8){
ModifyStopLoss(Bid-TrailPips*Point);
}
}
if (tsok[pos] && Bid-TrailPips*Point > tsPrice[pos] ){
tsPrice[pos]=Bid-TrailPips*Point;
if(TrailPips > 8){
ModifyStopLoss(Bid-TrailPips*Point);
}
}
if (tsok[pos] && Bid <= tsPrice[pos] ){
CloseOrder(1);
Print("Order ",tsTicket[pos]," Closed from TS");
} } } } }
for(i=0;i<21;i++){// this searches the array for ticket numbers that are now obsolete due to an order that has closed
if(tsTicket[i]>0){
bool found=false;
for(b=0;b<OrdersTotal();b++){
OrderSelect(b,SELECT_BY_POS);
if(tsTicket[i]==OrderTicket()){
found=true;
break;
}
}
if(!found){// if there are matching ticket numbers in the trade pool and the array then nothing happens
tsTicket[i]=0;tsPrice[i]=0;tsok[i]=false;// if there is an obolete ticket the the data is reset. And the next new ticket data can occupy this space
Print("Array pos ",i," Cleaned");
} } } }