Strategy is sending orders even when spec as Marketposition

Questions about MultiCharts and user contributed studies.
designer01
Posts: 80
Joined: 02 Feb 2010

Strategy is sending orders even when spec as Marketposition

Postby designer01 » 14 Nov 2012

I have a triple exit ATR strategy (see script below) that has in it specified to exit only if Marketposition = 1
For some reason it is sending orders even if I have no market position open in the chart. Not sure why. Please help. May be missing a statement?
Thanks

Code: Select all

Inputs:
Length(10), ExitATRs1(1), ExitATRs2(1.5), ExitATRs3(2), TradeSize(25);

Vars: ATR(0);



ATR = AvgTrueRange (Length);

If Marketposition = 1 then begin


Sell ( "AtrLX1" )TradeSize shares {CurrentShares/3 shares} next bar at AvgEntryPrice + ATR * ExitATRs1 limit;
Sell ( "AtrLX2" )TradeSize shares {CurrentShares/2 shares} next bar at AvgEntryPrice + ATR * ExitATRs2 limit;
Sell ( "AtrLX3" )TradeSize shares next bar at AvgEntryPrice + ATR * ExitATRs3 limit;


end;

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

Re: Strategy is sending orders even when spec as Marketposit

Postby TJ » 14 Nov 2012

I have a triple exit ATR strategy (see script below) that has in it specified to exit only if Marketposition = 1
For some reason it is sending orders even if I have no market position open in the chart. Not sure why. Please help. May be missing a statement?
Thanks

Code: Select all

Inputs:
Length(10), ExitATRs1(1), ExitATRs2(1.5), ExitATRs3(2), TradeSize(25);
Vars: ATR(0);
ATR = AvgTrueRange (Length);
If Marketposition = 1 then begin
Sell ( "AtrLX1" )TradeSize shares {CurrentShares/3 shares} next bar at AvgEntryPrice + ATR * ExitATRs1 limit;
Sell ( "AtrLX2" )TradeSize shares {CurrentShares/2 shares} next bar at AvgEntryPrice + ATR * ExitATRs2 limit;
Sell ( "AtrLX3" )TradeSize shares next bar at AvgEntryPrice + ATR * ExitATRs3 limit;
end;
There must be something in the rest of your code that is causing the problem.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy is sending orders even when spec as Marketposit

Postby designer01 » 14 Nov 2012

That is the whole code.. can you give me an example what else it could be

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

Re: Strategy is sending orders even when spec as Marketposit

Postby TJ » 14 Nov 2012

That is the whole code.. can you give me an example what else it could be
you can add this line to the inside as well as outside of the loop:

Code: Select all

print(date, time, " marketposition=", marketposition);
It will show you your marketposition status.
If it is equals to one, then you must have something else going on.


Return to “MultiCharts”