how to create stoploss and trailing stop with.....

Questions about MultiCharts and user contributed studies.
RedBerlin
Posts: 81
Joined: 05 Dec 2014

how to create stoploss and trailing stop with.....

Postby RedBerlin » 11 Dec 2014

hallo
pleasesay how can I create my own stoploss and trailing stop orders using stop limit orders?
someone could please ,say how to do it?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: how to create stoploss and trailing stop with.....

Postby TJ » 11 Dec 2014

hallo
pleasesay how can I create my own stoploss and trailing stop orders using stop limit orders?
someone could please ,say how to do it?
EasyLanguage Essentials Programmers Guide

Creating Trading Strategies
Strategy Order Syntax ..... pg 80

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: how to create stoploss and trailing stop with.....

Postby TJ » 11 Dec 2014

hallo
pleasesay how can I create my own stoploss and trailing stop orders using stop limit orders?
someone could please ,say how to do it?
Creating your own exit orders is no different than writing the entry order -- you have to know your syntax, and you have to have a workable logic.

My suggest would be, to start with a flowchart...
A flowchart allows you to visualize your logic in simple step by step decisions.

Do remember one thing --
The human mind is complex, it can think in 4 dimensions and process multiple logics at the same time.
The computer, on the other hand, can only do one thing at a time. You have to tell the computer what to do STEP BY STEP, as if you are talking to a child.

Here is an example of a flowchart, hope it can get you started in the right direction:

Image

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 11 Dec 2014

hallo
pleasesay how can I create my own stoploss and trailing stop orders using stop limit orders?
someone could please ,say how to do it?
Creating your own exit orders is no different than writing the entry order -- you have to know your syntax, and you have to have a workable logic.

My suggest would be, to start with a flowchart...
A flowchart allows you to visualize your logic in simple step by step decisions.
grazie TJ ..I 'll try to do it!!!!

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 13 Dec 2014

Code: Select all

[LegacyColorValue = TRUE];

inputs:
ATRLength(2), ATRMult(2.1), UpColor(cyan), DnColor(magenta),TicksAway( 1 ) ;

vars:
ATR(0),
avg(0),
dn(0),
up(0),
trend(1),
flag(0),
flagh(0),
SuperTrend(0),
sellStopPrice(0),
sellLimitPrice(0);


ATR = AvgTrueRange(ATRLength) * ATRMult;
avg = (high + low)/2;
up = avg + ATR;
dn = avg - ATR;

if close > up[1] then
trend = 1
else if close < dn[1] then
trend = -1;

if trend < 0 and trend[1] > 0 then flag=1 else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0;

if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];

if flag = 1 then up = avg + ATR;
if flagh = 1 then dn = avg - ATR;



if trend = 1 and trend [1] < 0 then buy 5000 shares next bar C+ 4*minmove/pricescale limit
else
if marketposition=1 and trend [1] >0 then
Sell 5000 shares total next bar c+30*MinMove/pricescale stop c+31* MinMove/pricescale limit;

if trend = -1 and trend [1] >0 then Sellshort next bar C- 4*minmove/pricescale limit;
sorry
Itried to do it just for long position but it seems like a kind of take profit !!!
I d like stop limit order.....now I have headache.....
my logic is ridiculuss

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 15 Dec 2014

hallo
pleasesay how can I create my own stoploss and trailing stop orders using stop limit orders?
someone could please ,say how to do it?
Creating your own exit orders is no different than writing the entry order -- you have to know your syntax, and you have to have a workable logic.

[/img]
Hello TJ
when you say "Creating your own exit orders is no different than writing the entry order"
this means that in the same way is possible to put =trailing-take profit and breakeven?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: how to create stoploss and trailing stop with.....

Postby TJ » 15 Dec 2014

hallo
pleasesay how can I create my own stoploss and trailing stop orders using stop limit orders?
someone could please ,say how to do it?
Creating your own exit orders is no different than writing the entry order -- you have to know your syntax, and you have to have a workable logic.

[/img]
Hello TJ
when you say "Creating your own exit orders is no different than writing the entry order"
this means that in the same way is possible to put =trailing-take profit and breakeven?
Yes...

