Help requested trying to track losing trades in a strategy

Questions about MultiCharts and user contributed studies.
gpw797
Posts: 216
Joined: 04 Mar 2006
Has thanked: 3 times
Been thanked: 7 times

Help requested trying to track losing trades in a strategy

Postby gpw797 » 26 Jul 2011

how come this isn't working?

vars: counter ( 0 );

If marketposition = 0 and marketposition[1] <> 0 and netprofit < netprofit[1] then begin
counter = counter + 1;
end;


counter isn't counting but netprofit is changing

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

Re: Help requested trying to track losing trades in a strate

Postby TJ » 26 Jul 2011

how come this isn't working?

vars: counter ( 0 );

If marketposition = 0 and marketposition[1] <> 0 and netprofit < netprofit[1] then begin
counter = counter + 1;
end;


counter isn't counting but netprofit is changing
1. please use code tag when posting codes.

2. MarketPosition(PosBack) <-- note bracket type

gpw797
Posts: 216
Joined: 04 Mar 2006
Has thanked: 3 times
Been thanked: 7 times

Re: Help requested trying to track losing trades in a strate

Postby gpw797 » 26 Jul 2011

thanks for helping but that wasn't it...

the netprofit code isn't working.. took it out and it counts fine

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

Re: Help requested trying to track losing trades in a strate

Postby TJ » 26 Jul 2011

thanks for helping but that wasn't it...

the netprofit code isn't working.. took it out and it counts fine
Can you write out in plain English what you would like the logic to achieve?

gpw797
Posts: 216
Joined: 04 Mar 2006
Has thanked: 3 times
Been thanked: 7 times

Re: Help requested trying to track losing trades in a strate

Postby gpw797 » 26 Jul 2011

If the last trade was a losing trade then add that trade count to a cumulative total of losing trades.

For example today there are 4 losing trades so far i.e. counter = 4

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

Re: Help requested trying to track losing trades in a strate

Postby TJ » 26 Jul 2011

If the last trade was a losing trade then add that trade count to a cumulative total of losing trades.

For example today there are 4 losing trades so far i.e. counter = 4
There are a few errors.

Let's start with the first one.

What is the difference between these 2 keywords?

marketposition[1]

marketposition(1)

gpw797
Posts: 216
Joined: 04 Mar 2006
Has thanked: 3 times
Been thanked: 7 times

Re: Help requested trying to track losing trades in a strate

Postby gpw797 » 26 Jul 2011

I don't know... ... is there a place I can look that up? I am a rookie at this stuff but trying to learn.

I would think that marketposition[1] is either -1 (short trade) 0 (no trade) or 1 (long trade) one bar ago...

I am not familiar with the use of marketposition(1)

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

Re: Help requested trying to track losing trades in a strate

Postby TJ » 26 Jul 2011

I don't know... ... is there a place I can look that up? I am a rookie at this stuff but trying to learn.

I would think that marketposition[1] is either -1 (short trade) 0 (no trade) or 1 (long trade) one bar ago...

I am not familiar with the use of marketposition(1)
see the first 2 posts
viewtopic.php?f=16&t=6929

gpw797
Posts: 216
Joined: 04 Mar 2006
Has thanked: 3 times
Been thanked: 7 times

Re: Help requested trying to track losing trades in a strate

Postby gpw797 » 26 Jul 2011

got it.. thanks...

needed to assign a variable to netprofit to reference it historically

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

Re: Help requested trying to track losing trades in a strate

Postby TJ » 26 Jul 2011

I don't know... ... is there a place I can look that up? ...
Press [F1]

most of the answers are there.


Return to “MultiCharts”