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
thanks!
Thanks mladen!!
its looks very nice:)
Ray
On both places where you have order modify after opening buy order you have the following code :
Bid-(TakeProfit*Point*PipMultiplier),0,DarkRed);
[/php]stop loss and take profit are on a "wrong" side that way (assuming that the order was opened just a few moments ago Bid+((Stoploss*Point*PipMultiplier) is greater than the current price and you can not set the stop loss to that price. The similar (with different side of the price) goes for take profit.
Change the code (here is a mode I prefer - using OrderOpenPrice() when modifying order instead of Bidor Ask- that way the distance for stop loss and take profit should be at exact place regardless of the current Bidor Ask(since there is always a risk that Ask and Bid have changed in the mean time)
[php]OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()-(Stoploss*Point*PipMultiplier),
OrderOpenPrice()+(TakeProfit*Point*PipMultiplier),0,DarkRed);
Attached the changed code (changed only the buy orders modification to the mode I proposed in it) Tested it and it opens and modifies buy order correctly (default take profit set to 50 pips and default stop loss set to 300 pips)
regards
Mladen
Mladen,
I was woundering if you could extend me another programming lesson. I converted Firebird to an ECN. It will Sell and Buy and the Trailing stop works but " no SL & TP". So I added the "ticket = Ordersend...." to all 4 Ordersend lines. Now the Sell will Modify the SL & TP but the Buy won't active the Modfiy.
Can you tell me where I went wrong. This ECN change works for all my EAs except this one. This firebird is the most involed that I have converted.
Ray
Mladen I rewrote the modify and got it working!!! So please disregard this request.
RayFirebird
Mladen
Thanks for the re-do yours looks a lot more stream line then Mine. I always thought using the bid for Buy exits vs the ask for sell exits put your number closer to reality. I can't say thats a fact its just a belief.
Do you know of any Martingales like this for Tradestation?? or web sites. I have never seen a TS martingale EA. TS uses Gann Capitial no such thing as a quick exit maybe thats the reason.
Thanks again for the lesson
Ray
Ray
That OrderOpenPrice() "trick" applies only to case when modifying stop loss and / or take profit on ECN (apart from the stated, the other reasons is laziness : that way I do not have to double check if I should use Ask or Bid in order modify )
That way, even if you allow some slippage and even if the Ask and Bid have changed, you can place the stop loss and take profit at the exact distance where it would be if the order was executed on a non-ecn broker. In all the other cases you must use Ask for buy orders and Bid for sell orders and for all the rest of processing (as I said, this is just one case and one application which I prefer in case of ECN broker)
regards
Mladen
Mladen
Thanks for the re-do yours looks a lot more stream line then Mine. I always thought using the bid for Buy exits vs the ask for sell exits put your number closer to reality. I can't say thats a fact its just a belief.
Do you know of any Martingales like this for Tradestation?? or web sites. I have never seen a TS martingale EA. TS uses Gann Capitial no such thing as a quick exit maybe thats the reason.
Thanks again for the lesson
Rayheikobaer
Here you go
As far as I remember I posted the basic version on one of the public threads (right now could not find it where) but added some stuff to this one, so this is a bit upgraded and improved Wish you a pleasant weekendregards
MladenMany thanks Mladen...looks really good and nice features.
Adding MTF
mLaden,
I tried Converting Nonlag to MTF, it verified but failed to work. I left my Programming , use the term loosely, in as text.
Can you show me the error of my ways?
Ray
Ray
It is simpler to show the whole process of making a single file MTF from a "normal" indicator on a simple code.
So, here is a simplified code of non lag moving average and a mtf version of it with comments and explanations what and why is done at some part of the code. Using this indicator simply because it is much, much simpler to see in it exactly what is done (just take a look at the start procedure of the "non mtf" version)
{
int counted_bars=IndicatorCounted();
int i,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars,Bars-1);
for (i=limit; i>=0; i--) NonLagMaBuffer = iNoLagMa(iMA(NULL,0,1,0,MODE_SMA,Price,i),Length,alphas,0,i);
return(0);
}Also, the code of it is suitable to calculate values of anything. All you have to change is the first parameter in calling the iNoLagMa()function ( theiMA(NULL,0,1,0,MODE_SMA,Price,i) part which is used for fast price extraction in the above code)
_________________________
PS: in these color changes are left out for sake of simplicity. Non repainting color changes need to be coded in a different way and needs at least 2 more buffers so I decided to keep it as simple as possible. Instead made a third indicator that has a multi color non repainting mode (MultiColorparameter) and alerts (since alerts in mtf also have to be taken care of at a specific way) - the "nrp" version does all those things (like this example : it is a 1 hour NonLagMA on a 15 minute chart) regardsmladen
Unbelievable
mladen,
If this were a car, I asked for help to fix a dent in the door and you refinisihed and repainted the entire car.
Some how "Thank You" seems so insignificant. I wish you a good weekend.
Ray