Ask! - page 30

 

for (int cnt1=OrdersTotal()-1;cnt1>=0;cnt1--)

OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);

if (OrderType()>=OP_SELL && OrderSymbol()==Symbol() && (OrderMagicNumber () == MagicNumber || MagicNumber==0))

{

if(OrderStopLoss()>Ask+Point*15||OrderStopLoss()==0)

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(15 *Point),Bid-(20*Point),Cyan); //Modify stop loss and take profit

return(0);

}

if (OrderType()>=OP_BUY && OrderSymbol()==Symbol() && (OrderMagicNumber () == MagicNumber || MagicNumber==0))

{

if(OrderStopLoss()<Bid-Point*15 ||OrderStopLoss()==0)

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(15*Point),Ask+(20*Point),Cyan); //Modify stop loss and take profit

return(0);

}

return(0);

}

}

Getting closer, but not quite there! This is really trying my patience!

Dave

<<<

 

then add this maybe better

iscuba11:
for (int cnt1=OrdersTotal()-1;cnt1>=0;cnt1--)

OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);

if (OrderType()>=OP_SELL && OrderSymbol()==Symbol() && (OrderMagicNumber () == MagicNumber || MagicNumber==0))

{

if( OrderOpenPrice() - Ask >= TrailingStop * Point)

{

if(OrderStopLoss()>Ask+Point*15||OrderStopLoss()==0)

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(15 *Point),Bid-(20*Point),Cyan); //Modify stop loss and take profit

}

return(0);

}

if (OrderType()>=OP_BUY && OrderSymbol()==Symbol() && (OrderMagicNumber () == MagicNumber || MagicNumber==0))

{

if( Bid - OrderOpenPrice() >= TrailingStop * Point)

{

if(OrderStopLoss()<Bid-Point*15 ||OrderStopLoss()==0)

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(15*Point),Ask+(20*Point),Cyan); //Modify stop loss and take profit

}

return(0);

}

return(0);

}

}

Getting closer, but not quite there! This is really trying my patience!

Dave

<<<
 
Maji:
Please post your code within the [PHP][/PHP] codes. It is much easier to read and debug formatted code.

I am piece mealing this program together. I am close to completing it. Unfortunately, there are no schools on this language and the documentation leaves a lot to be desired. In that being said, I do not have a clue what you are talking about. No offense intended!

Dave <<<
 

then add this maybe better[/QUOTE

This is the latest backtester run. So close yet so far. Reminds me of my Vietnam days. Check out the .gif of the results attached. I owe you for having the goodness of your heart to help me through this tribulation moment! It still seems as if there is a loop that is not exiting as showing in the sell trade.

Dave <<
 
iscuba11:
I owe you for having the goodness of your heart to help me through this tribulation moment!
Dave <<

you are wellcome

 

I still have a loop - darn it. I am going to crash. Tomorrow is another day. This low level language is the pits to learn.

Dave <<<

///////////////////MODIFY STOP LOSS & TAKE PROFIT AT START OF SLEEP CYCLE /////////////////

for (int cnt1=OrdersTotal()-1;cnt1>=0;cnt1--)

OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);

if (OrderType()>=OP_SELL && OrderSymbol()==Symbol() && (OrderMagicNumber () == MagicNumber || MagicNumber==0))

{

if(OrderOpenPrice()-Ask>=TrailingStop*Point)

{

if(OrderStopLoss()>Ask+Point*15||OrderStopLoss()==0)

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(15 *Point),Bid-(20*Point),Cyan); //Modify stop loss and take profit

}

return(0);

}

if (OrderType()>=OP_BUY && OrderSymbol()==Symbol() && (OrderMagicNumber () == MagicNumber || MagicNumber==0))

{

if(Bid-OrderOpenPrice()>=TrailingStop*Point)

{

if(OrderStopLoss()<Bid-Point*15 ||OrderStopLoss()==0)

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(15*Point),Ask+(20*Point),Cyan); //Modify stop loss and take profit

}

return(0);

}

return(0);

}

}

//////////////////////////////////////////////////////////////////////////////////////

My coding as it stands above. There is a bug in it that causes a modification loop. Many bugs or additions have brought it to this stage. Please help find the loop bug somebody!

 

or may it was my missunderstood of you purpose

what do you want the OrderModify() function to do so?

to do trailling stop or something else?

pls clearify it again

 

The original design is to tighten up the stop losses and take profits on any open buy or sell orders when the program is about to go into its sleep mode.

Instead of a large 40 - 50 pip stop loss and a large 100 pip take profit in each open trade, I wanted each open trades be reduced to a 15 pip stop loss, and the take profit of 100 be reduced to a 25 pip take profit.

Then the program would sleep (stop) and the open trades would run their course without any further program intervention (sleep mode) - Each open trade would then make either a 25 pip profit or make a 15 pip loss and close themselves out.

I hope this helps clarify the purpose of the stop loss and take profit modification. I am sorry for the misunderstanding. Please help if you will to accomplish these modifications! Thanks so much for your help up to now!

Boy, did need the sleep last night myself!

Dave

<<<
 
iscuba11:
I am piece mealing this program together. I am close to completing it. Unfortunately, there are no schools on this language and the documentation leaves a lot to be desired. In that being said, I do not have a clue what you are talking about. No offense intended!
Dave <<<

When you are going to copy and paste a code snippet, select that little "php" button on top of the edit screen. Alternatively, you can first type "[ PHP ]"

and then end your code by typing "[ /PHP ]" without the quotes and remove the spaces within the square brackets. See what you get

 
Maji:
When you are going to copy and paste a code snippet, select that little "php" button on top of the edit screen. Alternatively, you can first type "[ PHP ]" and then end your code by typing "[ /PHP ]" without the quotes and remove the spaces within the square brackets. See what you get

The PHP button? Is this located on the forum side or the MetaEditor from which I am copying the code from?? I cannot find a PHP button on the MetaEditor.

Dave <<<