If you can visualize your logic in a step-by-step flowchart, you can code it into your strategy.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: how to create stoploss and trailing stop with.....

Postby MAtricks » 16 Dec 2014

Red,

Make sure that you are using a tick by tick back-test while using every "bad" exit feature that Power/Easy Language has to offer haha... I highly recommend NOT using Breakeven stops, small Stoplosses, and any built in Trail Stops. They don't work well even if used properly. Save yourself a headache and listen to this tidbit..

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 16 Dec 2014

Red,

Make sure that you are using a tick by tick back-test while using every "bad" exit feature that Power/Easy Language has to offer haha... I highly recommend NOT using Breakeven stops, small Stoplosses, and any built in Trail Stops. They don't work well even if used properly. Save yourself a headache and listen to this tidbit..
thanks matrix
I have not forgotten your advice,
but then you do trading without stop loss or profit?
however, you can at least help me build the stoploss all as you did with the code you gave me?
please
grazie

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: how to create stoploss and trailing stop with.....

Postby MAtricks » 16 Dec 2014

There's a lot of back and forth with your questions here. Please take your time and formulate your questions clearly. Think of it this way: If your question is easy to read and clearly understood, we will not only answer it, but we will enjoy answering it. If we have to read your questions multiple times and still want to bang our head on the desk because of the confusion (current scenario), we probably won't even reply.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 16 Dec 2014

There's a lot of back and forth with your questions here. Please take your time and formulate your questions clearly. Think of it this way: If your question is easy to read and clearly understood, we will not only answer it, but we will enjoy answering it. If we have to read your questions multiple times and still want to bang our head on the desk because of the confusion (current scenario), we probably won't even reply.
first of all
thanks for your help and your patience will try to understand what
I would like to do !!!!
if you remember, you did for me the right code for sellshort limit!!!

Code: Select all

if trend = 1 and trend [1] < 0 then buy next bar C+ 4*minmove/pricescale limit;
if trend = -1 and trend [1] >0 then Sellshort next bar C- 4*minmove/pricescale limit;
I need the same help for: stop limit order!!=which means ,I need thet multicharts send
stoploss order with price!!!!

and if you have time same thing for trailing stop and profit, just to trial software!!!!!!
please
I hope it is clear
ciao

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: how to create stoploss and trailing stop with.....

Postby MAtricks » 16 Dec 2014

Code: Select all

setstoploss( 500 ) ; //replace the $500 with whatever amount you desire.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 17 Dec 2014

Code: Select all

setstoploss( 500 ) ; //replace the $500 with whatever amount you desire.
thanks Matricks
but my broker doesn 't accept this order!!!
it answer: stop loss at market not accepted!!!!!!!!!!
I need to replace a order stoploss with price just like the
code that you
have write to me!!!
maybe this is a = A STOP LIMIT ORDER?
I don' know .

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: how to create stoploss and trailing stop with.....

Postby MAtricks » 17 Dec 2014

You definitely do not want to use a stop limit order to exit a trade. Your initial question is asking how to create a stoploss with LIMIT orders which is ludicrous.

Your broker won't allow a STOP order? Or is there something wrong with you using Setstoploss? If so use something like this:

Code: Select all

[IntrabarOrderGeneration = True]

INPUTS:
StopLoss( 10 ) ; //Calculated in TICKS

VARIABLES:
MM( MinMove/PriceScale ),
SL( StopLoss*MM ) ;

Sell( "LX" ) all Shares next bar EntryPrice-SL STOP ;
BuyToCover( "SX" ) all Shares next bar EntryPrice+SL STOP ;

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: how to create stoploss and trailing stop with.....

Postby MAtricks » 17 Dec 2014

Can you use a Market order stop? It wouldn't be as safe as a STOP order, but an intrabar MARKET order might be your best bet. Convert my stoploss code in the previous post to MARKET orders and that should do the trick.

Who's your broker? Sorry to be so abrupt, but why on earth are you trading with so little knowledge of the markets? My advice: Don't place a live trade until you've spent 5000 hours staring at charts and coding strategies and even that isn't enough.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 17 Dec 2014

Can you use a Market order stop? It wouldn't be as safe as a STOP order, but an intrabar MARKET order might be your best bet. Convert my stoploss code in the previous post to MARKET orders and that should do the trick.

