code help

Questions about MultiCharts and user contributed studies.
drudominique
Posts: 70
Joined: 17 Mar 2010

code help

Postby drudominique » 14 Oct 2010

I would like to know how to program this.
purchase when a moving average crosses another (the value it did not matter to understand) and I want a stop of 30 pips if I touch my stop I make a sell order if the stop the sale of 30 pips key is I run a purchase order is my take profit 50 pips how?


I am in the simulation.
thank you

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: code help

Postby furytrader » 15 Oct 2010

I'd be happy to help but you need to be clearer in what it is you're trying to do.

Maybe you could write it down in a list.

1) I will buy the market when ...
2) After buying, I will look to take profits when ...
3) After buying, I will look to protect against losses when ...
4) I will sell short the market when ...

et cetera ...

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: code help

Postby Dave Masalov » 15 Oct 2010

Dear drudominique,

Please try touse the following:

For entry use MovAvg2Line Cross LE/MovAvg2Line Cross SE strategy.

For exit - StopLoss and ProfitTarget signals with the values: 30 points * pointvalue, 50 points * pointvalue.

drudominique
Posts: 70
Joined: 17 Mar 2010

Re: code help

Postby drudominique » 15 Oct 2010

sorry I do not speak English.

here is the problem:

I get in position on a cross of MM.
starting position of 0.1 contracts (forex).

once I'm in position I put a take profit of 30 pips.

eg I'm buying a 1.40 on euro dollar:

if the current falls to 1.3950 close my position buying and selling I open a position if the court contracts 0.3 has 1.40 I cut back my position and I am selling a position of 1.2 purchase contract etc. .. I do this until a take profit is hit.

As I do not get a take advantage of either purchase or sale I do not fit into position with my MM if a take profit is hit when I start the cycle with the 0.1 mm and with contract.


thank you for your help.

FRENCH

desolé je parle pas anglais .

voila le problème :

je rentre en position sur un croisement de MM .
position de départ 0.1 contrat ( forex ) .

une fois que je suis en position je met un take profit de 30 pips .

exemple je suis en achat a 1.40 sur euro:dollar :

si le cour descends a 1.3950 je ferme la position achat et j'ouvre une position vente de 0.3 contrats si le cour remonte a 1.40 je coupe ma position vente et je prends une position achat de 1.2 contrat etc.. je fais ça jusqu'à ce que un take profit est toucher .

tant que je ne touche pas un take profit soit en achat soit en vente je ne rentre pas en position avec mes MM si un take profit est toucher alors je recommence le cycle avec les mm et avec 0.1 contrat.

merci de votre aide.
merci de votre aide.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: code help

Postby Dave Masalov » 15 Oct 2010

Dear drudominique,

We understand the logic of your script. You can code it in PowerLanguage, but it will take some time. The signals that I metionned in previous post should help you to understand how your script should be written.

If you are intersted in custom programming please contact us directly via e-mail.

drudominique
Posts: 70
Joined: 17 Mar 2010

Re: code help

Postby drudominique » 15 Oct 2010

Hello.
I prefer free help but I feel that this kind of thing on the internet is now finished it's sad.
I will try to solve my problem alone.
Dave attention this is not a criticism against you because I have great respect for you as you provide valuable assistance to users multichart.
Dave you know my goal is not to become rich trading with I'm not naive I am 55 years old at my age people watch television, make their garden etc. .. this is me trading it allows me to keep me informed of what's happening in the world and make my brain :-)
if I win a few hundred dollars a month and although I'm happy and I go to a restaurant or buy something that makes me happy and I'm happy like this.
the dream of becoming rich with the trading I leave that to the youth I am aware that the overwhelming majority of tradeurs lose money.

cordially
FRENCH
Bonjour.
j'aurais préférer une aide gratuite mais j'ai le sentiment que ce genre de chose sur internet est maintenant fini c'est triste .
je vais donc essayer de résoudre mon problème seul .
attention Dave ce n'est pas une critique contre vous car j'ai beaucoup de respect pour vous car vous apporter une aide précieuse aux utilisateurs de multichart .
vous savez Dave mon but n'est pas de devenir riche avec le trading je ne suis pas naif j'ai 55 ans a mon age les personnes regarde la télévision,font leur jardin etc..moi c'est le trading cela me permet de me tenir au courant de ce qui se passe dans le monde et de faire travailler mon cerveau :-)
si je gagne quelques centaines de dollar dans un mois et bien je suis content et je vais au restaurant ou j'achete quelque chose qui me fait plaisir et je suis heureux comme ça .
le rêve de devenir riche avec le trading je laisse ça aux jeunes moi je sais parfaitement que l'écrasante majorité des tradeurs perdent de l'argent .
cordialement

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

Re: code help

Postby TJ » 15 Oct 2010

Hello.
I prefer free help but I feel that this kind of thing on the internet is now finished it's sad....
cordialement
There are plenty of free help here,
no freeloader though.

You can start here: (2nd post)
viewtopic.php?f=16&t=6929

