You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Vangrosh
thanks for the input
can you help me to under stand
is this correct
i do an EA with auto trail
if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
{if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); // place a TP and SL
}
if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) // place TP
{
if(OrderStopLoss()>(Ask+Point*TrailingStop)+Point) // check true
{
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red)) // if true modify order
Print("Error_Modify - ",GetLastError());
else str=StringConcatenate("\n My ticket number is ", OrderTicket(), " and my stop loss setting is ", DoubleToStr(Ask+Point*TrailingStop,Digits)); // new code
}
}
}
Here is what I wrote in another post, explaining the different approach.
>>Here is an easy fix simply by checking that the new stoploss price is at least 1 point or greater then the old stoploss. Just do the reverse for a Sell order.
Here is the complete function I use. Now that I think about it I could have used a better var name then nextStopLoss, and I should also add error checking to the OrderModify().
Also my Trailing Stop function is in an EA that can have multiple orders opened at the same time, that is why it has those params so I can update the Trailing Stop on multiple orders at the same time.
Then in my start() function I have:
I left the other function calls in there just so you can see that I like to partition my code into specific functions as much as possible. It makes things a lot easier.
Good luck with your EA.
Here is what I wrote in another post, explaining the different approach.
>>Here is an easy fix simply by checking that the new stoploss price is at least 1 point or greater then the old stoploss. Just do the reverse for a Sell order.
Here is the complete function I use. Now that I think about it I could have used a better var name then nextStopLoss, and I should also add error checking to the OrderModify().
Also my Trailing Stop function is in an EA that can have multiple orders opened at the same time, that is why it has those params so I can update the Trailing Stop on multiple orders at the same time.
Then in my start() function I have:
I left the other function calls in there just so you can see that I like to partition my code into specific functions as much as possible. It makes things a lot easier.
Good luck with your EA.
thank you - it look good
so do you place your start() function at the bottom of the ea
I have a problem too with dreadful error. Thing is, I don't have stop loss or take profit, it just fails to place the pending order, lots of pips away from the market where there should be no problem...
Problem with good'ole 130 is that it indicates (one of) a class or group of errors and does not lead one to any instant fix..
You can even fix a problem and its still there
Only thing that occurs here is a typo?
Maybe you are entering a Buy Limit above Ask, when you intended a Buy Stop order?
FWIW
-BB-
Problem with good'ole 130 is that it indicates (one of) a class or group of errors and does not lead one to any instant fix..
You can even fix a problem and its still there
Only thing that occurs here is a typo?
Maybe you are entering a Buy Limit above Ask, when you intended a Buy Stop order?
FWIW
-BB-
I have a function that selects operation type:
like this:
09:28:46 2008.06.09 00:00 ForexCraft2 EURGBP,Daily: Opening Sell on level 2 for pylon 0 @ 0.8024 while bid = 0.8016
09:28:46 2008.06.09 00:00 ForexCraft2 EURGBP,Daily: OrderSend error 130
09:28:46 2008.06.09 00:00 ForexCraft2 EURGBP,Daily: ReliableOrderSend error : 130 : Invalid stops.
Hello TheEconomist
just some quickies...
1. Do not see any normalizes on ToCompare, unless WhatOperation() is guarranteed to have norm'd actual given it.
2. Double comps have issues - eg, 'Conditional Statement failure... [At wits end] if ( 1.4225 > 1.4225) is NOT TRUE!!!!!!'
3. Do you follow guidance in https://book.mql4.com/appendix/limits
Regards
I've been studying this post in hops of solving my error in 'Quick Question' with 130. The order send function is there as well as the journal entries with Print function, do any of you guys know whats going on?
Thanks,
Bauer Boy
.
as seen on .../24681
1. StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
SL,TP must be at least StopLevel points away from Bid
See below (**)
2. ACCTxx = NormalizeDouble(Ask ..(..), Digits);
3. Print("Bid=",DoubleToString(Ask,Digits),", Ask=",DoubleToString(Bid,Digits));
4. Print ("Stop Loss Value",DoubleToString( ACCTSL,Digits),", stopLoss=",stopLoss);
Print ("Take Profit Value", DoubleToString(ACCTTP,Digits),", takeProfit=",takeProfit);
Why DoubleToString()? Print() only displays FOUR DIGITS
Btw, I'd also somewere at least once Print("MyDig=",MyDig); Why? no way can you then have to worry about it. May seem petty but you'd be amazed by the funnies surrounding such simple stuff!
5. ALL your issues can be easily solved by getting all available information at your fingertips and displaying it.
Then, with good old fashioned paper + pencil you can see where missunderstandings are.
(**)
Ref: https://book.mql4.com/appendix/limits
StopLevel Minimum Distance Limitation.
A trade operation will not be performed if any of the following conditions is disrupted.
.
as seen on .../24681
1. StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
SL,TP must be at least StopLevel points away from Bid
See below (**)
2. ACCTxx = NormalizeDouble(Ask ..(..), Digits);
3. Print("Bid=",DoubleToString(Ask,Digits),", Ask=",DoubleToString(Bid,Digits));
4. Print ("Stop Loss Value",DoubleToString( ACCTSL,Digits),", stopLoss=",stopLoss);
Print ("Take Profit Value", DoubleToString(ACCTTP,Digits),", takeProfit=",takeProfit);
Why DoubleToString()? Print() only displays FOUR DIGITS
Btw, I'd also somewere at least once Print("MyDig=",MyDig); Why? no way can you then have to worry about it. May seem petty but you'd be amazed by the funnies surrounding such simple stuff!
5. ALL your issues can be easily solved by getting all available information at your fingertips and displaying it.
Then, with good old fashioned paper + pencil you can see where missunderstandings are.
(**)
Ref: https://book.mql4.com/appendix/limits
StopLevel Minimum Distance Limitation.
A trade operation will not be performed if any of the following conditions is disrupted.
Really can't tell what is going on and why this is happening
2009.08.05 14:32:26 Trender Beta Test EURUSD,H1: OrderSend (Trender Beta Test ) failed with error #130
2009.08.05 14:32:26 Trender Beta Test EURUSD,H1: MyDig=10
2009.08.05 14:32:26 Trender Beta Test EURUSD,H1: Take Profit Value1.43155, takeProfit=110
2009.08.05 14:32:26 Trender Beta Test EURUSD,H1: Stop Loss Value1.42255, stopLoss=200
2009.08.05 14:32:26 Trender Beta Test EURUSD,H1: Bid=1.44255, Ask=1.44229
Really can't tell what is going on and why this is happening
Really it's time to show the whole code. If you hesitate, you can use PM.
I see you have TP lower then Bid