Who's your broker? Sorry to be so abrupt, but why on earth are you trading with so little knowledge of the markets? My advice: Don't place a live trade until you've spent 5000 hours staring at charts and coding strategies and even that isn't enough.
ciao Matricks and thank you!!!
my broker wants for stoploss =stop price and limit price;
this is a STOP LIMIT ORDER?
I don't know!!
I 'll use your code above tomorrow and then I 'll say you if is works!!!
about my knowledge in easy language and trading system ,is true,Im
without any knowledge to programming , about words ,for example which is difference
between true and false?,but I m trader on line since 1998 and since2007 I
closed every year in positive!!
I m not rich and I work in hotel for only 1200 euro per month,but trading online is my passion
and before end month of trial to multicharts I d like trial in real time
because in trading first thing is =never afraid!!!
my opinion if course!!!!!!!!!!!
so please I just need to stop limit order and trailing order!!!
my broker IS Directa italian broker,it is very good and maybe best broker in Italy
and maybe Im one of the first customers online since 1999!!!
ciao and sorry ......

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: how to create stoploss and trailing stop with.....

Postby MAtricks » 17 Dec 2014

I'm glad that you're experienced. That makes me feel better...

I apologize, but I will not help anyone use an automated stop limit order as a stop loss. I cannot do this. Convert that code I gave you to Market orders and that will work for you.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 17 Dec 2014

I'm glad that you're experienced. That makes me feel better...

I apologize, but I will not help anyone use an automated stop limit order as a stop loss. I cannot do this. Convert that code I gave you to Market orders and that will work for you.
my broker doesn t accept : order at market!!!
so, there is no chance to put stop loss in ts,but TJ said it is possible!!
I called it stop limit order but maybe I wrong......
maybe it is a STOP ORDER or LIMIT ORDERS.
FOR example
buy 4.80
stoploss ;4.70 stop 4.72 limit.....this wants my broker!!!
if it is stop limit-
stop order
limit order
I DONT KNOW!!!

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 18 Dec 2014

I'm glad that you're experienced. That makes me feel better...

I apologize, but I will not help anyone use an automated stop limit order as a stop loss. I cannot do this. Convert that code I gave you to Market orders and that will work for you.
http://www.tradingcode.net/multicharts- ... mit-order/
------------sorry
but in this web site above ,he talks about stop loss or what?
maybe this is the answer at my questions?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: how to create stoploss and trailing stop with.....

Postby JoshM » 20 Dec 2014

A stop-limit order in PowerLanguage would work like:

Code: Select all

Variables:
myLongCondition(False),
stopPrice(0),
limitPrice(0);

if (myLongCondition = True) then begin

Buy ("STP-LMT LE") 1 contracts next bar at stopPrice stop limitPrice limit;

end;
There's more official information about that kind of order here.

More information about the supported order types can be found here: order types. If your broker doesn't support the orders you want to use, there are other brokers to choose from: here's the official broker list and this topic also contains the introducing brokers.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: how to create stoploss and trailing stop with.....

Postby RedBerlin » 20 Dec 2014

A stop-limit order in PowerLanguage would work like:

Code: Select all

Variables:
myLongCondition(False),
stopPrice(0),
limitPrice(0);

if (myLongCondition = True) then begin

Buy ("STP-LMT LE") 1 contracts next bar at stopPrice stop limitPrice limit;

end;
There's more official information about that kind of order here.

More information about the supported order types can be found here: order types. If your broker doesn't support the orders you want to use, there are other brokers to choose from: here's the official broker list and this topic also contains the introducing brokers.
thanks josh
today is saturday and I dont if in real tim your code works.
I trialed in backtest and there is no traces to stoploss with your code!!!
I tried it in this way:

Code: Select all

if trend = 1 and trend [1] < 0 then buy 1000 shares next bar C+ 6*minmove/pricescale limit;
if (myLongCondition = True) then begin

sell ("STP-LMT LE") 1000 shares next bar C- 10*minmove/pricescale stop C- 13*minmove/pricescale limit;

end;


if trend = -1 and trend [1] >0 then Sellshort next bar C- 6*minmove/pricescale limit;
however grazie
ciao


Return to “MultiCharts”