Plus, there are over 150 strategies in your PLEditor.
You can "borrow" the codes and learn to concoct your own autotrade.

Post your work-in-progress if you got stuck.
We have a very helpful community here,
I am sure someone can lend you a helping hand.

drudominique
Posts: 70
Joined: 17 Mar 2010

Re: code help

Postby drudominique » 16 Oct 2010

Here is the code I have already done it but am not at all what I want :-)
it increments the number of contract not properly, it takes a position with mm before my take profit or touch etc. ..

Code: Select all

input :profits(30),open_position(50);
inputs: Price( Close), FastLength( 5), SlowLength( 9) ;
variables: FastAvg( 0 ), SlowAvg( 0 ) ,nb(10000) ,mp(0);
FastAvg = AverageFC( Price, FastLength ) ;
SlowAvg = AverageFC( Price, SlowLength ) ;


if CurrentBar > 1 and FastAvg crosses under SlowAvg then
Sell short ( "MA_SELL" ) nb contract Next Bar at Market;

if CurrentBar > 1 and FastAvg crosses over SlowAvg then
Buy ( "MA_BUY" ) nb contract Next Bar at Market;

mp=marketposition;

{ parametres pour le forex euo/usd}

If mp=1 then begin
if close >entryprice+profits then begin
sell nb contract next bar at market;
nb=10000;
end;
end;

If mp =-1 then begin
if close <entryprice-profits then begin
buy to cover nb contract next bar at market;
nb=10000;
end;
end;

If mp=1 {and mp[1]=0} then begin
if (Entryprice-close)>open_position then begin
Sell nb contract next bar at market;
nb=nb*3;
Sell short nb contract next bar at market;
end;
end;

If mp=-1 {and mp[1]=0} then begin
If (close-Entryprice) >open_position then begin
Buy to cover nb contract next bar at market ;
nb=nb*3;
buy nb contract next bar at market;
end;
end;

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

Re: code help

Postby TJ » 16 Oct 2010

Here is the code I have already done it but am not at all what I want :-)
it increments the number of contract not properly, it takes a position with mm before my take profit or touch etc. ..
...
This is advanced programming.

you might be trying to run before you can walk...

my suggestions:
1. start with an indicator -- replace your BUY/SELL orders with a plot statement, so that you can visually inspect the time and location of your logic. When you are satisfied that your logics are triggering at the correct places, then migrate your indicator to a strategy.

2. When you are testing your logic, use streaming data instead of backtesting.
-- Check out Interactivebrokers' website for the free demo system datafeed.

drudominique
Posts: 70
Joined: 17 Mar 2010

Re: code help

Postby drudominique » 17 Oct 2010

Hello.
I managed to code exactly what I wanted it have not been easy but I still could cook.

me and my problem also revealed today that if you seek assistance from a little more complicated than traditional applications you have to pay a year ago I received help for free because it was the policy of Multichart Now I feel like TS only the money matters is very sad.
Finally, I guess that's what we call progress.
in the meantime I hope we have as promised by multichart our DOM before the end of the fall as they had told us on a post regarding this.
thank you

FRENCH

Bonjour.
J'ai réussi a coder exactement ce que je voulais cela n'as pas été facile mais je suis quand même arriver a le faire.

mais mon problème m'as aussi permis de constater que si aujourd'hui vous demander une aide un peu plus compliqué que les demandes classique vous devez payer il y a un an j'aurais obtenu une aide gratuitement car c'était dans la politique de Multichart maintenant j'ai le sentiment que comme pour TS seul le fric compte c'est bien triste .
enfin je suppose que c'est ce que nous appelons le progrès .
en attendant j'espère que nous aurons comme promis par multichart notre DOM avant la fin de l'automne comme ils nous l'avait dit sur un post concernant ce sujet.
merci

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: code help

Postby Dave Masalov » 26 Oct 2010

Dear drudominique,

We have always helped our customers with coding questions if it was 5-10 minutes deal. However, if it takes considerable amount of time to code what you need we can do it only as a custom programming project. Sometimes we make some exceptions if it is really something basic and the coders have spare time, but generally we do not do this.

Please do not exgerate things, it is not all about money as you said.

Regarding manual trading, it is planned to be implemented in the middle of November.

drudominique
Posts: 70
Joined: 17 Mar 2010

Re: code help

Postby drudominique » 26 Oct 2010

ok no problem I know you help many customers so please forgive me for my comments because you are misplaced.
DOM for the month of November is a very good news.

and again I apologize for my remarks.
cordially

FRENCH

ok pas de problème je sais que vous aider beaucoup vos clients donc veuillez me pardonner mes propos qui sont vous avez raison mal placé .
pour le DOM au mois de novembre c'est une très bonne nouvelle .

et encore mes excuses pour mes propos .
cordialement

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

Re: code help

Postby TJ » 26 Oct 2010

Hello.
I managed to code exactly what I wanted it have not been easy but I still could cook.
...
as a courtesy to the community,
you should post your solution,
so that everybody can learn from it.


Return to “MultiCharts”